-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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: LEAP-1492: More flexible Custom buttons #6454
base: develop
Are you sure you want to change the base?
Conversation
- extend the structure of custom buttons definition to allow different modes - custom buttons now can replace just some buttons, leaving the rest untouched - start to simplify work with all buttons to use standard button description + additional wrappers for main actions, so any button action will go through mandatory checks
✅ Deploy Preview for heartex-docs canceled.
|
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
function toArray<T>(arg: undefined | T | (T | undefined)[]): T[] { | ||
return (Array.isArray(arg) ? arg : [arg]).filter(v => v !== undefined); | ||
} |
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.
It could be moved to utils
await onClick?.(button.name); | ||
setWaiting(false); | ||
}, []); | ||
// @todo do we need waiting? all buttons should utilize isSubmitting |
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.
It's for indication, but it may look not good.
|
||
// either we render _before buttons and then the rest, or we render only _replace buttons | ||
if (firstToRender) { | ||
const allButtons = Array.isArray(firstToRender) ? firstToRender : [firstToRender]; |
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.
const allButtons = Array.isArray(firstToRender) ? firstToRender : [firstToRender]; | |
const allButtons = toArray(firstToRender); |
@@ -29,7 +29,8 @@ type MSTCommentStore = { | |||
}; | |||
|
|||
type MSTStore = { | |||
customButtons: Instance<typeof CustomButton>[]; | |||
// @todo we can't import CustomButton store here and use it type :( | |||
customButtons: any; |
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.
I've just figured out that it works for me 🤯
customButtons: any; | |
customButtons: CustomControlProps.button[]; |
Examples of new structure:
PR fulfills these requirements
Change has impacts in these area(s)
Describe the reason for change
We need to dynamically display buttons we need, so previous predefined approach didn't work.
Does this change affect performance?
no
Does this change affect security?
no
What alternative approaches were there?
(briefly list any if applicable)
Does this PR introduce a breaking change?
What level of testing was included in the change?