-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: LEAP-1492: More flexible Custom buttons (#6454)
- 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 Examples of new structure: ```js // switch buttons { "_replace": ["update", "submit"] } // add simple custom button { "_before": [{ "name": "analyze", "title": "Analyze task" }] } // split Reject into 2 buttons, leaving normal Accept button; // these 2 new buttons share part of reject logic { "reject": [ { "name": "hide", "title": "Hide" }, { "name": "postpone", "title": "Postpone" }, ] } ``` Co-authored-by: hlomzik <hlomzik@users.noreply.github.com> Co-authored-by: Sergey <sergey.koshevarov@humansignal.com>
- Loading branch information
1 parent
0689e4f
commit 65f69dd
Showing
9 changed files
with
165 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
|
@@ -25,6 +25,7 @@ const mockStore = { | |
}, | ||
}, | ||
}, | ||
customButtons: new Map(), | ||
}; | ||
|
||
const mockHistory = { | ||
|
This file contains 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 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 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 |
---|---|---|
@@ -1,25 +1,19 @@ | ||
import { applySnapshot, getSnapshot, types } from "mobx-state-tree"; | ||
import { types } from "mobx-state-tree"; | ||
import { guidGenerator } from "../utils/unique"; | ||
|
||
/** | ||
* Custom buttons that can be injected from outside application. | ||
* The only required property is `name`. If the `name` is one of the predefined buttons, it will be rendered as such. | ||
* @see CustomControl in BottomBar/Controls | ||
*/ | ||
export const CustomButton = types | ||
.model("CustomButton", { | ||
id: types.optional(types.identifier, guidGenerator), | ||
name: types.string, | ||
title: types.maybe(types.string), | ||
look: types.maybe( | ||
types.enumeration(["primary", "danger", "destructive", "alt", "outlined", "active", "disabled"] as const), | ||
), | ||
tooltip: types.maybe(types.string), | ||
ariaLabel: types.maybe(types.string), | ||
disabled: types.maybe(types.boolean), | ||
}) | ||
.actions((self) => ({ | ||
updateProps(newProps: Partial<typeof self>) { | ||
applySnapshot(self, Object.assign({}, getSnapshot(self), newProps)); | ||
}, | ||
})); | ||
export const CustomButton = types.model("CustomButton", { | ||
id: types.optional(types.identifier, guidGenerator), | ||
name: types.string, | ||
title: types.string, | ||
look: types.maybe( | ||
types.enumeration(["primary", "danger", "destructive", "alt", "outlined", "active", "disabled"] as const), | ||
), | ||
tooltip: types.maybe(types.string), | ||
ariaLabel: types.maybe(types.string), | ||
disabled: types.maybe(types.boolean), | ||
}); |
This file contains 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 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
Oops, something went wrong.