Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI fixes for loading state, empty tree, added toast for error, fixed no indicies error #176

Merged
merged 10 commits into from
Oct 25, 2023
3 changes: 3 additions & 0 deletions common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ export const POLL_INTERVAL_MS = 2000;
export const ASYNC_QUERY_ENDPOINT = '/api/spark_sql_console';
export const ASYNC_QUERY_JOB_ENDPOINT = ASYNC_QUERY_ENDPOINT + '/job/';
export const ASYNC_QUERY_SESSION_ID = 'async-query-session-id';

export const SAMPLE_PPL_QUERY = 'source = <datasource>.<database>.<table> | head 10';
export const SAMPLE_SQL_QUERY = 'select * from <datasource>.<database>.<table> limit 10';
37 changes: 37 additions & 0 deletions common/toast/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { ToastInputFields } from '../../../../src/core/public';
import { coreRefs } from '../../public/framework/core_refs';

type Color = 'success' | 'primary' | 'warning' | 'danger' | undefined;

export const useToast = () => {
const toasts = coreRefs.toasts!;

const setToast = (title: string, color: Color = 'success', text?: string) => {
const newToast: ToastInputFields = {
id: new Date().toISOString(),
title,
text,
};
switch (color) {
case 'danger': {
toasts.addDanger(newToast);
break;
}
case 'warning': {
toasts.addWarning(newToast);
break;
}
default: {
toasts.addSuccess(newToast);
break;
}
}
};

return { setToast };
};
5 changes: 3 additions & 2 deletions common/utils/async_query_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ export const pollQueryStatus = (id: string, http: CoreStart['http'], callback) =
callback({ status: status });
setTimeout(() => pollQueryStatus(id, http, callback), POLL_INTERVAL_MS);
} else if (status === 'failed') {
callback({ status: 'FAILED', results: [] });
const results = res.data.resp;
callback({ status: 'FAILED', error: results.error });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we tested the acceleration flyout with the function change here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not able to test anything, right now

} else if (status === 'success') {
const results = _.get(res.data.resp, 'datarows');
callback({ status: 'SUCCESS', results: results });
}
})
.catch((err) => {
console.error(err);
callback([]);
callback({ status: 'FAILED', error: 'Failed to fetch data' });
});
};
Loading
Loading