Skip to content

Commit

Permalink
chore: allow context to be passed from new file menu
Browse files Browse the repository at this point in the history
  • Loading branch information
marstamm committed Oct 1, 2024
1 parent 13f5766 commit 1c5f4c2
Show file tree
Hide file tree
Showing 7 changed files with 378 additions and 12 deletions.
8 changes: 2 additions & 6 deletions client/src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ export class App extends PureComponent {
}

if (action === 'create-diagram') {
return this.createDiagram(options);
return this.createDiagram(options.type);
}

if (action === 'reopen-file') {
Expand Down Expand Up @@ -2190,15 +2190,11 @@ export class App extends PureComponent {
items = [
...items,
...entries.map(entry => {

// This allows tab providers to pass options, e.g. for the diagram type
const actionArgs = typeof action === 'string' ? [ entry.action ] : entry.action;

return {
text: entry.label,
group: entry.group,
icon: provider.getIcon(),
onClick: () => this.triggerAction(...actionArgs)
onClick: () => this.triggerAction(entry.action, entry.options)
};
})
];
Expand Down
10 changes: 4 additions & 6 deletions client/src/app/EmptyTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,24 @@ export default class EmptyTab extends PureComponent {

triggerAction() { }

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

const {
onAction
} = this.props;

const actionArgs = typeof action === 'string' ? [ action ] : action;

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

AdditionalButton = (props) => {
const { action, title, icon } = props;
const { action, options, title, icon } = props;

return this.renderDiagramButton(action, title, icon);
return this.renderDiagramButton(action, title, icon, options);
};

renderCloudColumn = () => {
Expand Down
237 changes: 237 additions & 0 deletions resources/plugins/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1c5f4c2

Please sign in to comment.