Skip to content

Commit

Permalink
wip: add settings tab
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Feb 24, 2023
1 parent 8f7c99f commit e08ff7c
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 3 deletions.
13 changes: 13 additions & 0 deletions app/lib/menu/menu-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class MenuBuilder {
.appendExportAs()
.appendCloseTab()
.appendSeparator()
.appendSettings()
.appendSeparator()
.appendQuit()
.get()
);
Expand Down Expand Up @@ -337,6 +339,17 @@ class MenuBuilder {
return this;
}

appendSettings() {
this.menu.append(new MenuItem({
label: 'Settings',
click: function() {
app.emit('menu:action', 'open-settings');
}
}));

return this;
}

appendMenuItem(builder, menuItem) {
const {
accelerator,
Expand Down
29 changes: 26 additions & 3 deletions client/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ export const EMPTY_TAB = {
type: 'empty'
};

export const SETTINGS_TAB = {
id: '__settings',
type: 'settings',
name: 'Settings',
title: 'Settings'
};

const ENCODING_UTF8 = 'utf8';

const FILTER_ALL_EXTENSIONS = {
Expand Down Expand Up @@ -369,11 +376,11 @@ export class App extends PureComponent {
* @return {Promise<boolean>} resolved to true if tab is closed
*/
closeTab = async (tab) => {
const { file } = tab;
if (this.isDirty(tab)) {
const { file } = tab;

const { name } = file;
const { name } = file;

if (this.isDirty(tab)) {
const { button } = await this.showCloseFileDialog({ name });

if (button === 'save') {
Expand Down Expand Up @@ -403,6 +410,10 @@ export class App extends PureComponent {
return tab === EMPTY_TAB;
};

isSettingsTab = (tab) => {
return tab === SETTINGS_TAB;
};

isDirty = (tab) => {
return !!this.state.dirtyTabs[tab.id];
};
Expand Down Expand Up @@ -1511,6 +1522,14 @@ export class App extends PureComponent {
return Promise.reject(new Error('no last tab'));
};

openSettings = () => {
if (!this.state.tabs.includes(SETTINGS_TAB)) {
this.addTab(SETTINGS_TAB);
}

return this.selectTab(SETTINGS_TAB);
};

showShortcuts = () => this.openModal('KEYBOARD_SHORTCUTS');

/**
Expand Down Expand Up @@ -1690,6 +1709,10 @@ export class App extends PureComponent {
return this.createDiagram('cmmn');
}

if (action === 'open-settings') {
return this.openSettings();
}

if (action === 'create-form') {
return this.createDiagram('form');
}
Expand Down
62 changes: 62 additions & 0 deletions client/src/app/SettingsTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership.
*
* Camunda licenses this file to you under the MIT; you may not use this file
* except in compliance with the MIT License.
*/

import React, { PureComponent } from 'react';

import css from './EmptyTab.less';

import {
Tab
} from './primitives';

import Flags, { DISABLE_DMN, DISABLE_FORM, DISABLE_ZEEBE, DISABLE_PLATFORM } from '../util/Flags';


export default class EmptyTab extends PureComponent {

componentDidMount() {
this.props.onShown();
}

triggerAction() { }

renderDiagramButton = (action, title, icon) => {

const {
onAction
} = this.props;

return (
<button className="btn btn-secondary" onClick={ () => onAction(action) }>
{icon}
{title}
</button>
);
};

render() {

return (
<Tab className={ css.EmptyTab }>
<h1>This is the settings page</h1>

<p>
Lorem ipsum foo bar wat.
</p>

<h3>Startup Flags</h3>

<pre>
{ JSON.stringify(Flags.data, 0, 2) }
</pre>
</Tab>
);
}
}
12 changes: 12 additions & 0 deletions client/src/app/TabsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
} from '../util/Engines';

import EmptyTab from './EmptyTab';
import SettingsTab from './SettingsTab';

import parseDiagramType from './util/parseDiagramType';

Expand Down Expand Up @@ -131,6 +132,17 @@ export default class TabsProvider {
return null;
}
},
settings: {
canOpen(file) {
return false;
},
getComponent() {
return SettingsTab;
},
getIcon() {
return null;
}
},
'cloud-bpmn': {
name: 'BPMN',
encoding: ENCODING_UTF8,
Expand Down

0 comments on commit e08ff7c

Please sign in to comment.