@n8n/frontend-module-engine-v2 0.0.0-stage → 0.0.0-tp
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +88 -0
- package/README.md +86 -2
- package/biome.jsonc +4 -0
- package/oxlint.config.mts +4 -0
- package/package.json +54 -3
- package/src/__tests__/design-system-icons.test.ts +24 -0
- package/src/__tests__/mocks.ts +34 -0
- package/src/__tests__/setup.ts +4 -0
- package/src/components/EngineV2CompatibilityButton.test.ts +67 -0
- package/src/components/EngineV2CompatibilityButton.vue +53 -0
- package/src/components/EngineV2CompatibilityDialog.test.ts +301 -0
- package/src/components/EngineV2CompatibilityDialog.vue +109 -0
- package/src/components/severityIcon.ts +20 -0
- package/src/composables/useEngineV2Compatibility.test.ts +171 -0
- package/src/composables/useEngineV2Compatibility.ts +58 -0
- package/src/engine-v2.module.test.ts +9 -0
- package/src/engine-v2.module.ts +31 -0
- package/src/engineV2Check.test.ts +67 -0
- package/src/engineV2Check.ts +34 -0
- package/src/engineV2ReasonText.ts +106 -0
- package/src/index.ts +11 -0
- package/stylelint.config.mjs +9 -0
- package/vite.config.ts +52 -0
- package/vize-lint.config.mjs +3 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
Portions of this software are licensed as follows:
|
|
4
|
+
|
|
5
|
+
- Content of branches other than the main branch (i.e. "master") are not licensed.
|
|
6
|
+
- Source code files that contain ".ee." in their filename or ".ee" in their dirname are NOT licensed under
|
|
7
|
+
the Sustainable Use License.
|
|
8
|
+
To use source code files that contain ".ee." in their filename or ".ee" in their dirname you must hold a
|
|
9
|
+
valid n8n Enterprise License specifically allowing you access to such source code files and as defined
|
|
10
|
+
in "LICENSE_EE.md".
|
|
11
|
+
- All third party components incorporated into the n8n Software are licensed under the original license
|
|
12
|
+
provided by the owner of the applicable component.
|
|
13
|
+
- Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
|
|
14
|
+
License" as defined below.
|
|
15
|
+
|
|
16
|
+
## Sustainable Use License
|
|
17
|
+
|
|
18
|
+
Version 1.0
|
|
19
|
+
|
|
20
|
+
### Acceptance
|
|
21
|
+
|
|
22
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
23
|
+
|
|
24
|
+
### Copyright License
|
|
25
|
+
|
|
26
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
|
|
27
|
+
to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
|
|
28
|
+
to the limitations below.
|
|
29
|
+
|
|
30
|
+
### Limitations
|
|
31
|
+
|
|
32
|
+
You may use or modify the software only for your own internal business purposes or for non-commercial or
|
|
33
|
+
personal use. You may distribute the software or provide it to others only if you do so free of charge for
|
|
34
|
+
non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
|
|
35
|
+
the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
36
|
+
|
|
37
|
+
### Patents
|
|
38
|
+
|
|
39
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
|
|
40
|
+
license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
|
|
41
|
+
subject to the limitations and conditions in this license. This license does not cover any patent claims that
|
|
42
|
+
you cause to be infringed by modifications or additions to the software. If you or your company make any
|
|
43
|
+
written claim that the software infringes or contributes to infringement of any patent, your patent license
|
|
44
|
+
for the software granted under these terms ends immediately. If your company makes such a claim, your patent
|
|
45
|
+
license ends immediately for work on behalf of your company.
|
|
46
|
+
|
|
47
|
+
### Notices
|
|
48
|
+
|
|
49
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
|
|
50
|
+
terms. If you modify the software, you must include in any modified copies of the software a prominent notice
|
|
51
|
+
stating that you have modified the software.
|
|
52
|
+
|
|
53
|
+
### No Other Rights
|
|
54
|
+
|
|
55
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
56
|
+
|
|
57
|
+
### Termination
|
|
58
|
+
|
|
59
|
+
If you use the software in violation of these terms, such use is not licensed, and your license will
|
|
60
|
+
automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
|
|
61
|
+
violation of this license no later than 30 days after you receive that notice, your license will be reinstated
|
|
62
|
+
retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
|
|
63
|
+
terms will cause your license to terminate automatically and permanently.
|
|
64
|
+
|
|
65
|
+
### No Liability
|
|
66
|
+
|
|
67
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
|
|
68
|
+
not be liable to you for any damages arising out of these terms or the use or nature of the software, under
|
|
69
|
+
any kind of legal claim.
|
|
70
|
+
|
|
71
|
+
### Definitions
|
|
72
|
+
|
|
73
|
+
The “licensor” is the entity offering these terms.
|
|
74
|
+
|
|
75
|
+
The “software” is the software the licensor makes available under these terms, including any portion of it.
|
|
76
|
+
|
|
77
|
+
“You” refers to the individual or entity agreeing to these terms.
|
|
78
|
+
|
|
79
|
+
“Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
|
|
80
|
+
all organizations that have control over, are under the control of, or are under common control with that
|
|
81
|
+
organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
|
|
82
|
+
management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
83
|
+
|
|
84
|
+
“Your license” is the license granted to you for the software under these terms.
|
|
85
|
+
|
|
86
|
+
“Use” means anything you do with the software requiring your license.
|
|
87
|
+
|
|
88
|
+
“Trademark” means trademarks, service marks, and similar rights.
|
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @n8n/frontend-module-engine-v2
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Frontend module for engine v2. The editor-ui shell consumes it from source through
|
|
4
|
+
`src/app/modules.manifest.ts`, so there is no build step and no `dist`.
|
|
5
|
+
|
|
6
|
+
The descriptor `id` must match the backend module id (`packages/cli/src/modules/engine-v2`).
|
|
7
|
+
`settings.activeModules` is keyed by that string, and a mismatch fails silently. The module is
|
|
8
|
+
not a default module. Enable it in a dev instance with `N8N_ENABLED_MODULES=engine-v2`.
|
|
9
|
+
|
|
10
|
+
## Compatibility check
|
|
11
|
+
|
|
12
|
+
The module tells the editor if the open workflow can run on engine v2. Every answer is
|
|
13
|
+
"compatible" unless the `engine-v2` module is active and the workflow setting `engineType` is
|
|
14
|
+
`'v2'`. The rules live in `@n8n/workflow-engine-check`. This module only shows their result.
|
|
15
|
+
|
|
16
|
+
- `src/engineV2Check.ts` is the only file that imports `@n8n/workflow-engine-check`. The rest of
|
|
17
|
+
the module uses its names, so a change to the package contract changes this file only.
|
|
18
|
+
- `isNodeTypeSupported` asks the package's `isNodeTypeSupported`, which applies the same
|
|
19
|
+
node-type rule as the workflow check. The node creator uses it before the node exists.
|
|
20
|
+
- `useEngineV2Compatibility` takes getters for the nodes, the connections and the settings of the
|
|
21
|
+
workflow, because the document store belongs to the shell. It returns the reasons, the blocking
|
|
22
|
+
reasons and `isNodeTypeIncompatible`.
|
|
23
|
+
- `EngineV2CompatibilityButton` shows the number of reasons, with a red icon when one blocks and a
|
|
24
|
+
yellow icon when all are warnings. The shell puts it above the node creator toolbar on editable
|
|
25
|
+
canvases, and at the top right on read-only canvases. A click opens
|
|
26
|
+
`EngineV2CompatibilityDialog`, which lists the blocking reasons first, then the warnings. The
|
|
27
|
+
list scrolls inside the dialog. Each entry's icon depends on its severity only, so a new reason
|
|
28
|
+
code needs no icon.
|
|
29
|
+
- `src/engineV2ReasonText.ts` gives the text of each reason:
|
|
30
|
+
- `REASON_TEXT_KEYS` has an entry for every code of the package, so the typecheck fails when
|
|
31
|
+
the package adds a code. An entry is a key in `en.json`, one key for each `kind` when a code
|
|
32
|
+
has two meanings, or `null`. A `temporary` reason adds "Run this workflow on Engine v1 for
|
|
33
|
+
now." Codes with the same text share a key.
|
|
34
|
+
- A `null` code shows the English `message` of the package. Use `null` when the `message` holds
|
|
35
|
+
details that a fixed string can't, such as a second node or a count. The dialog then shows no
|
|
36
|
+
node name before the `message` when the `message` already names the node.
|
|
37
|
+
- When the package adds a code, add its entry, and its key to `en.json` unless the entry is
|
|
38
|
+
`null`. When a package rule changes what its `message` says, change the string in the same
|
|
39
|
+
PR, or set the entry to `null`.
|
|
40
|
+
- Tests replace the check with `mockEngineV2Compatibility` from
|
|
41
|
+
`@n8n/frontend-module-engine-v2/__tests__/mocks`.
|
|
42
|
+
|
|
43
|
+
## Checks
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pnpm turbo typecheck --filter=@n8n/frontend-module-engine-v2
|
|
47
|
+
pnpm turbo lint --filter=@n8n/frontend-module-engine-v2
|
|
48
|
+
pnpm turbo lint:styles --filter=@n8n/frontend-module-engine-v2
|
|
49
|
+
pnpm turbo test --filter=@n8n/frontend-module-engine-v2
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Go through turbo, not `pnpm --filter <pkg> typecheck`: this package is consumed
|
|
53
|
+
from source, and on a cold tree its platform dependencies have not been built
|
|
54
|
+
yet. Turbo builds them first; the bare pnpm form does not.
|
|
55
|
+
|
|
56
|
+
## Import rules
|
|
57
|
+
|
|
58
|
+
- Depend on foundation and platform packages only (`@n8n/design-system`,
|
|
59
|
+
`@n8n/stores`, `@n8n/composables`, `@n8n/i18n`, `@n8n/rest-api-client`,
|
|
60
|
+
`@n8n/api-types`, `@n8n/permissions`, `n8n-workflow`,
|
|
61
|
+
`@n8n/frontend-module-sdk`). Never import another
|
|
62
|
+
`@n8n/frontend-module-*`, and never import `@/…` from the shell.
|
|
63
|
+
- `@n8n/stores` and `@n8n/composables` are **subpath-only** — import
|
|
64
|
+
`@n8n/stores/settings.store`, not `@n8n/stores`.
|
|
65
|
+
- The no-cross-module rule is currently a convention: the shared tsconfig base
|
|
66
|
+
omits sibling modules from `paths`, which blocks an accidental import but not
|
|
67
|
+
a deliberate one (declaring the dependency makes it typecheck clean). No
|
|
68
|
+
rule enforces it yet. CAT-3692 tracks the Oxlint rule that will.
|
|
69
|
+
|
|
70
|
+
## Adding UI
|
|
71
|
+
|
|
72
|
+
`vite.config.ts` already carries the three plugins a design-system consumer
|
|
73
|
+
needs, so a `.vue` file compiles in tests without further setup:
|
|
74
|
+
|
|
75
|
+
- `@vitejs/plugin-vue` — single-file components.
|
|
76
|
+
- `unplugin-icons` — the `~icons/lucide/*` virtual modules behind `N8nIcon`.
|
|
77
|
+
- `vite-svg-loader` — design-system's `custom/*.svg` icon components. Without
|
|
78
|
+
it an `.svg` import is a data-URI string, which Vue renders as a tag name.
|
|
79
|
+
|
|
80
|
+
`src/__tests__/design-system-icons.test.ts` renders one icon of each kind, so a
|
|
81
|
+
plugin dropped from `vite.config.ts` fails this package's own suite. Keep that
|
|
82
|
+
test while the module renders any design-system component.
|
|
83
|
+
|
|
84
|
+
SCSS goes in a scoped `<style lang="scss">` block, with tokens from
|
|
85
|
+
design-system — `stylelint.config.mjs` holds this package to the same rules the
|
|
86
|
+
shell uses. Route components must load lazily — see the note in
|
|
87
|
+
`src/engine-v2.module.ts`.
|
package/biome.jsonc
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/frontend-module-engine-v2",
|
|
3
|
-
"version": "0.0.0-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0-tp",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./__tests__/mocks": "./src/__tests__/mocks.ts"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@n8n/design-system": "2.48.0",
|
|
12
|
+
"@n8n/frontend-module-sdk": "0.19.0",
|
|
13
|
+
"@n8n/i18n": "2.49.0",
|
|
14
|
+
"@n8n/stores": "2.49.0",
|
|
15
|
+
"@n8n/workflow-engine-check": "0.2.0",
|
|
16
|
+
"n8n-workflow": "2.49.0",
|
|
17
|
+
"vue": "^3.5.13",
|
|
18
|
+
"vue-router": "^4.5.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@iconify/json": "^2.2.488",
|
|
22
|
+
"@n8n/frontend-test-utils": "0.1.0",
|
|
23
|
+
"@n8n/frontend-vite-config": "0.1.0",
|
|
24
|
+
"@n8n/oxlint-config": "0.0.1",
|
|
25
|
+
"@n8n/playwright-janitor": "0.1.0",
|
|
26
|
+
"@n8n/stylelint-config": "0.0.1",
|
|
27
|
+
"@n8n/typescript-config": "1.12.0",
|
|
28
|
+
"@n8n/vitest-config": "1.26.0",
|
|
29
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
30
|
+
"@testing-library/vue": "^8.1.0",
|
|
31
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
32
|
+
"oxlint": "1.93.0",
|
|
33
|
+
"oxlint-tsgolint": "^7.0.2007",
|
|
34
|
+
"stylelint": "^16.23.0",
|
|
35
|
+
"typescript": "6.0.2",
|
|
36
|
+
"unplugin-icons": "^23.0.1",
|
|
37
|
+
"vite": "^8.1.6",
|
|
38
|
+
"vite-svg-loader": "5.1.0",
|
|
39
|
+
"vitest": "5.0.1",
|
|
40
|
+
"vize": "0.715.0",
|
|
41
|
+
"vue-tsc": "^2.2.8"
|
|
42
|
+
},
|
|
43
|
+
"license": "LicenseRef-n8n-sustainable-use",
|
|
44
|
+
"scripts": {
|
|
45
|
+
"clean": "rimraf .turbo",
|
|
46
|
+
"typecheck": "vue-tsc --noEmit",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:changed": "janitor test-scoped",
|
|
49
|
+
"test:dev": "vitest",
|
|
50
|
+
"lint": "oxlint src --quiet && vize lint -c vize-lint.config.mjs \"src/**/*.vue\"",
|
|
51
|
+
"lint:fix": "oxlint src --fix && vize lint -c vize-lint.config.mjs \"src/**/*.vue\"",
|
|
52
|
+
"lint:styles": "stylelint \"src/**/*.{scss,sass,vue}\" --cache --allow-empty-input",
|
|
53
|
+
"lint:styles:fix": "stylelint \"src/**/*.{scss,sass,vue}\" --fix --cache --allow-empty-input",
|
|
54
|
+
"format": "biome format --write . && prettier --write . --ignore-path ../../../../.prettierignore",
|
|
55
|
+
"format:check": "biome ci . && prettier --check . --ignore-path ../../../../.prettierignore"
|
|
56
|
+
}
|
|
6
57
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { N8nIcon } from '@n8n/design-system';
|
|
2
|
+
import { render } from '@testing-library/vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A build-config test, not a feature test. `@n8n/design-system` is consumed from source, so its
|
|
6
|
+
* two icon mechanisms are this package's problem, and each package carries its own
|
|
7
|
+
* `vite.config.ts`. Both cases fail loudly when a plugin goes missing from that file:
|
|
8
|
+
*
|
|
9
|
+
* - `box` comes from `~icons/lucide/box`, which only `unplugin-icons` resolves.
|
|
10
|
+
* - `webhook` comes from `custom/webhook.svg`, which only `svgLoader` turns into a component.
|
|
11
|
+
* Without it the import is a data-URI string, which Vue renders as a tag name.
|
|
12
|
+
*
|
|
13
|
+
* Keep this test while the module renders any design-system component.
|
|
14
|
+
*/
|
|
15
|
+
describe('design-system icons', () => {
|
|
16
|
+
it.each([
|
|
17
|
+
['a lucide icon', 'bookmark'],
|
|
18
|
+
['a custom svg icon', 'webhook'],
|
|
19
|
+
])('renders %s', (_case, icon) => {
|
|
20
|
+
const { container } = render(N8nIcon, { props: { icon } });
|
|
21
|
+
|
|
22
|
+
expect(container.querySelector('svg')).not.toBeNull();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
engineV2Check,
|
|
5
|
+
type EngineCompatibilityReason,
|
|
6
|
+
type EngineCompatibilityWorkflow,
|
|
7
|
+
} from '../engineV2Check';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Makes the engine v2 check return these results until the test ends. `reasons` can be a
|
|
11
|
+
* function of the checked workflow, to prove that a change to the workflow reaches the check.
|
|
12
|
+
*/
|
|
13
|
+
export function mockEngineV2Compatibility({
|
|
14
|
+
reasons = [],
|
|
15
|
+
unsupportedNodeTypes = [],
|
|
16
|
+
}: {
|
|
17
|
+
reasons?:
|
|
18
|
+
| EngineCompatibilityReason[]
|
|
19
|
+
| ((workflow: EngineCompatibilityWorkflow) => EngineCompatibilityReason[]);
|
|
20
|
+
unsupportedNodeTypes?: string[];
|
|
21
|
+
} = {}) {
|
|
22
|
+
const checkWorkflow = vi.spyOn(engineV2Check, 'checkWorkflow').mockImplementation((workflow) => {
|
|
23
|
+
const result = typeof reasons === 'function' ? reasons(workflow) : reasons;
|
|
24
|
+
return {
|
|
25
|
+
eligible: !result.some((reason) => reason.severity === 'blocking'),
|
|
26
|
+
reasons: result,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
const isNodeTypeSupported = vi
|
|
30
|
+
.spyOn(engineV2Check, 'isNodeTypeSupported')
|
|
31
|
+
.mockImplementation((nodeTypeName) => !unsupportedNodeTypes.includes(nodeTypeName));
|
|
32
|
+
|
|
33
|
+
return { checkWorkflow, isNodeTypeSupported };
|
|
34
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// The shared frontend test harness: the jsdom environment, english messages, and a fresh pinia
|
|
2
|
+
// per test. It lives in `@n8n/frontend-test-utils` rather than in `@n8n/vitest-config`, because
|
|
3
|
+
// `@n8n/i18n` devDepends on the latter and importing i18n there closes a cycle in the turbo graph.
|
|
4
|
+
import '@n8n/frontend-test-utils/setup';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useI18n } from '@n8n/i18n';
|
|
2
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/vue';
|
|
3
|
+
|
|
4
|
+
import type { EngineCompatibilityReason } from '../engineV2Check';
|
|
5
|
+
import EngineV2CompatibilityButton from './EngineV2CompatibilityButton.vue';
|
|
6
|
+
|
|
7
|
+
function reason(severity: EngineCompatibilityReason['severity']): EngineCompatibilityReason {
|
|
8
|
+
return { code: 'ERROR_WORKFLOW', kind: 'temporary', severity, message: 'Package message.' };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function buttonIcon() {
|
|
12
|
+
return screen
|
|
13
|
+
.getByTestId('engine-v2-compatibility-button')
|
|
14
|
+
.querySelector('[data-icon]')
|
|
15
|
+
?.getAttribute('data-icon');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('EngineV2CompatibilityButton', () => {
|
|
19
|
+
const i18n = useI18n();
|
|
20
|
+
|
|
21
|
+
it('shows the blocking icon when a reason blocks', () => {
|
|
22
|
+
render(EngineV2CompatibilityButton, {
|
|
23
|
+
props: { reasons: [reason('warning'), reason('blocking')] },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
expect(buttonIcon()).toBe('circle-x');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('shows the warning icon when every reason is a warning', () => {
|
|
30
|
+
render(EngineV2CompatibilityButton, {
|
|
31
|
+
props: { reasons: [reason('warning'), reason('warning')] },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(buttonIcon()).toBe('triangle-alert');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it.each([
|
|
38
|
+
[1, '1 Engine v2 issue'],
|
|
39
|
+
[3, '3 Engine v2 issues'],
|
|
40
|
+
])('counts %i reasons', (count, label) => {
|
|
41
|
+
render(EngineV2CompatibilityButton, {
|
|
42
|
+
props: { reasons: Array.from({ length: count }, () => reason('blocking')) },
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(screen.getByTestId('engine-v2-compatibility-button')).toHaveTextContent(label);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('opens the dialog with every reason, and keeps the button when the dialog closes', async () => {
|
|
49
|
+
render(EngineV2CompatibilityButton, {
|
|
50
|
+
props: { reasons: [reason('blocking'), reason('warning')] },
|
|
51
|
+
});
|
|
52
|
+
expect(screen.queryByTestId('engine-v2-compatibility-dialog')).not.toBeInTheDocument();
|
|
53
|
+
|
|
54
|
+
await fireEvent.click(screen.getByTestId('engine-v2-compatibility-button'));
|
|
55
|
+
|
|
56
|
+
const dialog = await screen.findByTestId('engine-v2-compatibility-dialog');
|
|
57
|
+
expect(dialog).toHaveTextContent(i18n.baseText('engineV2Compatibility.dialog.title'));
|
|
58
|
+
expect(screen.getAllByTestId('engine-v2-compatibility-reason')).toHaveLength(2);
|
|
59
|
+
|
|
60
|
+
await fireEvent.keyDown(dialog, { key: 'Escape' });
|
|
61
|
+
|
|
62
|
+
await waitFor(() =>
|
|
63
|
+
expect(screen.queryByTestId('engine-v2-compatibility-dialog')).not.toBeInTheDocument(),
|
|
64
|
+
);
|
|
65
|
+
expect(screen.getByTestId('engine-v2-compatibility-button')).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { N8nButton, N8nIcon } from '@n8n/design-system';
|
|
3
|
+
import { useI18n } from '@n8n/i18n';
|
|
4
|
+
import { computed, ref } from 'vue';
|
|
5
|
+
|
|
6
|
+
import EngineV2CompatibilityDialog from './EngineV2CompatibilityDialog.vue';
|
|
7
|
+
import { severityIcon, worstSeverity } from './severityIcon';
|
|
8
|
+
import type { EngineCompatibilityReason } from '../engineV2Check';
|
|
9
|
+
|
|
10
|
+
const { reasons } = defineProps<{
|
|
11
|
+
reasons: EngineCompatibilityReason[];
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const i18n = useI18n();
|
|
15
|
+
|
|
16
|
+
// The dialog is a sibling of the button, so a change to the reasons never closes it.
|
|
17
|
+
const isDialogOpen = ref(false);
|
|
18
|
+
|
|
19
|
+
const icon = computed(() => severityIcon(worstSeverity(reasons)));
|
|
20
|
+
|
|
21
|
+
const label = computed(() =>
|
|
22
|
+
i18n.baseText('engineV2Compatibility.button.label', {
|
|
23
|
+
adjustToNumber: reasons.length,
|
|
24
|
+
interpolate: { count: reasons.length },
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<div>
|
|
31
|
+
<N8nButton
|
|
32
|
+
variant="outline"
|
|
33
|
+
size="small"
|
|
34
|
+
:class="$style.button"
|
|
35
|
+
data-test-id="engine-v2-compatibility-button"
|
|
36
|
+
data-attr="engine-v2-compatibility-button"
|
|
37
|
+
@click="isDialogOpen = true"
|
|
38
|
+
>
|
|
39
|
+
<template #icon>
|
|
40
|
+
<N8nIcon :icon="icon.icon" :color="icon.color" />
|
|
41
|
+
</template>
|
|
42
|
+
{{ label }}
|
|
43
|
+
</N8nButton>
|
|
44
|
+
<EngineV2CompatibilityDialog v-model:open="isDialogOpen" :reasons="reasons" />
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style lang="scss" module>
|
|
49
|
+
.button {
|
|
50
|
+
box-shadow: var(--shadow--xs);
|
|
51
|
+
pointer-events: auto;
|
|
52
|
+
}
|
|
53
|
+
</style>
|