-
Notifications
You must be signed in to change notification settings - Fork 229
fix: update collection drawer styles COMPASS-9477 #7144
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
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0bc848a
fix: update collection drawer styles COMPASS-9477
paula-stacho b07a6f2
polish and tests
paula-stacho d37e148
.
paula-stacho 4d1f2c4
pr feedback
paula-stacho 920fee4
improve styles
paula-stacho 9abebfd
darkmode
paula-stacho 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
88 changes: 0 additions & 88 deletions
88
packages/compass-data-modeling/src/components/collection-drawer-content.tsx
This file was deleted.
Oops, something went wrong.
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
174 changes: 174 additions & 0 deletions
174
packages/compass-data-modeling/src/components/drawer/collection-drawer-content.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,174 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import type { Relationship } from '../../services/data-model-storage'; | ||
import { | ||
Badge, | ||
Button, | ||
IconButton, | ||
css, | ||
FormFieldContainer, | ||
palette, | ||
spacing, | ||
TextInput, | ||
Icon, | ||
} from '@mongodb-js/compass-components'; | ||
import { | ||
createNewRelationship, | ||
deleteRelationship, | ||
getCurrentDiagramFromState, | ||
selectCurrentModel, | ||
selectRelationship, | ||
} from '../../store/diagram'; | ||
import type { DataModelingState } from '../../store/reducer'; | ||
import { getRelationshipName } from '../../utils'; | ||
import DMDrawerSection from './dm-drawer-section'; | ||
|
||
type CollectionDrawerContentProps = { | ||
namespace: string; | ||
relationships: Relationship[]; | ||
onCreateNewRelationshipClick: (namespace: string) => void; | ||
onEditRelationshipClick: (rId: string) => void; | ||
onDeleteRelationshipClick: (rId: string) => void; | ||
}; | ||
|
||
const formFieldContainerStyles = css({ | ||
marginBottom: spacing[400], | ||
marginTop: spacing[400], | ||
}); | ||
|
||
const titleBtnStyles = css({ | ||
marginLeft: 'auto', | ||
}); | ||
|
||
const emptyRelationshipMessageStyles = css({ | ||
color: palette.gray.dark1, | ||
}); | ||
|
||
const relationshipsListStyles = css({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: spacing[200], | ||
}); | ||
|
||
const relationshipItemStyles = css({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
}); | ||
|
||
const relationshipNameStyles = css({ | ||
flexGrow: 1, | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
whiteSpace: 'nowrap', | ||
minWidth: 0, | ||
paddingRight: spacing[200], | ||
}); | ||
|
||
const relationshipContentStyles = css({ | ||
marginTop: spacing[400], | ||
}); | ||
|
||
const CollectionDrawerContent: React.FunctionComponent< | ||
CollectionDrawerContentProps | ||
> = ({ | ||
namespace, | ||
relationships, | ||
onCreateNewRelationshipClick, | ||
onEditRelationshipClick, | ||
onDeleteRelationshipClick, | ||
}) => { | ||
return ( | ||
<> | ||
<DMDrawerSection label="COLLECTION"> | ||
<FormFieldContainer className={formFieldContainerStyles}> | ||
<TextInput | ||
label="Name" | ||
sizeVariant="small" | ||
value={namespace} | ||
disabled={true} | ||
/> | ||
</FormFieldContainer> | ||
</DMDrawerSection> | ||
|
||
<DMDrawerSection | ||
label={ | ||
<> | ||
RELATIONSHIPS | ||
<Badge>{relationships.length}</Badge> | ||
<Button | ||
className={titleBtnStyles} | ||
size="xsmall" | ||
onClick={() => { | ||
onCreateNewRelationshipClick(namespace); | ||
}} | ||
> | ||
Add relationship | ||
</Button> | ||
</> | ||
} | ||
> | ||
<div className={relationshipContentStyles}> | ||
{!relationships.length ? ( | ||
<div className={emptyRelationshipMessageStyles}> | ||
This collection does not have any relationships yet. | ||
</div> | ||
) : ( | ||
<ul className={relationshipsListStyles}> | ||
{relationships.map((r) => { | ||
return ( | ||
<li | ||
key={r.id} | ||
data-relationship-id={r.id} | ||
className={relationshipItemStyles} | ||
> | ||
<span className={relationshipNameStyles}> | ||
{getRelationshipName(r)} | ||
</span> | ||
<IconButton | ||
aria-label="Edit relationship" | ||
title="Edit relationship" | ||
onClick={() => { | ||
onEditRelationshipClick(r.id); | ||
}} | ||
> | ||
<Icon glyph="Edit" /> | ||
</IconButton> | ||
<IconButton | ||
aria-label="Delete relationship" | ||
title="Delete relationship" | ||
onClick={() => { | ||
onDeleteRelationshipClick(r.id); | ||
}} | ||
> | ||
<Icon glyph="Trash" /> | ||
</IconButton> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
)} | ||
</div> | ||
</DMDrawerSection> | ||
</> | ||
); | ||
}; | ||
|
||
export default connect( | ||
(state: DataModelingState, ownProps: { namespace: string }) => { | ||
return { | ||
relationships: selectCurrentModel( | ||
getCurrentDiagramFromState(state).edits | ||
).relationships.filter((r) => { | ||
const [local, foreign] = r.relationship; | ||
return ( | ||
local.ns === ownProps.namespace || foreign.ns === ownProps.namespace | ||
); | ||
}), | ||
}; | ||
}, | ||
{ | ||
onCreateNewRelationshipClick: createNewRelationship, | ||
onEditRelationshipClick: selectRelationship, | ||
onDeleteRelationshipClick: deleteRelationship, | ||
} | ||
)(CollectionDrawerContent); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.