forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add workspace create and overview page
Signed-off-by: Lin Wang <wonglam@amazon.com>
- Loading branch information
Showing
24 changed files
with
2,436 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export type WorkspacePermissionItem<T extends string> = { | ||
modes: T[]; | ||
} & ({ type: 'user'; userId: string } | { type: 'group'; group: string }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/plugins/workspace/public/components/workspace_creator/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { WorkspaceCreator } from './workspace_creator'; | ||
export { WorkspacePermissionSetting } from './workspace_permission_setting_panel'; |
105 changes: 105 additions & 0 deletions
105
src/plugins/workspace/public/components/workspace_creator/workspace_bottom_bar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
49 changes: 49 additions & 0 deletions
49
src/plugins/workspace/public/components/workspace_creator/workspace_cancel_modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
Oops, something went wrong.