Skip to content

Commit 75dfecf

Browse files
committed
Hid server buttons
1 parent 77050ce commit 75dfecf

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

src/component/Header.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ const Header = ({ superState, dispatcher }) => {
4747
<section className="toolbar">
4848
{
4949
actions.map(({
50-
text, active, action, icon, type, hotkey,
50+
text, active, visibility, action, icon, type, hotkey,
5151
}, i) => {
5252
const props = {
5353
text,
5454
active,
55+
visibility,
5556
tabIndex: i + 1,
5657
key: text,
5758
action: (e) => action(superState, dispatcher, e),

src/component/HeaderComps.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import Switch from 'rc-switch';
33
import { Menu, MenuItem, MenuButton } from '@szhsin/react-menu';
44

55
function DropDown({
6-
Icon, text, action, active, tabIndex, hotkey,
6+
Icon, text, action, active, visibility, tabIndex, hotkey,
77
}) {
88
return (
99
<Menu menuButton={(
1010
<MenuButton>
1111
<ActionButton {...{
12-
Icon, text, action, active, tabIndex, hotkey,
12+
Icon, text, action, active, visibility, tabIndex, hotkey,
1313
}}
1414
/>
1515
</MenuButton>
@@ -21,10 +21,10 @@ function DropDown({
2121
}
2222

2323
const FileUploader = ({
24-
Icon, text, active, tabIndex, hotkey, superState,
24+
Icon, text, active, visibility, tabIndex, hotkey, superState,
2525
}) => (
2626
<ActionButton {...{
27-
Icon, text, active, tabIndex, action: () => superState.fileRef.current.click(), hotkey,
27+
Icon, text, active, visibility, tabIndex, action: () => superState.fileRef.current.click(), hotkey,
2828
}}
2929
/>
3030
);
@@ -51,7 +51,7 @@ const Switcher = ({
5151
);
5252

5353
const ActionButton = ({
54-
Icon, text, action, active, tabIndex, hotkey,
54+
Icon, text, action, active, visibility, tabIndex, hotkey,
5555
}) => (
5656
<div
5757
role="button"
@@ -61,6 +61,7 @@ const ActionButton = ({
6161
onClick={() => (active && action())}
6262
onKeyDown={(ev) => active && ev.key === ' ' && action()}
6363
data-tip={hotkey ? hotkey.split(',')[0] : ''}
64+
style={{ display: `${visibility ? '' : 'none'}` }}
6465
>
6566
<div className="icon"><Icon size="20" /></div>
6667
<div style={{ fontSize: 14 }}>{text}</div>

src/toolbarActions/toolbarList.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const toolbarList = (state, dispatcher) => [
2323
icon: FaPlus,
2424
action: createNode,
2525
active: true,
26+
visibility: true,
2627
hotkey: 'Ctrl+G',
2728
},
2829
{ type: 'vsep' },
@@ -32,6 +33,7 @@ const toolbarList = (state, dispatcher) => [
3233
icon: FaFileImport,
3334
action: readFile,
3435
active: true,
36+
visibility: true,
3537
hotkey: 'Ctrl+O',
3638
},
3739
{
@@ -40,20 +42,23 @@ const toolbarList = (state, dispatcher) => [
4042
icon: FaSave,
4143
action: saveGraphMLFile,
4244
active: state.curGraphInstance,
45+
visibility: true,
4346
},
4447
{
4548
type: 'action',
4649
text: 'Save As',
4750
icon: FaSave,
4851
action: (s, d) => saveAction(s, d),
4952
active: true,
53+
visibility: true,
5054
},
5155
{
5256
type: 'action',
5357
text: 'Empty',
5458
icon: FaThermometerEmpty,
5559
action: clearAll,
5660
active: true,
61+
visibility: true,
5762
hotkey: 'Ctrl+Backspace',
5863
},
5964
{ type: 'vsep' },
@@ -63,6 +68,7 @@ const toolbarList = (state, dispatcher) => [
6368
icon: FaUndo,
6469
action: undo,
6570
active: state.undoEnabled,
71+
visibility: true,
6672
hotkey: 'Ctrl+Z',
6773
},
6874
{
@@ -71,6 +77,7 @@ const toolbarList = (state, dispatcher) => [
7177
icon: FaRedo,
7278
action: redo,
7379
active: state.redoEnabled,
80+
visibility: true,
7481
hotkey: 'Ctrl+Shift+Z,Ctrl+Y',
7582
},
7683
{ type: 'vsep' },
@@ -80,6 +87,7 @@ const toolbarList = (state, dispatcher) => [
8087
icon: FaEdit,
8188
action: editElement,
8289
active: (state.eleSelected && state.eleSelectedPayload.type !== 'MIX'),
90+
visibility: true,
8391
hotkey: 'Ctrl+E',
8492
},
8593
{
@@ -88,6 +96,7 @@ const toolbarList = (state, dispatcher) => [
8896
icon: FaTrash,
8997
action: deleteElem,
9098
active: state.eleSelected,
99+
visibility: true,
91100
hotkey: 'Delete,Backspace,Del,Clear',
92101
},
93102
{ type: 'vsep' },
@@ -97,6 +106,7 @@ const toolbarList = (state, dispatcher) => [
97106
icon: FaHistory,
98107
action: viewHistory,
99108
active: true,
109+
visibility: true,
100110
},
101111
{ type: 'vsep' },
102112
// server buttons
@@ -106,48 +116,55 @@ const toolbarList = (state, dispatcher) => [
106116
icon: state.isWorkflowOnServer ? FaToggleOn : FiToggleLeft,
107117
action: () => toggleServer(state, dispatcher),
108118
active: true,
119+
visibility: true,
109120
},
110121
{
111122
type: 'action',
112123
text: 'Build',
113124
icon: FaHammer,
114125
action: () => state.curGraphInstance && state.curGraphInstance.build(),
115126
active: state.isWorkflowOnServer,
127+
visibility: state.isWorkflowOnServer,
116128
},
117129
{
118130
type: 'action',
119131
text: 'Debug',
120132
icon: FaBug,
121133
action: () => state.curGraphInstance && state.curGraphInstance.debug(),
122134
active: state.isWorkflowOnServer,
135+
visibility: state.isWorkflowOnServer,
123136
},
124137
{
125138
type: 'action',
126139
text: 'Run',
127140
icon: FiPlay,
128141
action: () => state.curGraphInstance && state.curGraphInstance.run(),
129142
active: state.isWorkflowOnServer,
143+
visibility: state.isWorkflowOnServer,
130144
},
131145
{
132146
type: 'action',
133147
text: 'Clear',
134148
icon: FaRegTimesCircle,
135149
action: () => state.curGraphInstance && state.curGraphInstance.clear(),
136150
active: state.isWorkflowOnServer,
151+
visibility: state.isWorkflowOnServer,
137152
},
138153
{
139154
type: 'action',
140155
text: 'Stop',
141156
icon: FiStopCircle,
142157
action: () => state.curGraphInstance && state.curGraphInstance.stop(),
143158
active: state.isWorkflowOnServer,
159+
visibility: state.isWorkflowOnServer,
144160
},
145161
{
146162
type: 'action',
147163
text: 'Destroy',
148164
icon: FaBomb,
149165
action: () => state.curGraphInstance && state.curGraphInstance.destroy(),
150166
active: state.isWorkflowOnServer,
167+
visibility: state.isWorkflowOnServer,
151168
},
152169

153170
// Not being implemented in version 1
@@ -195,13 +212,15 @@ const toolbarList = (state, dispatcher) => [
195212
icon: FiTriangle,
196213
action: () => { window.open('https://github.com/ControlCore-Project/concore-editor', '_blank'); },
197214
active: true,
215+
visibility: true,
198216
},
199217
{
200218
type: 'action',
201219
text: 'Share',
202220
icon: FaShare,
203221
action: openShareModal,
204222
active: true,
223+
visibility: true,
205224
},
206225
{
207226
type: 'menu',
@@ -211,6 +230,7 @@ const toolbarList = (state, dispatcher) => [
211230
{ fn: () => downloadImg(s, d, 'JPG'), name: 'JPG' },
212231
{ fn: () => downloadImg(s, d, 'PNG'), name: 'PNG' },
213232
],
233+
visibility: true,
214234
active: true,
215235
},
216236
{ type: 'vsep' },

0 commit comments

Comments
 (0)