Skip to content
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-1454: Custom action buttons in LSF #6411

Merged
merged 11 commits into from
Sep 26, 2024

Conversation

hlomzik
Copy link
Collaborator

@hlomzik hlomzik commented Sep 19, 2024

Introducing custom action buttons for LSF to allow additional actions, controlled from outside of editor. Provided buttons will completely replace the internal ones, but there is a way to reuse buttons you need, just add the button with internal name and no extra params.

TODO: Add example

Custom buttons need to behave similarly to internal ones, so we are using flags and additional checks. They will call the same event handleCustomButton(button_name) so external app will handle customButton event with store, button_name, options params.

Also new types for global MST stores are introduced in a draft state with intention to expand them with more props and methods so they can be used in other TypeScript code, which currently uses any for any MST stuff.

PR fulfills these requirements

  • Tests for the changes have been added/updated (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • Best efforts were made to ensure docs/code are concise and coherent (checked for spelling/grammatical errors, commented out code, debug logs etc.)
  • Self-reviewed and ran all changes on a local instance (for bug fixes/features)

Change has impacts in these area(s)

  • Product design
  • Backend (Database)
  • Backend (API)
  • Frontend

Describe the reason for change

We need to introduce new buttons in LSE and instead of creating another "hidden" buttons in LSF we create a way to use any button you need.

What alternative approaches were there?

Hardcode new buttons in LSF and display them by one more interface.

What feature flags were used to cover this change?

None. That's addition and will be used only if specific props are passed in.

Does this PR introduce a breaking change?

  • Yes, and covered entirely by feature flag(s)
  • Yes, and covered partially by feature flag(s)
  • No
  • Not sure (briefly explain the situation below)

What level of testing was included in the change?

  • e2e
  • integration
  • unit

Simple declarative store to describe custom buttons.
Plus universal handler to handle any button depending on its type.
Main stores are covered with some popular props and methods:
AppStore, AnnotationStore, Annotation
They will fully substitute all other buttons for now.
Later we'll add some other buttons specified in custom buttons config.
@github-actions github-actions bot added the feat label Sep 19, 2024
Copy link

netlify bot commented Sep 19, 2024

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit 9498397
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/66f30c60d96cd40008b03bed

Copy link

netlify bot commented Sep 19, 2024

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit 9498397
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/66f30c60a5ec0c000896f751

This allows to mix custom buttons with internal ones.
- look for Submit is primary as a fallback value, because it has no secondary
- Button now have a `mod` property from Block, should be infered, but that's for later
- Dropdown pointing to a correct component with additional property
- the rest are just added types or direct type casts
@hlomzik hlomzik changed the title feat: LEAP-1454: Flexible reject buttons feat: LEAP-1454: Custom action buttons in LSF Sep 20, 2024
`buttons.tsx` to store most of the buttons, so logic will be more readable in `Controls.tsx`.
Buttons which can require a comment use handler wrapper.
`disabled` is added to custom buttons as well to block them during action handling as all other buttons.
@hlomzik
Copy link
Collaborator Author

hlomzik commented Sep 24, 2024

/git merge

Workflow run
Successfully merged: create mode 100644 label_studio/ml_models/migrations/0012_alter_thirdpartymodelversion_provider.py

@hlomzik hlomzik merged commit 52014d2 into develop Sep 26, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants