Skip to content

Commit

Permalink
Fixed issue with warning alerts.
Browse files Browse the repository at this point in the history
Changed misleading warnings to errors.
Closes #1071
  • Loading branch information
imolorhe committed Jun 13, 2020
1 parent dd38eba commit 01f8a22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
19 changes: 11 additions & 8 deletions packages/altair-app/src/app/effects/query.ts
Expand Up @@ -137,15 +137,15 @@ export class QueryEffects {
);
selectedOperation = operationData.selectedOperation;
if (operationData.requestSelectedOperationFromUser) {
this.notifyService.warning(
this.notifyService.error(
`You have more than one query operations.
You need to select the one you want to run from the dropdown.`
);
return observableEmpty();
}
} catch (err) {
this.store.dispatch(new queryActions.SetSelectedOperationAction(response.windowId, { selectedOperation: '' }));
this.notifyService.warning(err.message);
this.notifyService.error(err.message);
return observableEmpty();
}

Expand All @@ -169,7 +169,7 @@ export class QueryEffects {
this.electronAppService.setHeaders(headers);

if (this.gqlService.hasInvalidFileVariable(response.data.variables.files)) {
this.notifyService.warning(`
this.notifyService.error(`
You have some invalid file variables.<br><br>
You need to provide a file and file name, when uploading files.
Check your files in the variables section.<br><br>
Expand Down Expand Up @@ -353,6 +353,7 @@ export class QueryEffects {
catchError((err: any) => {
this.store.dispatch(new docsAction.StopLoadingDocsAction(response.windowId));
const errorObj = err.error || err;
const errorMessage = errorObj.message ? errorObj.message : err.message ? err.message : errorObj.toString();
let allowsIntrospection = true;

if (errorObj.errors) {
Expand All @@ -366,14 +367,16 @@ export class QueryEffects {
// If the server does not support introspection
if (!allowsIntrospection) {
this.store.dispatch(new gqlSchemaActions.SetAllowIntrospectionAction(false, response.windowId));
this.notifyService.warning(`
this.notifyService.error(`
Looks like this server does not support introspection.
Please check with the server administrator.
`);
} else {
this.notifyService.warning(`
this.notifyService.error(`
Seems like something is broken. Please check that the URL is valid,
and the server is up and running properly.
<br>
${errorMessage}
`);
}
return observableEmpty();
Expand All @@ -398,7 +401,7 @@ export class QueryEffects {
}),
catchError((error: any) => {
debug.error(error);
this.notifyService.warning(error.message);
this.notifyService.error(error.message);
return observableEmpty();
})
);
Expand Down Expand Up @@ -510,7 +513,7 @@ export class QueryEffects {
selectedOperation = operationData.selectedOperation;
} catch (err) {
this.store.dispatch(new queryActions.SetSelectedOperationAction(response.windowId, { selectedOperation: '' }));
this.notifyService.warning(err.message);
this.notifyService.error(err.message);
return observableEmpty();
}

Expand Down Expand Up @@ -748,7 +751,7 @@ export class QueryEffects {
...refactorResult.variables,
}, null, 2), res.windowId));
} catch (err) {
this.notifyService.warning('Looks like your variables are not formatted properly');
this.notifyService.error('Looks like your variables are not formatted properly');
return observableEmpty();
}
return observableOf(new queryActions.SetQueryAction(refactorResult.query, res.windowId));
Expand Down
Expand Up @@ -4,6 +4,7 @@ import { isExtension } from '../../utils';
import { Store } from '@ngrx/store';
import * as fromRoot from '../../reducers';
import { IDictionary } from 'app/interfaces/shared';
import { first } from 'rxjs/operators';

type NotifyOptions = Partial<ToastrConfig & { data: any }>;
type NotifyType = 'success' | 'error' | 'warning' | 'info';
Expand All @@ -26,7 +27,9 @@ export class NotifyService {
this.exec('error', message, title, opts);
}
warning(message: string, title = 'Altair', opts: NotifyOptions = {}) {
this.store.select(state => state.settings['alert.disableWarnings']).toPromise().then(disableWarnings => {
this.store.select(state => state.settings['alert.disableWarnings']).pipe(
first(),
).subscribe(disableWarnings => {
if (!disableWarnings) {
return this.exec('warning', message, title, opts);
}
Expand Down

0 comments on commit 01f8a22

Please sign in to comment.