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

[Bug][Workspace]Fix page display errors and add loading status #8086

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/8086.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- [Workspace]Fix page display errors and add loading status ([#8086](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8086))
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const defaultProps = {
numberOfChanges: 2,
numberOfErrors: 1,
handleResetForm: mockHandleResetForm,
isFormSubmitting: false,
};

describe('WorkspaceBottomBar', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ interface WorkspaceBottomBarProps {
numberOfChanges: number;
numberOfErrors: number;
handleResetForm: () => void;
isFormSubmitting: boolean;
}

export const WorkspaceBottomBar = ({
formId,
numberOfChanges,
numberOfErrors,
handleResetForm,
isFormSubmitting,
}: WorkspaceBottomBarProps) => {
const applicationElement = document.querySelector('.app-wrapper');
const bottomBar = (
Expand Down Expand Up @@ -82,6 +84,7 @@ export const WorkspaceBottomBar = ({
fill
color="primary"
data-test-subj="workspaceForm-bottomBar-updateButton"
isLoading={isFormSubmitting}
>
{i18n.translate('workspace.form.bottomBar.saveChanges', {
defaultMessage: 'Save changes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {

export interface WorkspaceDetailProps {
registeredUseCases$: BehaviorSubject<WorkspaceUseCase[]>;
isFormSubmitting: boolean;
}

export const WorkspaceDetail = (props: WorkspaceDetailProps) => {
Expand Down Expand Up @@ -292,6 +293,7 @@ export const WorkspaceDetail = (props: WorkspaceDetailProps) => {
numberOfChanges={numberOfChanges}
numberOfErrors={numberOfErrors}
handleResetForm={handleResetForm}
isFormSubmitting={props.isFormSubmitting}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const WorkspaceDetailApp = (props: WorkspaceDetailProps) => {
const currentWorkspace = useObservable(workspaces ? workspaces.currentWorkspace$ : of(null));
const availableUseCases = useObservable(props.registeredUseCases$, []);
const isPermissionEnabled = application?.capabilities.workspaces.permissionEnabled;
const [isFormSubmitting, setIsFormSubmitting] = useState(false);

/**
* set breadcrumbs to chrome
Expand Down Expand Up @@ -105,6 +106,10 @@ export const WorkspaceDetailApp = (props: WorkspaceDetailProps) => {
const handleWorkspaceFormSubmit = useCallback(
async (data: WorkspaceFormSubmitData) => {
let result;
if (isFormSubmitting) {
return;
}
setIsFormSubmitting(true);
yubonluo marked this conversation as resolved.
Show resolved Hide resolved
if (!currentWorkspace) {
notifications?.toasts.addDanger({
title: i18n.translate('Cannot find current workspace', {
Expand Down Expand Up @@ -158,9 +163,11 @@ export const WorkspaceDetailApp = (props: WorkspaceDetailProps) => {
text: error instanceof Error ? error.message : JSON.stringify(error),
});
return;
} finally {
setIsFormSubmitting(false);
}
},
[notifications?.toasts, currentWorkspace, http, application, workspaceClient]
[isFormSubmitting, currentWorkspace, notifications?.toasts, workspaceClient, application, http]
);

if (!workspaces || !application || !http || !savedObjects || !currentWorkspaceFormData) {
Expand All @@ -178,7 +185,7 @@ export const WorkspaceDetailApp = (props: WorkspaceDetailProps) => {
availableUseCases={availableUseCases}
>
<I18nProvider>
<WorkspaceDetail {...props} />
<WorkspaceDetail {...props} isFormSubmitting={isFormSubmitting} />
</I18nProvider>
</WorkspaceFormProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export const DataSourceConnectionTable = ({
itemIdToExpandedRowMap={itemIdToExpandedRowMap}
isExpandable={true}
selection={selection}
className="workspace-detail-direct-query-table"
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export const WorkspacePermissionSettingPanel = ({
{isEditing && (
<EuiSmallButton
fullWidth={false}
style={{ maxWidth: 160 }}
yubonluo marked this conversation as resolved.
Show resolved Hide resolved
onClick={handleAddNewOne}
data-test-subj={`workspaceForm-permissionSettingPanel-addNew`}
color="primary"
Expand Down
Loading