Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): mapping expressions from input table #3864

Merged
merged 61 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
26c08e0
implement tree render
mutdmour Aug 5, 2022
4036e91
update styles
mutdmour Aug 5, 2022
4a1da92
merge in master
mutdmour Aug 8, 2022
5b54fdc
implement slots
mutdmour Aug 8, 2022
b0cc1ab
fix recursive tree rendering
mutdmour Aug 8, 2022
f064fc1
make not recursive
mutdmour Aug 8, 2022
1568294
Revert "make not recursive"
mutdmour Aug 8, 2022
d567c24
enable dragging
mutdmour Aug 8, 2022
983539e
fix dragging name
mutdmour Aug 8, 2022
2516564
fix col bug
mutdmour Aug 8, 2022
81f5882
update values and styles
mutdmour Aug 8, 2022
f0c6a13
update style
mutdmour Aug 9, 2022
57b5e1c
update colors
mutdmour Aug 9, 2022
6138408
update design
mutdmour Aug 9, 2022
8c8a51e
add hover state
mutdmour Aug 9, 2022
747b709
add dragging behavior
mutdmour Aug 9, 2022
5d433d8
format file
mutdmour Aug 9, 2022
b528f98
update pill text
mutdmour Aug 9, 2022
4d572d9
add depth field
mutdmour Aug 10, 2022
e7b4acb
typo
mutdmour Aug 10, 2022
b7ce631
add avg height
mutdmour Aug 10, 2022
6a990dd
update event name
mutdmour Aug 10, 2022
80f441c
update expr at distance
mutdmour Aug 10, 2022
82fd08f
add right margin always
mutdmour Aug 10, 2022
3d8a369
add space
mutdmour Aug 10, 2022
97c6e99
handle long values
mutdmour Aug 10, 2022
512f123
Merge branch 'master' of github.com:n8n-io/n8n into n8n-4284-mapping-v2
mutdmour Aug 10, 2022
78853de
update types
mutdmour Aug 10, 2022
ab43454
Merge branch 'master' of github.com:n8n-io/n8n into n8n-4284-mapping-v2
mutdmour Aug 11, 2022
391f19d
Merge branch 'master' of github.com:n8n-io/n8n into n8n-4284-mapping-v2
mutdmour Aug 12, 2022
a1533dd
merge in master
mutdmour Aug 15, 2022
0faf2f2
fix conflict
mutdmour Aug 22, 2022
0147c3c
update messages
mutdmour Aug 23, 2022
4687649
update keys styling
mutdmour Aug 23, 2022
7602795
update spacing size
mutdmour Aug 23, 2022
a775540
fix hover bug
mutdmour Aug 23, 2022
26c8512
update switch spacing
mutdmour Aug 23, 2022
03f9691
fix wrap issue
mutdmour Aug 23, 2022
4688dd0
update spacing issues
mutdmour Aug 23, 2022
5392418
remove br
mutdmour Aug 23, 2022
cbe44e8
update hoverable
mutdmour Aug 23, 2022
70df1ba
reduce event
mutdmour Aug 23, 2022
056dea8
replace tree
mutdmour Aug 23, 2022
3e8e111
update prop name
mutdmour Aug 23, 2022
39d943a
update tree story
mutdmour Aug 23, 2022
0a16c4a
update tree
mutdmour Aug 23, 2022
640f43e
refactor run data
mutdmour Aug 23, 2022
3e4f96b
add unit tests
mutdmour Aug 23, 2022
fa4f7c2
add test for nodeclass
mutdmour Aug 23, 2022
7506fbf
remove number check
mutdmour Aug 23, 2022
df037d4
bring back hook
mutdmour Aug 23, 2022
45041f3
Merge branch 'master' of github.com:n8n-io/n8n into n8n-4284-mapping-v2
mutdmour Aug 23, 2022
b502fd2
Merge branch 'master' of github.com:n8n-io/n8n into n8n-4284-mapping-v2
mutdmour Aug 23, 2022
df55f6d
address review comments
mutdmour Aug 23, 2022
6d33891
Merge branch 'master' of github.com:n8n-io/n8n into n8n-4284-mapping-v2
mutdmour Aug 24, 2022
5ff18ff
update margin
mutdmour Aug 24, 2022
20b3380
update tests
mutdmour Aug 24, 2022
b36a8ab
address max's feedback
mutdmour Aug 24, 2022
ea0c624
update tslint issues
mutdmour Aug 24, 2022
976be82
if empty, remove min width
mutdmour Aug 24, 2022
f239382
update spacing back
mutdmour Aug 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions packages/design-system/src/components/N8nTree/Tree.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* tslint:disable:variable-name */

import N8nTree from './Tree.vue';
import {StoryFn} from "@storybook/vue";

export default {
title: 'Atoms/Tree',
component: N8nTree,
};

export const Default: StoryFn = (args, {argTypes}) => ({
props: Object.keys(argTypes),
components: {
N8nTree,
},
template: `<n8n-tree v-bind="$props">
<template v-slot:label="{ label }">
<span>{{ label }}</span>
</template>
<template v-slot:value="{ value }">
<span>{{ value }}</span>
</template>
</n8n-tree>`,
});

Default.args = {
value: {
objectKey: {
nestedArrayKey: [
'in progress',
33958053,
],
stringKey: 'word',
aLongKey: 'Lorem ipsum dolor sit consectetur adipiscing elit. Sed dignissim aliquam ipsum mattis pellentesque. Phasellus ut ligula fermentum orci elementum dignissim. Vivamus interdum risus eget nibh placerat ultrices. Vivamus orci arcu, iaculis in nulla non, blandit molestie magna. Praesent tristique feugiat odio non vehicula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse fermentum purus diam, nec auctor elit consectetur nec. Vestibulum ultrices diam magna, in faucibus odio bibendum id. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut sollicitudin lacus neque.',
objectKey: {
myKey: 'what\'s for lunch',
yourKey: 'prolle rewe wdyt',
},
id: 123,
},
hello: "world",
test: {
label: "A cool folder",
children: [
{
label: "A cool sub-folder 1",
children: [
{ label: "A cool sub-sub-folder 1" },
{ label: "A cool sub-sub-folder 2" },
],
},
{ label: "This one is not that cool" },
],
},
},
};

82 changes: 82 additions & 0 deletions packages/design-system/src/components/N8nTree/Tree.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<template>
<div class="n8n-tree">
<div v-for="(label, i) in Object.keys(value || {})" :key="i" :class="{[nodeClass]: !!nodeClass, [$style.indent]: depth > 0}">
<div :class="$style.simple" v-if="isSimple(value[label])">
<slot v-if="$scopedSlots.label" name="label" v-bind:label="label" v-bind:path="getPath(label)" />
<span v-else>{{ label }}</span>
<span>:</span>
<slot v-if="$scopedSlots.value" name="value" v-bind:value="value[label]" />
<span v-else>{{ value[label] }}</span>
</div>
<div v-else>
<slot v-if="$scopedSlots.label" name="label" v-bind:label="label" v-bind:path="getPath(label)" />
<span v-else>{{ label }}</span>
<n8n-tree :path="getPath(label)" :depth="depth + 1" :value="value[label]" :nodeClass="nodeClass">
<template v-for="(index, name) in $scopedSlots" v-slot:[name]="data">
<slot :name="name" v-bind="data"></slot>
</template>
</n8n-tree>
</div>
</div>
</div>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
name: 'n8n-tree',
components: {
},
props: {
value: {
},
path: {
type: Array,
default: () => [],
},
depth: {
type: Number,
default: 0,
},
nodeClass: {
type: String,
},
},
methods: {
isSimple(data: unkown): boolean {
if (typeof data === 'object' && Object.keys(data).length === 0) {
return true;
}

if (Array.isArray(data) && data.length === 0) {
return true;
}

return typeof data !== 'object';
},
getPath(key: string): string[] {
if (Array.isArray(this.value)) {
return [...this.path, parseInt(key, 10)];
}
return [...this.path, key];
},
},
});
</script>

<style lang="scss" module>

$--spacing: var(--spacing-s);

.indent {
margin-left: $--spacing;
}

.simple {
text-indent: calc($--spacing * -1);
margin-left: $--spacing;
max-width: 300px;
}

</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { render } from '@testing-library/vue';
import N8nTree from '../Tree.vue';

describe('components', () => {
describe('N8nTree', () => {
it('should render simple tree', () => {
const wrapper = render(N8nTree, {
props: {
value: {
"hello": "world",
},
},
});
expect(wrapper.html()).toMatchSnapshot();
});

it('should render tree', () => {
const wrapper = render(N8nTree, {
props: {
value: {
"hello": {
"test": "world",
},
"options": [
"yes",
"no",
],
},
},
});
expect(wrapper.html()).toMatchSnapshot();
});

it('should render tree with slots', () => {
const wrapper = render(N8nTree, {
props: {
value: {
"hello": {
"test": "world",
},
"options": [
"yes",
"no",
],
},
},
slots: {
label: "<span>label</span>",
value: "<span>value</span>",
},
});
expect(wrapper.html()).toMatchSnapshot();
});


it('should render each tree with node class', () => {
const wrapper = render(N8nTree, {
props: {
value: {
"hello": {
"test": "world",
},
"options": [
"yes",
"no",
],
},
nodeClass: "nodeClass",
},
});
expect(wrapper.html()).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Vitest Snapshot v1

exports[`components > N8nTree > should render each tree with node class 1`] = `
"<div class=\\"n8n-tree\\">
<div class=\\"nodeClass\\">
<div><span>hello</span>
<div class=\\"n8n-tree\\">
<div class=\\"nodeClass _indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>test</span><span>:</span><span>world</span></div>
</div>
</div>
</div>
</div>
<div class=\\"nodeClass\\">
<div><span>options</span>
<div class=\\"n8n-tree\\">
<div class=\\"nodeClass _indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>0</span><span>:</span><span>yes</span></div>
</div>
<div class=\\"nodeClass _indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>1</span><span>:</span><span>no</span></div>
</div>
</div>
</div>
</div>
</div>"
`;

exports[`components > N8nTree > should render simple tree 1`] = `
"<div class=\\"n8n-tree\\">
<div class=\\"\\">
<div class=\\"_simple_1y4uu_5\\"><span>hello</span><span>:</span><span>world</span></div>
</div>
</div>"
`;

exports[`components > N8nTree > should render tree 1`] = `
"<div class=\\"n8n-tree\\">
<div class=\\"\\">
<div><span>hello</span>
<div class=\\"n8n-tree\\">
<div class=\\"_indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>test</span><span>:</span><span>world</span></div>
</div>
</div>
</div>
</div>
<div class=\\"\\">
<div><span>options</span>
<div class=\\"n8n-tree\\">
<div class=\\"_indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>0</span><span>:</span><span>yes</span></div>
</div>
<div class=\\"_indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>1</span><span>:</span><span>no</span></div>
</div>
</div>
</div>
</div>
</div>"
`;

exports[`components > N8nTree > should render tree with slots 1`] = `
"<div class=\\"n8n-tree\\">
<div class=\\"\\">
<div><span>label</span>
<div class=\\"n8n-tree\\">
<div class=\\"_indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>label</span><span>:</span><span>value</span></div>
</div>
</div>
</div>
</div>
<div class=\\"\\">
<div><span>label</span>
<div class=\\"n8n-tree\\">
<div class=\\"_indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>label</span><span>:</span><span>value</span></div>
</div>
<div class=\\"_indent_1y4uu_1\\">
<div class=\\"_simple_1y4uu_5\\"><span>label</span><span>:</span><span>value</span></div>
</div>
</div>
</div>
</div>
</div>"
`;
3 changes: 3 additions & 0 deletions packages/design-system/src/components/N8nTree/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Tree from './Tree.vue';

export default Tree;
2 changes: 2 additions & 0 deletions packages/design-system/src/plugins/n8nComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import N8nTabs from '../components/N8nTabs';
import N8nTag from '../components/N8nTag';
import N8nText from '../components/N8nText';
import N8nTooltip from '../components/N8nTooltip';
import N8nTree from '../components/N8nTree';
import N8nUsersList from '../components/N8nUsersList';
import N8nUserSelect from '../components/N8nUserSelect';

Expand Down Expand Up @@ -76,6 +77,7 @@ export default {
app.component('n8n-tag', N8nTag);
app.component('n8n-text', N8nText);
app.component('n8n-tooltip', N8nTooltip);
app.component('n8n-tree', N8nTree);
app.component('n8n-users-list', N8nUsersList);
app.component('n8n-user-select', N8nUserSelect);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/src/styleguide/colors.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import ColorCircles from './ColorCircles.vue';
<Canvas>
<Story name="secondary">
{{
template: `<color-circles :colors="['--color-secondary']" />`,
template: `<color-circles :colors="['--color-secondary', '--color-secondary-tint-1', '--color-secondary-tint-2']" />`,
components: {
ColorCircles,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/design-system/theme/src/_tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@

--color-json-default: #5045A1;
--color-json-null: var(--color-danger);
--color-json-boolean: #1d8ce0;
--color-json-number: #1d8ce0;
--color-json-boolean: var(--color-success);
--color-json-number: var(--color-success);
--color-json-string: #5045A1;
--color-json-key: var(--color-text-dark);
--color-json-brackets: var(--color-text-dark);
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export interface IRunDataUi {
export interface ITableData {
columns: string[];
data: GenericValue[][];
hasJson: {[key: string]: boolean};
}

export interface IVariableItemSelected {
Expand Down
Loading