Skip to content

Commit

Permalink
UI fixes for loading state, empty tree, added toast for error, fixed …
Browse files Browse the repository at this point in the history
…no indicies error (opensearch-project#176)

* sample query button

Signed-off-by: Paul Sebastian <[email protected]>

* added toasts for failure cases

Signed-off-by: Paul Sebastian <[email protected]>

* added changes for error loading message, fixed initial loading screen, added badge for no indicies

Signed-off-by: sumukhswamy <[email protected]>

* ui changes to curb sidebar

Signed-off-by: Paul Sebastian <[email protected]>

* added fix for error from async query

Signed-off-by: sumukhswamy <[email protected]>

* updated snapshots

Signed-off-by: Paul Sebastian <[email protected]>

* added changes for for mocking toasts, changed table test

Signed-off-by: sumukhswamy <[email protected]>

* pr requested changes

Signed-off-by: Paul Sebastian <[email protected]>

* fix main.tsx tests

Signed-off-by: Shenoy Pratik <[email protected]>

---------

Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: sumukhswamy <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Co-authored-by: Paul Sebastian <[email protected]>
Co-authored-by: Shenoy Pratik <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2023
1 parent a5aa2d2 commit 015cab8
Show file tree
Hide file tree
Showing 18 changed files with 10,165 additions and 5,505 deletions.
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 });
} 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

0 comments on commit 015cab8

Please sign in to comment.