diff --git a/client/src/app/App.js b/client/src/app/App.js index 7c4b15723a..8110f1fc7e 100644 --- a/client/src/app/App.js +++ b/client/src/app/App.js @@ -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') { @@ -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) }; }) ]; diff --git a/client/src/app/EmptyTab.js b/client/src/app/EmptyTab.js index 8cfeaf8652..c13c5e9729 100644 --- a/client/src/app/EmptyTab.js +++ b/client/src/app/EmptyTab.js @@ -34,16 +34,14 @@ 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 ( - @@ -51,9 +49,9 @@ export default class EmptyTab extends PureComponent { }; 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 = () => { diff --git a/resources/plugins/package-lock.json b/resources/plugins/package-lock.json index 332fc47b0e..d7d189932f 100644 --- a/resources/plugins/package-lock.json +++ b/resources/plugins/package-lock.json @@ -892,6 +892,16 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/bpmn-moddle": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/bpmn-moddle/-/bpmn-moddle-8.0.1.tgz", @@ -995,6 +1005,96 @@ "integrity": "sha512-QwUMNUBWDQlWtOY76sFEsG26IpVt9Xo+Vyg/NiFi22/5KfiKgxqS93LeJ/BsM2cq00setWM3QSzILyQieyNyTQ==", "dev": true }, + "node_modules/camunda-modeler-webpack-plugin": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/camunda-modeler-webpack-plugin/-/camunda-modeler-webpack-plugin-0.1.0.tgz", + "integrity": "sha512-hHaqCS94z5vBuRf8Vo/d5o/BjWGItkgMe+GilmjQkXV+Ih65NXekCxKU2EpTxmE1K4ii5+0XsizXEUF/G7GniA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-transform-react-jsx": "^7.16.5", + "@babel/preset-react": "^7.16.7", + "babel-loader": "^8.2.3" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0", + "camunda-modeler-plugin-helpers": ">=5.0.0", + "webpack": ">=4.0.0" + } + }, + "node_modules/camunda-modeler-webpack-plugin/node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/camunda-modeler-webpack-plugin/node_modules/ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "ajv": "^6.9.1" + } + }, + "node_modules/camunda-modeler-webpack-plugin/node_modules/babel-loader": { + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.4.1.tgz", + "integrity": "sha512-nXzRChX+Z1GoE6yWavBQg6jDslyFF3SDjl2paADuoQtQW10JqShJt62R6eJQ5m/pjJFDT8xgKIWSP85OY8eXeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-cache-dir": "^3.3.1", + "loader-utils": "^2.0.4", + "make-dir": "^3.1.0", + "schema-utils": "^2.6.5" + }, + "engines": { + "node": ">= 8.9" + }, + "peerDependencies": { + "@babel/core": "^7.0.0", + "webpack": ">=2" + } + }, + "node_modules/camunda-modeler-webpack-plugin/node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/camunda-modeler-webpack-plugin/node_modules/schema-utils": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz", + "integrity": "sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/json-schema": "^7.0.5", + "ajv": "^6.12.4", + "ajv-keywords": "^3.5.2" + }, + "engines": { + "node": ">= 8.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001431", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz", @@ -1154,6 +1254,16 @@ "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==", "dev": true }, + "node_modules/emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/enhanced-resolve": { "version": "5.10.0", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", @@ -1576,6 +1686,21 @@ "node": ">=6.11.5" } }, + "node_modules/loader-utils": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + }, + "engines": { + "node": ">=8.9.0" + } + }, "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -2331,6 +2456,10 @@ "resolved": "test-lint-rules", "link": true }, + "node_modules/test-tab": { + "resolved": "test-tab", + "link": true + }, "node_modules/tiny-glob": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz", @@ -2657,6 +2786,18 @@ "dependencies": { "bpmnlint-utils": "^1.0.1" } + }, + "test-tab": { + "version": "0.0.0", + "devDependencies": { + "@babel/core": "^7.20.2", + "@babel/preset-react": "^7.18.6", + "babel-loader": "^9.1.0", + "camunda-modeler-plugin-helpers": "^5.0.0", + "camunda-modeler-webpack-plugin": "^0.1.0", + "webpack": "^5.74.0", + "webpack-cli": "^5.0.0" + } } }, "dependencies": { @@ -3352,6 +3493,12 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true + }, "bpmn-moddle": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/bpmn-moddle/-/bpmn-moddle-8.0.1.tgz", @@ -3433,6 +3580,67 @@ "integrity": "sha512-QwUMNUBWDQlWtOY76sFEsG26IpVt9Xo+Vyg/NiFi22/5KfiKgxqS93LeJ/BsM2cq00setWM3QSzILyQieyNyTQ==", "dev": true }, + "camunda-modeler-webpack-plugin": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/camunda-modeler-webpack-plugin/-/camunda-modeler-webpack-plugin-0.1.0.tgz", + "integrity": "sha512-hHaqCS94z5vBuRf8Vo/d5o/BjWGItkgMe+GilmjQkXV+Ih65NXekCxKU2EpTxmE1K4ii5+0XsizXEUF/G7GniA==", + "dev": true, + "requires": { + "@babel/plugin-transform-react-jsx": "^7.16.5", + "@babel/preset-react": "^7.16.7", + "babel-loader": "^8.2.3" + }, + "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true, + "requires": {} + }, + "babel-loader": { + "version": "8.4.1", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.4.1.tgz", + "integrity": "sha512-nXzRChX+Z1GoE6yWavBQg6jDslyFF3SDjl2paADuoQtQW10JqShJt62R6eJQ5m/pjJFDT8xgKIWSP85OY8eXeA==", + "dev": true, + "requires": { + "find-cache-dir": "^3.3.1", + "loader-utils": "^2.0.4", + "make-dir": "^3.1.0", + "schema-utils": "^2.6.5" + } + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "schema-utils": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.1.tgz", + "integrity": "sha512-SHiNtMOUGWBQJwzISiVYKu82GiV4QYGePp3odlY1tuKO7gPtphAT5R/py0fA6xtbgLL/RvtJZnU9b8s0F1q0Xg==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.5", + "ajv": "^6.12.4", + "ajv-keywords": "^3.5.2" + } + } + } + }, "caniuse-lite": { "version": "1.0.30001431", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz", @@ -3553,6 +3761,12 @@ "integrity": "sha512-M8WEXFuKXMYMVr45fo8mq0wUrrJHheiKZf6BArTKk9ZBYCKJEOU5H8cdWgDT+qCVZf7Na4lVUaZsA+h6uA9+PA==", "dev": true }, + "emojis-list": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", + "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", + "dev": true + }, "enhanced-resolve": { "version": "5.10.0", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", @@ -3868,6 +4082,17 @@ "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", "dev": true }, + "loader-utils": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.4.tgz", + "integrity": "sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -4429,6 +4654,18 @@ "webpack-cli": "^5.0.0" } }, + "test-tab": { + "version": "file:test-tab", + "requires": { + "@babel/core": "^7.20.2", + "@babel/preset-react": "^7.18.6", + "babel-loader": "^9.1.0", + "camunda-modeler-plugin-helpers": "^5.0.0", + "camunda-modeler-webpack-plugin": "^0.1.0", + "webpack": "^5.74.0", + "webpack-cli": "^5.0.0" + } + }, "tiny-glob": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/tiny-glob/-/tiny-glob-0.2.9.tgz", diff --git a/resources/plugins/test-tab/client/index.js b/resources/plugins/test-tab/client/index.js new file mode 100644 index 0000000000..21db1212d3 --- /dev/null +++ b/resources/plugins/test-tab/client/index.js @@ -0,0 +1,63 @@ +/** + * 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. + */ + +// eslint-disable-next-line no-unused-vars +import React from 'react'; + +import { registerClientExtension, registerClientPlugin } from 'camunda-modeler-plugin-helpers'; +import { Fill } from 'camunda-modeler-plugin-helpers/components'; + +const tab = { + helloWorld: { + name: 'TEST', + encoding: 'utf8', + exports: {}, + extensions: [ 'helloWorld' ], + canOpen(file) { + return file.name.endsWith('.helloWorld'); + }, + getComponent(options) { + return () =>

Hello world!

; + }, + getIcon() { + return null; + }, + getInitialContents() { + return ''; + }, + getInitialFilename(suffix) { + return `hello_${suffix}.helloWorld`; + }, + getHelpMenu() { + return []; + }, + getNewFileMenu() { + return [ { + label: 'Hello World', + group: 'Camunda 8', + action: 'create-diagram', + options: { + type: 'helloWorld' + } + } ]; + }, + getLinter() { + return null; + } + } +}; + +const EmptyTabEntry = () => { + return ; +}; + + +registerClientPlugin(tab, 'tabs'); +registerClientExtension(EmptyTabEntry); \ No newline at end of file diff --git a/resources/plugins/test-tab/index.js b/resources/plugins/test-tab/index.js new file mode 100644 index 0000000000..388034998d --- /dev/null +++ b/resources/plugins/test-tab/index.js @@ -0,0 +1,14 @@ +/** + * 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. + */ + +module.exports = { + script: './dist/client.js', + name: 'test-tab' +}; diff --git a/resources/plugins/test-tab/package.json b/resources/plugins/test-tab/package.json new file mode 100644 index 0000000000..eaad21c1ac --- /dev/null +++ b/resources/plugins/test-tab/package.json @@ -0,0 +1,19 @@ +{ + "name": "test-tab", + "version": "0.0.0", + "description": "Camunda Modeler test client plug-in", + "main": "index.js", + "scripts": { + "all": "webpack", + "test": "echo \"no tests\" && exit 0" + }, + "devDependencies": { + "@babel/core": "^7.20.2", + "@babel/preset-react": "^7.18.6", + "babel-loader": "^9.1.0", + "camunda-modeler-plugin-helpers": "^5.0.0", + "camunda-modeler-webpack-plugin": "^0.1.0", + "webpack": "^5.74.0", + "webpack-cli": "^5.0.0" + } +} diff --git a/resources/plugins/test-tab/webpack.config.js b/resources/plugins/test-tab/webpack.config.js new file mode 100644 index 0000000000..7b1f6da456 --- /dev/null +++ b/resources/plugins/test-tab/webpack.config.js @@ -0,0 +1,39 @@ +/** + * 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. + */ + +const path = require('path'); +const CamundaModelerWebpackPlugin = require('camunda-modeler-webpack-plugin'); + +module.exports = { + mode: 'development', + entry: './client/index.js', + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'client.js' + }, + plugins: [ + new CamundaModelerWebpackPlugin() + ], + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + presets: [ '@babel/preset-react' ] + } + } + } + ] + }, + devtool: 'cheap-module-source-map' +};