This repository was archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathAction.js
More file actions
68 lines (61 loc) · 1.93 KB
/
Action.js
File metadata and controls
68 lines (61 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { types } from "mobx-state-tree";
import { FF_LOPS_E_3, isFF } from "../utils/feature-flags";
import { CustomCalback, HtmlOrReact, StringOrNumberID } from "./types";
const SelectOptions = types.model("SelectOptions", {
label: types.string,
value: types.string,
});
const ActionFormField = types.model("ActionForm", {
label: types.maybeNull(types.string),
name: types.string,
value: types.maybeNull(types.union(
types.string,
types.array(types.string),
)),
options: types.maybeNull(types.union(
types.array(types.string),
types.array(SelectOptions),
)),
type: types.enumeration([
"input",
"number",
"checkbox",
"radio",
"toggle",
"select",
"range",
]),
});
const ActionFormCoulmn = types.model('ActionFormCoulmn', {
width: types.maybeNull(types.number),
fields: types.array(ActionFormField),
});
const ActionFormRow = types.model('ActionFormRow', {
columnCount: 1,
columns: types.maybeNull(types.array(ActionFormCoulmn)),
fields: types.array(ActionFormField),
});
const ActionDialog = types.model("ActionDialog", {
title: types.maybeNull(types.string),
text: types.string,
type: types.enumeration(["confirm", "prompt"]),
form: types.maybeNull(types.array(ActionFormRow)),
});
const isFFLOPSE3 = isFF(FF_LOPS_E_3);
export const Action = types.model("Action", {
id: StringOrNumberID,
dialog: types.maybeNull(ActionDialog),
order: types.integer,
title: isFFLOPSE3 ? types.union(types.string , HtmlOrReact) : types.string,
...(isFFLOPSE3 ? {
children: types.optional(types.array(types.late(() => Action)), []),
callback: types.maybeNull(CustomCalback),
isSeparator: types.optional(types.boolean, false),
isTitle: types.optional(types.boolean, false),
newStyle: types.optional(types.boolean, false),
disabled: types.optional(types.boolean, false),
disabledReason: types.optional(types.string, ""),
} : {}),
}).volatile(() => ({
caller: null,
}));