n8n/packages/editor-ui/src/components/VariableSelectorItem.vue

184 lines
4.6 KiB
Vue
Raw Normal View History

2019-06-23 03:35:23 -07:00
<template>
<div class="item">
<div v-if="item.options" class="options">
<div v-if="item.options.length" class="headline clickable" @click="extended = !extended">
2019-06-23 03:35:23 -07:00
<div class="options-toggle" v-if="extendAll !== true">
<font-awesome-icon v-if="extended" icon="angle-down" />
<font-awesome-icon v-else icon="angle-right" />
</div>
<div class="option-title" :title="item.key">
{{ item.name }}
2019-06-23 03:35:23 -07:00
<el-dropdown
trigger="click"
@click.stop
@command="optionSelected($event, item)"
v-if="allowParentSelect === true"
>
2019-06-23 03:35:23 -07:00
<span class="el-dropdown-link clickable" @click.stop>
<font-awesome-icon
icon="dot-circle"
:title="$locale.baseText('variableSelectorItem.selectItem')"
/>
2019-06-23 03:35:23 -07:00
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item
:command="operation.command"
v-for="operation in itemAddOperations"
:key="operation.command"
>{{ operation.displayName }}</el-dropdown-item
>
</el-dropdown-menu>
</template>
2019-06-23 03:35:23 -07:00
</el-dropdown>
</div>
</div>
<div v-if="item.options && (extended === true || extendAll === true)">
<variable-selector-item
v-for="option in item.options"
:item="option"
:key="option.key"
:extendAll="extendAll"
:allowParentSelect="option.allowParentSelect"
class="sub-level"
@itemSelected="forwardItemSelected"
></variable-selector-item>
2019-06-23 03:35:23 -07:00
</div>
</div>
<div v-else class="value clickable" @click="selectItem(item)">
<div class="item-title" :title="item.key">
{{ item.name }}:
2019-06-23 03:35:23 -07:00
<font-awesome-icon icon="dot-circle" title="Select Item" />
</div>
<div class="item-value ph-no-capture">
{{ item.value !== undefined ? item.value : $locale.baseText('variableSelectorItem.empty') }}
</div>
2019-06-23 03:35:23 -07:00
</div>
</div>
</template>
<script lang="ts">
import type { IVariableSelectorOption, IVariableItemSelected } from '@/Interface';
import { externalHooks } from '@/mixins/externalHooks';
import mixins from 'vue-typed-mixins';
2019-06-23 03:35:23 -07:00
export default mixins(externalHooks).extend({
2019-06-23 03:35:23 -07:00
name: 'VariableSelectorItem',
props: ['allowParentSelect', 'extendAll', 'item'],
feat(editor): Overhaul expression editor modal (#4631) * feat(editor): Integrate CodeMirror into expression editor modal (#4563) * :sparkles: Initial setup * :shirt: Fix lint * :zap: Extract segments * :zap: Implement var insertion * :shirt: Ignore `.d.cts` * :zap: Refactor to simplify * :sparkles: Add brace handler * :sparkles: Fully replace input and output * feat(editor): Adjust resolved expression to match parameter input hint (#4600) * :sparkles: Initial adjustments * :bug: Prevent empty decorations * :zap: Adjust resolved expression to match param input hint * :pencil2: Improve comment * :shirt: Remove lint rule * :pencil2: Fix typo * :pencil2: Fix closing brace * :zap: Clean up `displayableSegments()` * feat(editor): Apply styling to expression editor modal (#4607) :art: Apply styling * feat(core): Improve errors in evaluated expression (#4619) * :bug: Fix env var access for FE * :fire: Remove excess closing bracket * :construction: Set up TODO * :pencil2: Update copy * :zap: Deny env vars access to FE * :shirt: Remove unneeded lint exception * :blue_book: Remove unneeded typing * feat(editor): Dynamically delay evaluation resolution (#4625) * :pencil2: Update copy * :zap: Dynamically delay evaluation resolution * :fire: Remove unneeded computed property * refactor(editor): Pre-review cleanup (#4627) * :fire: Remove `ExpressionInput` component * :fire: Remove Quill * :pencil2: Rename i18n key * :art: Place border on correct element * :bug: Handle syntax errors * :zap: Add sample autocompletions * :bug: Fix auto-extending behavior * feat(editor): Improve escaping behavior (#4641) * :art: Hide hint on small screen * :zap: Improve escaping * refactor(editor): Apply styling feedback to expression editor modal (#4660) * :art: Restyle hint * :art: Restyle param input hint * :fire: Remove `e.g.` * :zap: Tweak delay * :art: Restyle output * :art: Tweak theme * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.22 (#4697) * :art: Change background color * :zap: Focus on mount * :zap: Account for preexisting braces on injection * :bug: Fix `$workflow` showing as not saved * :pencil2: Tweak copy * :bug: Fix readonly focus * :zap: Focus input on paste * :zap: Sync inputs with modal * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.23 (#4705) * :zap: Allow newlines * :zap: Set cursor at end of content * :zap: Do not defocus on paste on Chrome * :zap: Fix import * :test_tube: Add e2e tests * :zap: Cleanup * :zap: Add telemetry * :fire: Remove log * :zap: Expose error properties * :test_tube: Rename test * :zap: Move `getCurrentWorkflow()` call * :rewind: Revert highlighting removal per feedback * :zap: Add i18n keys * :truck: Move computed property to local state * :art: Use CSS vars * :zap: Update `pnpm-lock.yaml` * :zap: Apply readonly state * :zap: Use prop * :zap: Complete fix
2022-12-01 04:26:22 -08:00
mounted() {
if (this.extended) return;
const shouldAutoExtend =
[
this.$locale.baseText('variableSelectorItem.currentNode'),
this.$locale.baseText('variableSelectorItem.inputData'),
this.$locale.baseText('variableSelectorItem.binary'),
this.$locale.baseText('variableSelectorItem.json'),
].includes(this.item.name) && this.item.key === undefined;
feat(editor): Overhaul expression editor modal (#4631) * feat(editor): Integrate CodeMirror into expression editor modal (#4563) * :sparkles: Initial setup * :shirt: Fix lint * :zap: Extract segments * :zap: Implement var insertion * :shirt: Ignore `.d.cts` * :zap: Refactor to simplify * :sparkles: Add brace handler * :sparkles: Fully replace input and output * feat(editor): Adjust resolved expression to match parameter input hint (#4600) * :sparkles: Initial adjustments * :bug: Prevent empty decorations * :zap: Adjust resolved expression to match param input hint * :pencil2: Improve comment * :shirt: Remove lint rule * :pencil2: Fix typo * :pencil2: Fix closing brace * :zap: Clean up `displayableSegments()` * feat(editor): Apply styling to expression editor modal (#4607) :art: Apply styling * feat(core): Improve errors in evaluated expression (#4619) * :bug: Fix env var access for FE * :fire: Remove excess closing bracket * :construction: Set up TODO * :pencil2: Update copy * :zap: Deny env vars access to FE * :shirt: Remove unneeded lint exception * :blue_book: Remove unneeded typing * feat(editor): Dynamically delay evaluation resolution (#4625) * :pencil2: Update copy * :zap: Dynamically delay evaluation resolution * :fire: Remove unneeded computed property * refactor(editor): Pre-review cleanup (#4627) * :fire: Remove `ExpressionInput` component * :fire: Remove Quill * :pencil2: Rename i18n key * :art: Place border on correct element * :bug: Handle syntax errors * :zap: Add sample autocompletions * :bug: Fix auto-extending behavior * feat(editor): Improve escaping behavior (#4641) * :art: Hide hint on small screen * :zap: Improve escaping * refactor(editor): Apply styling feedback to expression editor modal (#4660) * :art: Restyle hint * :art: Restyle param input hint * :fire: Remove `e.g.` * :zap: Tweak delay * :art: Restyle output * :art: Tweak theme * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.22 (#4697) * :art: Change background color * :zap: Focus on mount * :zap: Account for preexisting braces on injection * :bug: Fix `$workflow` showing as not saved * :pencil2: Tweak copy * :bug: Fix readonly focus * :zap: Focus input on paste * :zap: Sync inputs with modal * :pencil2: Tweak copy * refactor(editor): Apply feedback 2022.11.23 (#4705) * :zap: Allow newlines * :zap: Set cursor at end of content * :zap: Do not defocus on paste on Chrome * :zap: Fix import * :test_tube: Add e2e tests * :zap: Cleanup * :zap: Add telemetry * :fire: Remove log * :zap: Expose error properties * :test_tube: Rename test * :zap: Move `getCurrentWorkflow()` call * :rewind: Revert highlighting removal per feedback * :zap: Add i18n keys * :truck: Move computed property to local state * :art: Use CSS vars * :zap: Update `pnpm-lock.yaml` * :zap: Apply readonly state * :zap: Use prop * :zap: Complete fix
2022-12-01 04:26:22 -08:00
if (shouldAutoExtend) {
this.extended = true;
}
},
2019-06-23 03:35:23 -07:00
computed: {
itemAddOperations() {
2019-06-23 03:35:23 -07:00
const returnOptions = [
{
command: 'raw',
displayName: 'Raw value',
},
];
if (this.item.dataType === 'array') {
returnOptions.push({
command: 'arrayLength',
displayName: 'Length',
});
returnOptions.push({
command: 'arrayValues',
displayName: 'Values',
});
} else if (this.item.dataType === 'object') {
returnOptions.push({
command: 'objectKeys',
displayName: 'Keys',
});
returnOptions.push({
command: 'objectValues',
displayName: 'Values',
});
}
return returnOptions;
},
},
data() {
2019-06-23 03:35:23 -07:00
return {
extended: false,
};
},
methods: {
optionSelected(command: string, item: IVariableSelectorOption) {
2019-06-23 03:35:23 -07:00
// By default it is raw
let variable = item.key;
if (command === 'arrayValues') {
variable = `${item.key}.join(', ')`;
} else if (command === 'arrayLength') {
variable = `${item.key}.length`;
} else if (command === 'objectKeys') {
variable = `Object.keys(${item.key}).join(', ')`;
} else if (command === 'objectValues') {
variable = `Object.values(${item.key}).join(', ')`;
}
this.$emit('itemSelected', { variable });
},
selectItem(item: IVariableSelectorOption) {
2019-06-23 03:35:23 -07:00
this.$emit('itemSelected', { variable: item.key });
},
forwardItemSelected(eventData: IVariableItemSelected) {
2019-06-23 03:35:23 -07:00
this.$emit('itemSelected', eventData);
},
},
});
</script>
<style scoped lang="scss">
.option-title {
position: relative;
display: inline-block;
font-size: 0.9em;
font-weight: 600;
padding: 0.2em 1em 0.2em 0.4em;
}
.item-title {
font-weight: 600;
font-size: 0.8em;
white-space: nowrap;
:sparkles: Implement design system (#2050) * split up main, sass imports, import new nds * migrate most buttons * update sizes based on feedback * update copy buttons * update executions list * fix issues * force message box buttons * update warning color * update more buttons * wrap message box buttons * update last component * lint fixes * add build report step * breakout imports * set package.json * fix notification bug * clean up imports * use build directories directly * update imports * remove xl size * update number inputs * fix input width * update line height, fix icon bug * fix up editor * fix spacing between buttons * Reset line height * revert changes to this * revert changes * clean up button sizes * change to outline * update select height * update tooltip * remove build report step * clean up impl * remove regenerator runtime * add design system repo * apply editorconfig * apply editor config prettier * lint issue * switch to tabs * switch to single space * update eslintrc * remove git modules * update sass package * support dart sass * add build * update dependency * update contributing.md * set repo * update versions * add tslint step * update spacing to spaces, add dev step * add test step * add test step * update browser lint rc * remove .github * delete .gitignore * set comment for icons * remove preview link * update button interface * update types * set types * clean up intro * update intro * remove assets * move into preview * remove headline comment * reduce theme build * loading executions * match deps versions * match deps versions * fix lint issues * fix lint issues * update callback * disable codacy for docs.css * fix storybook issues * add design system to docker image * update spacing around delete sort button * set line height to stop juggling headline * update sizes * clean up vars * fix scss issues * update button vars * add shade color * fix button without click * fix buttons bug * fix bug with executions list * clean up theme * update link styling * fix typo * run prettier * :art: code format * :art: code format * 🔥 remove empty files * :sparkles: N8n 2284 new inputs (#2075) * implement inputs * prettier fixes * revert unnessary change * move input components and tooltip * remove form elements * move select * update input placements * update sizes * update credentails * clean up select size * fix caret issue * update inputs * clean up select * fix tags dropdown border * clean up tags input * fix workflow name bug * clean up select here * add sizes template * fix option caret * fix input sizes * update date input size * remove tags input override * update prop * update input size * center run data inputs * update disabled colors * update execution header * update scrollbar * update text area spacing * fix items in header * update run data tooltip * remove popover * update prefix positions * add filterable demo * address design issues * fix input issues, flip boolean input to text * update input sufffix colors * remove override * speed up switch, fix toggle spacing issue * update icon * remove icon classes * clean up inputs * clean up inputs with icons * update input spacing again * update suffix position * build * Add support for xlarge inputs * fix input issues * fix input issue * update listeners * update number inputs for settings * update append/prepend spacing * clean up inputs, set expression input as text * fix type errors * fix workflow number input * fix tags dropdown bug * fix bugs * fix menu item bug * remove font weight from link element * remove default * fix select option * fix contrast issues * allow overflow x for multi selects * fix icon * update options select * fix issue that resolves expression to null * update how actions are centered * fix up selects * update selects to support limiting size * update option styles * :zap: Apply suggestions BHesseldieck Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> * :art: code format Co-authored-by: Jan <janober@users.noreply.github.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> * ⏪ Revert "🔥 remove empty files" This reverts commit e91ace4e52403f4a6b00b7be68b86fc48b7d8fef. * :zap: Remove private from n8n-design-system package * :art: Change to spaces to stay consistent with editorconfig & others package files * :zap: Fix year in license Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Jan <janober@users.noreply.github.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-08-29 04:36:17 -07:00
overflow: hidden;
2019-06-23 03:35:23 -07:00
text-overflow: ellipsis;
}
.headline {
position: relative;
margin: 2px;
margin-top: 10px;
feat: migrate editor-ui to Vite.js and various DX improvements (N8N-2277) (#4061) * feat: Added vite.js dependencies. * chore: Removed tests folder to follow same structure as design-system * chore: Removed unused testing config. * chore: Created vite.js index.html * refactor: Updated scss structure and imports. * refactor: Updated workflow building. * fix: Cleared up all workflow dependency cycles. Added proper package.json imports config. * feat: Got a working build using Vite. Need to fix issues next. * fix: Progress! Getting process.env error. * fix: Changed process.env to import.meta.env. * fix: Fixed circular imports that used require(). Fixed monaco editor. * chore: Removed commented code. * chore: Cleaned up package.json * feat: Made necessary changes to replace base path in css files. * feat: Serve CSS files for `editor-ui` Vite migration (#4069) :zap: Serve CSS files for Vite migration * chore: Fixed package-lock.json. * fix: Fixed build after centralized tsconfig update. * fix: Removed lodash-es replacement. * fix: Commented out vitest test command. * style: Fixed linting issues. * fix: Added lodash-es hotfix back. * chore: Updated package-lock.json * refactor: Renamed all n8n scss variables to no longer be defined as private. * feat(editor): add application-wide el-button replacement. * fix(editor): Fix import in page alert after merge. * chore(editor): update package-lock.json. * fix: Case sensitive lodash-es replacement for vue-agile. * fix: add alias for lodash-es camelcase import. * fix: add patch-package support for fixing quill * feat: add patch-package on postinstall * fix: update quill patch path. * refactor: rename quill patch * fix: update quill version. * fix: update quill patch * fix: fix linting rules after installing eslint in design-system * fix: update date picker button to have primary color * test: update callout component snapshots * fix(editor): fix linting issues in editor after enabling eslint * fix(cli): add /assets/* to auth ignore endpoints in server * chore: update package-lock.json * chore: update package-lock.json * fix(editor): fix linting issues * feat: add vite-legacy support * fix: update workflow package interface imports to type imports. * chore: update package-lock.json * fix(editor) fix importing translations other than english * fix(editor): remove test command until vitest is added * fix: increase memory allocation for vite build * fix: add patch-package patches to n8n-custom docker build * fix: add performance and load time improvements * fix: add proper typing to setNodeType * chore: update package-lock.json * style: use generic type for reduce in setNodeType Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
2022-09-23 07:14:28 -07:00
color: $color-primary;
2019-06-23 03:35:23 -07:00
}
.options-toggle {
position: relative;
top: 1px;
margin: 0 3px 0 8px;
display: inline;
}
.value {
margin: 0.2em;
padding: 0.1em 0.3em;
}
.item-value {
font-size: 0.6em;
overflow-x: auto;
}
.sub-level {
padding-left: 20px;
}
</style>