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

feat: update create workspace page UI and implement unit tests #226

Merged
merged 37 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0cd5dd7
ui update: workspace create page
yuye-aws Oct 8, 2023
536cd95
implement cancel button and wrap string with i18n
yuye-aws Oct 9, 2023
58e6e66
eslint fix
yuye-aws Oct 9, 2023
a2bece0
breadcrumb bug fix
yuye-aws Oct 9, 2023
0ddba6a
workspace create unit tests
yuye-aws Oct 12, 2023
019183e
bug fix
yuye-aws Oct 12, 2023
0e6dbb1
update bread crumbs for workspace create page
yuye-aws Oct 12, 2023
e8a6866
udpate test case
yuye-aws Oct 12, 2023
b455fab
optimize create page ui
yuye-aws Oct 13, 2023
819df61
update test file
yuye-aws Oct 13, 2023
61c0a27
change library category definition
yuye-aws Oct 13, 2023
6dfa790
remove key definition
yuye-aws Oct 13, 2023
8c81cae
change default permission type to Read
yuye-aws Oct 13, 2023
f268305
refactor bottom bar and cancel modal into components
yuye-aws Oct 13, 2023
e509ee2
declare consts outside functional components
yuye-aws Oct 13, 2023
1e2abca
remove key definition
yuye-aws Oct 16, 2023
91e14fc
refactor bottom bar and cancel model
yuye-aws Oct 16, 2023
384f421
Update src/plugins/workspace/public/components/workspace_updater/work…
yuye-aws Oct 13, 2023
9ed01e9
Update src/plugins/workspace/public/components/workspace_creator/work…
yuye-aws Oct 13, 2023
c771dd4
Update src/plugins/workspace/public/components/workspace_creator/work…
yuye-aws Oct 13, 2023
7090e96
wrap string with i18n
yuye-aws Oct 16, 2023
d457700
reimplement tab selection to enum
yuye-aws Oct 16, 2023
59aa149
fix data-test-subj duplicate bug
yuye-aws Oct 16, 2023
c471278
update tests and id
yuye-aws Oct 16, 2023
0067a4c
update UI
yuye-aws Oct 16, 2023
deeddad
track the number of errors
yuye-aws Oct 16, 2023
3b1fe21
add test cases
yuye-aws Oct 16, 2023
086ee4d
resolve conflicts
yuye-aws Oct 16, 2023
61f40f6
hide permission section when workspace permission is not enabled
yuye-aws Oct 17, 2023
ca6c263
sort permissions decreasingly
yuye-aws Oct 17, 2023
9b04975
update test file
yuye-aws Oct 17, 2023
2fb0001
feat: remove some error and optimize mock
SuZhou-Joe Oct 17, 2023
59d37f1
feat: update
SuZhou-Joe Oct 17, 2023
ea35faf
update test file
yuye-aws Oct 17, 2023
2a6dba3
refactor with EuiTab
yuye-aws Oct 17, 2023
e96ddb0
remove sort logic
yuye-aws Oct 17, 2023
8b22c35
remove unused import
yuye-aws Oct 17, 2023
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
12 changes: 0 additions & 12 deletions src/plugins/workspace/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import { AppCategory } from '../../../core/types';

export const WORKSPACE_CREATE_APP_ID = 'workspace_create';
export const WORKSPACE_LIST_APP_ID = 'workspace_list';
export const WORKSPACE_UPDATE_APP_ID = 'workspace_update';
Expand All @@ -22,12 +19,3 @@ export const PATHS = {
export const WORKSPACE_OP_TYPE_CREATE = 'create';
export const WORKSPACE_OP_TYPE_UPDATE = 'update';
export const WORKSPACE_SAVED_OBJECTS_CLIENT_WRAPPER_ID = 'workspace';

export const WORKSPACE_NAV_CATEGORY: AppCategory = {
id: 'workspace',
label: i18n.translate('core.ui.workspaceNavList.label', {
defaultMessage: 'Workspaces',
}),
euiIconType: 'folderClosed',
order: 2000,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
EuiBottomBar,
EuiButton,
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import React, { useState } from 'react';
import { ApplicationStart } from 'opensearch-dashboards/public';
import { WORKSPACE_OP_TYPE_CREATE, WORKSPACE_OP_TYPE_UPDATE } from '../../../common/constants';
import { WorkspaceCancelModal } from './workspace_cancel_modal';

interface WorkspaceBottomBarProps {
formId: string;
opType?: string;
numberOfErrors: number;
application: ApplicationStart;
}

// Number of saved changes will be implemented in workspace update page PR
export const WorkspaceBottomBar = ({
formId,
opType,
numberOfErrors,
application,
}: WorkspaceBottomBarProps) => {
const [isCancelModalVisible, setIsCancelModalVisible] = useState(false);
const closeCancelModal = () => setIsCancelModalVisible(false);
const showCancelModal = () => setIsCancelModalVisible(true);

return (
<div>
<EuiSpacer size="xl" />
<EuiSpacer size="xl" />
<EuiBottomBar>
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="s">
{opType === WORKSPACE_OP_TYPE_UPDATE ? (
<EuiText textAlign="left">
{i18n.translate('workspace.form.bottomBar.unsavedChanges', {
defaultMessage: '1 Unsaved change(s)',
})}
</EuiText>
) : (
<EuiText textAlign="left">
{i18n.translate('workspace.form.bottomBar.errors', {
defaultMessage: `${numberOfErrors} Error(s)`,
})}
</EuiText>
)}
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFlexGroup gutterSize="m">
<EuiButtonEmpty
color="ghost"
onClick={showCancelModal}
data-test-subj="workspaceForm-bottomBar-cancelButton"
>
{i18n.translate('workspace.form.bottomBar.cancel', {
defaultMessage: 'Cancel',
})}
</EuiButtonEmpty>
<EuiSpacer />
{opType === WORKSPACE_OP_TYPE_CREATE && (
<EuiButton
fill
type="submit"
color="primary"
form={formId}
data-test-subj="workspaceForm-bottomBar-createButton"
>
{i18n.translate('workspace.form.bottomBar.createWorkspace', {
defaultMessage: 'Create workspace',
})}
</EuiButton>
)}
{opType === WORKSPACE_OP_TYPE_UPDATE && (
<EuiButton form={formId} type="submit" fill color="primary">
{i18n.translate('workspace.form.bottomBar.saveChanges', {
defaultMessage: 'Save changes',
})}
</EuiButton>
)}
</EuiFlexGroup>
</EuiFlexItem>
</EuiFlexGroup>
</EuiBottomBar>
<WorkspaceCancelModal
application={application}
visible={isCancelModalVisible}
closeCancelModal={closeCancelModal}
/>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { i18n } from '@osd/i18n';
import { EuiConfirmModal } from '@elastic/eui';
import { ApplicationStart } from 'opensearch-dashboards/public';
import { WORKSPACE_LIST_APP_ID } from '../../../common/constants';

interface WorkspaceCancelModalProps {
visible: boolean;
application: ApplicationStart;
closeCancelModal: () => void;
}

export const WorkspaceCancelModal = ({
application,
visible,
closeCancelModal,
}: WorkspaceCancelModalProps) => {
if (!visible) {
return null;
}

return (
<EuiConfirmModal
data-test-subj="workspaceForm-cancelModal"
title={i18n.translate('workspace.form.cancelModal.title', {
defaultMessage: 'Discard changes?',
})}
onCancel={closeCancelModal}
onConfirm={() => application?.navigateToApp(WORKSPACE_LIST_APP_ID)}
cancelButtonText={i18n.translate('workspace.form.cancelButtonText.', {
defaultMessage: 'Continue editing',
})}
confirmButtonText={i18n.translate('workspace.form.confirmButtonText.', {
defaultMessage: 'Discard changes',
})}
buttonColor="danger"
defaultFocusedButton="confirm"
>
{i18n.translate('workspace.form.cancelModal.body', {
defaultMessage: 'This will discard all changes. Are you sure?',
})}
</EuiConfirmModal>
);
};
Loading
Loading