-
Notifications
You must be signed in to change notification settings - Fork 177
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
fix(compass-crud): show "expand all / collapse all" button on readonly documents COMPASS-4635 #6265
base: main
Are you sure you want to change the base?
Conversation
@@ -44,6 +44,13 @@ const actionsGroupSignalPopover = css({ | |||
display: 'block !important', | |||
}); | |||
|
|||
const expandButton = css({ | |||
'& > div:has(svg)': { |
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.
/** | ||
* Subscribe to the update store on mount. | ||
*/ | ||
componentDidMount() { | ||
this.subscribeToDocumentEvents(this.props.doc); | ||
} | ||
|
||
/** | ||
* Refreshing the list updates the doc in the props so we should update the | ||
* document on the instance. | ||
*/ | ||
componentDidUpdate(prevProps: ReadonlyDocumentProps) { | ||
if (prevProps.doc !== this.props.doc) { | ||
this.unsubscribeFromDocumentEvents(prevProps.doc); | ||
this.subscribeToDocumentEvents(this.props.doc); | ||
} | ||
} | ||
|
||
/** | ||
* Unsubscribe from the update store on unmount. | ||
*/ | ||
componentWillUnmount() { | ||
this.unsubscribeFromDocumentEvents(this.props.doc); | ||
} | ||
|
||
/** | ||
* Subscribe to the document events. | ||
*/ | ||
subscribeToDocumentEvents(doc: Document) { | ||
doc.on(DocumentEvents.Expanded, this.handleExpanded); | ||
doc.on(DocumentEvents.Collapsed, this.handleCollapsed); | ||
} | ||
|
||
/** | ||
* Unsubscribe from the document events. | ||
*/ | ||
unsubscribeFromDocumentEvents(doc: Document) { | ||
doc.on(DocumentEvents.Expanded, this.handleExpanded); | ||
doc.on(DocumentEvents.Collapsed, this.handleCollapsed); | ||
} | ||
|
||
handleExpanded = () => { | ||
this.setState({ expanded: true }); | ||
}; | ||
|
||
handleCollapsed = () => { | ||
this.setState({ expanded: false }); | ||
}; |
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.
This is mostly copied from the EditableDocument
to react to relevant events on the doc
.
@@ -94,7 +178,6 @@ class ReadonlyDocument extends React.Component<ReadonlyDocumentProps> { | |||
static propTypes = { | |||
copyToClipboard: PropTypes.func, | |||
doc: PropTypes.object.isRequired, | |||
expandAll: PropTypes.bool, |
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.
This was extraenuous. Most likely a leftover from some prop that got removed.
@@ -399,13 +399,15 @@ export const HadronElement: React.FunctionComponent<{ | |||
value: HadronElementType; | |||
editable: boolean; | |||
editingEnabled: boolean; | |||
extraPaddingLeft?: number; |
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.
The Element
in the Document
now takes some extraPaddingLeft
.
Description
To follow the design specification outlined in EXPO-2098.
Checklist
ReadonlyDocument
(as per design bullet 4).Expand / collapse in the "read only" mode
Screen.Recording.2024-09-19.at.22.54.37.mov
Motivation and Context
Open Questions
Dependents
Types of changes