-
Notifications
You must be signed in to change notification settings - Fork 247
feat(data-modeling): add side panel COMPASS-9476 #7111
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
64 changes: 64 additions & 0 deletions
64
packages/compass-data-modeling/src/components/diagram-editor-side-panel.tsx
This file contains hidden or 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,64 @@ | ||
| import React from 'react'; | ||
| import { connect } from 'react-redux'; | ||
| import type { DataModelingState } from '../store/reducer'; | ||
| import { closeSidePanel } from '../store/side-panel'; | ||
| import { | ||
| Button, | ||
| css, | ||
| cx, | ||
| Body, | ||
| spacing, | ||
| palette, | ||
| useDarkMode, | ||
| } from '@mongodb-js/compass-components'; | ||
|
|
||
| const containerStyles = css({ | ||
| width: '400px', | ||
| height: '100%', | ||
|
|
||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| gap: spacing[400], | ||
| borderLeft: `1px solid ${palette.gray.light2}`, | ||
| }); | ||
|
|
||
| const darkModeContainerStyles = css({ | ||
| borderLeftColor: palette.gray.dark2, | ||
| }); | ||
|
|
||
| type DiagramEditorSidePanelProps = { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| }; | ||
|
|
||
| function DiagmramEditorSidePanel({ | ||
| isOpen, | ||
| onClose, | ||
| }: DiagramEditorSidePanelProps) { | ||
| const isDarkMode = useDarkMode(); | ||
| if (!isOpen) { | ||
| return null; | ||
| } | ||
| return ( | ||
| <div className={cx(containerStyles, isDarkMode && darkModeContainerStyles)}> | ||
| <Body>This feature is under development.</Body> | ||
| <Button onClick={onClose} variant="primary" size="small"> | ||
| Close Side Panel | ||
| </Button> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default connect( | ||
| (state: DataModelingState) => { | ||
| const { sidePanel } = state; | ||
| return { | ||
| isOpen: sidePanel.isOpen, | ||
| }; | ||
| }, | ||
| { | ||
| onClose: closeSidePanel, | ||
| } | ||
| )(DiagmramEditorSidePanel); | ||
This file contains hidden or 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 | ||
|---|---|---|---|---|
|
|
@@ -38,6 +38,7 @@ import type { StaticModel } from '../services/data-model-storage'; | |||
| import DiagramEditorToolbar from './diagram-editor-toolbar'; | ||||
| import ExportDiagramModal from './export-diagram-modal'; | ||||
| import { useLogger } from '@mongodb-js/compass-logging/provider'; | ||||
| import { openSidePanel } from '../store/side-panel'; | ||||
|
|
||||
| const loadingContainerStyles = css({ | ||||
| width: '100%', | ||||
|
|
@@ -188,6 +189,7 @@ const DiagramEditor: React.FunctionComponent<{ | |||
| onCancelClick: () => void; | ||||
| onApplyInitialLayout: (positions: Record<string, [number, number]>) => void; | ||||
| onMoveCollection: (ns: string, newPosition: [number, number]) => void; | ||||
| onOpenSidePanel: () => void; | ||||
| }> = ({ | ||||
| diagramLabel, | ||||
| step, | ||||
|
|
@@ -196,6 +198,7 @@ const DiagramEditor: React.FunctionComponent<{ | |||
| onCancelClick, | ||||
| onApplyInitialLayout, | ||||
| onMoveCollection, | ||||
| onOpenSidePanel, | ||||
| }) => { | ||||
| const { log, mongoLogId } = useLogger('COMPASS-DATA-MODELING-DIAGRAM-EDITOR'); | ||||
| const isDarkMode = useDarkMode(); | ||||
|
|
@@ -332,6 +335,10 @@ const DiagramEditor: React.FunctionComponent<{ | |||
| title={diagramLabel} | ||||
| edges={edges} | ||||
| nodes={areNodesReady ? nodes : []} | ||||
| onEdgeClick={() => { | ||||
| // TODO: we have to open a side panel with edge details | ||||
|
||||
| // TODO: we have to open a side panel with edge details |
This file contains hidden or 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 hidden or 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,52 @@ | ||
| import type { Reducer } from 'redux'; | ||
| import { isAction } from './util'; | ||
|
|
||
| export type SidePanelState = { | ||
| isOpen: boolean; | ||
| }; | ||
|
|
||
| export enum SidePanelActionTypes { | ||
| SIDE_PANEL_OPENED = 'data-modeling/side-panel/SIDE_PANEL_OPENED', | ||
| SIDE_PANEL_CLOSED = 'data-modeling/side-panel/SIDE_PANEL_CLOSED', | ||
| } | ||
|
|
||
| export type SidePanelOpenedAction = { | ||
| type: SidePanelActionTypes.SIDE_PANEL_OPENED; | ||
| }; | ||
|
|
||
| export type SidePanelClosedAction = { | ||
| type: SidePanelActionTypes.SIDE_PANEL_CLOSED; | ||
| }; | ||
|
|
||
| export type SidePanelActions = SidePanelOpenedAction | SidePanelClosedAction; | ||
|
|
||
| const INITIAL_STATE: SidePanelState = { | ||
| isOpen: false, | ||
| }; | ||
|
|
||
| export const sidePanelReducer: Reducer<SidePanelState> = ( | ||
| state = INITIAL_STATE, | ||
| action | ||
| ) => { | ||
| if (isAction(action, SidePanelActionTypes.SIDE_PANEL_OPENED)) { | ||
| return { | ||
| ...state, | ||
| isOpen: true, | ||
| }; | ||
| } | ||
| if (isAction(action, SidePanelActionTypes.SIDE_PANEL_CLOSED)) { | ||
| return { | ||
| ...state, | ||
| isOpen: false, | ||
| }; | ||
| } | ||
| return state; | ||
| }; | ||
|
|
||
| export const openSidePanel = (): SidePanelOpenedAction => ({ | ||
| type: SidePanelActionTypes.SIDE_PANEL_OPENED, | ||
| }); | ||
|
|
||
| export const closeSidePanel = (): SidePanelClosedAction => ({ | ||
| type: SidePanelActionTypes.SIDE_PANEL_CLOSED, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding appropriate ARIA attributes (e.g.,
role="dialog",aria-label) to the panel container so screen readers can properly announce this element.