2021-09-11 01:15:36 -07:00
|
|
|
<template>
|
|
|
|
<n8n-input-label
|
2022-01-07 13:02:21 -08:00
|
|
|
:label="$locale.credText().inputLabelDisplayName(parameter)"
|
|
|
|
:tooltipText="$locale.credText().inputLabelDescription(parameter)"
|
2021-09-11 01:15:36 -07:00
|
|
|
:required="parameter.required"
|
2021-10-27 12:55:37 -07:00
|
|
|
:showTooltip="focused"
|
2022-07-20 04:32:51 -07:00
|
|
|
:showOptions="menuExpanded"
|
2022-11-25 04:09:44 -08:00
|
|
|
:data-test-id="parameter.name"
|
2021-09-11 01:15:36 -07:00
|
|
|
>
|
2022-07-20 04:32:51 -07:00
|
|
|
<template #options>
|
|
|
|
<parameter-options
|
|
|
|
:parameter="parameter"
|
|
|
|
:value="value"
|
|
|
|
:isReadOnly="false"
|
|
|
|
:showOptions="true"
|
2022-09-21 06:44:45 -07:00
|
|
|
:isValueExpression="isValueExpression"
|
2022-07-20 04:32:51 -07:00
|
|
|
@optionSelected="optionSelected"
|
|
|
|
@menu-expanded="onMenuExpanded"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<template>
|
2022-10-12 05:06:28 -07:00
|
|
|
<parameter-input-wrapper
|
2022-07-20 04:32:51 -07:00
|
|
|
ref="param"
|
|
|
|
inputSize="large"
|
|
|
|
:parameter="parameter"
|
|
|
|
:value="value"
|
|
|
|
:path="parameter.name"
|
|
|
|
:hideIssues="true"
|
|
|
|
:documentationUrl="documentationUrl"
|
|
|
|
:errorHighlight="showRequiredErrors"
|
|
|
|
:isForCredential="true"
|
|
|
|
:eventSource="eventSource"
|
2022-12-14 01:04:10 -08:00
|
|
|
:hint="!showRequiredErrors ? hint : ''"
|
2022-07-20 04:32:51 -07:00
|
|
|
@focus="onFocus"
|
|
|
|
@blur="onBlur"
|
|
|
|
@textInput="valueChanged"
|
|
|
|
@valueChanged="valueChanged"
|
|
|
|
/>
|
|
|
|
<div :class="$style.errors" v-if="showRequiredErrors">
|
|
|
|
<n8n-text color="danger" size="small">
|
|
|
|
{{ $locale.baseText('parameterInputExpanded.thisFieldIsRequired') }}
|
2022-12-14 01:04:10 -08:00
|
|
|
<n8n-link
|
|
|
|
v-if="documentationUrl"
|
|
|
|
:to="documentationUrl"
|
|
|
|
size="small"
|
|
|
|
:underline="true"
|
|
|
|
@click="onDocumentationUrlClick"
|
|
|
|
>
|
2022-07-20 04:32:51 -07:00
|
|
|
{{ $locale.baseText('parameterInputExpanded.openDocs') }}
|
|
|
|
</n8n-link>
|
|
|
|
</n8n-text>
|
|
|
|
</div>
|
|
|
|
</template>
|
2021-09-11 01:15:36 -07:00
|
|
|
</n8n-input-label>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { IUpdateInformation } from '@/Interface';
|
2022-07-20 04:32:51 -07:00
|
|
|
import ParameterOptions from './ParameterOptions.vue';
|
2022-10-12 05:06:28 -07:00
|
|
|
import Vue, { PropType } from 'vue';
|
|
|
|
import ParameterInputWrapper from './ParameterInputWrapper.vue';
|
2022-11-23 04:41:53 -08:00
|
|
|
import { isValueExpression } from '@/utils';
|
2022-09-21 06:44:45 -07:00
|
|
|
import { INodeParameterResourceLocator, INodeProperties } from 'n8n-workflow';
|
2022-11-04 06:04:31 -07:00
|
|
|
import { mapStores } from 'pinia';
|
|
|
|
import { useWorkflowsStore } from '@/stores/workflows';
|
2021-09-11 01:15:36 -07:00
|
|
|
|
2021-12-07 07:14:40 -08:00
|
|
|
export default Vue.extend({
|
2022-10-12 05:06:28 -07:00
|
|
|
name: 'parameter-input-expanded',
|
2021-09-11 01:15:36 -07:00
|
|
|
components: {
|
2022-07-20 04:32:51 -07:00
|
|
|
ParameterOptions,
|
2022-10-12 05:06:28 -07:00
|
|
|
ParameterInputWrapper,
|
2021-09-11 01:15:36 -07:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
parameter: {
|
2022-10-12 05:06:28 -07:00
|
|
|
type: Object as PropType<INodeProperties>,
|
2021-09-11 01:15:36 -07:00
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
value: {},
|
2021-09-11 01:15:36 -07:00
|
|
|
showValidationWarnings: {
|
|
|
|
type: Boolean,
|
|
|
|
},
|
|
|
|
documentationUrl: {
|
|
|
|
type: String,
|
|
|
|
},
|
2022-05-23 08:56:15 -07:00
|
|
|
eventSource: {
|
|
|
|
type: String,
|
|
|
|
},
|
2021-09-11 01:15:36 -07:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-10-27 12:55:37 -07:00
|
|
|
focused: false,
|
|
|
|
blurredEver: false,
|
2022-07-20 04:32:51 -07:00
|
|
|
menuExpanded: false,
|
2021-09-11 01:15:36 -07:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2022-12-14 01:04:10 -08:00
|
|
|
...mapStores(useWorkflowsStore),
|
2021-09-11 01:15:36 -07:00
|
|
|
showRequiredErrors(): boolean {
|
2021-10-09 11:42:30 -07:00
|
|
|
if (!this.$props.parameter.required) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-10-27 12:55:37 -07:00
|
|
|
if (this.blurredEver || this.showValidationWarnings) {
|
2021-10-09 11:42:30 -07:00
|
|
|
if (this.$props.parameter.type === 'string') {
|
|
|
|
return !this.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.$props.parameter.type === 'number') {
|
|
|
|
return typeof this.value !== 'number';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-09-11 01:15:36 -07:00
|
|
|
},
|
2022-10-12 05:06:28 -07:00
|
|
|
hint(): string | null {
|
|
|
|
if (this.isValueExpression) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.$locale.credText().hint(this.parameter);
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
isValueExpression(): boolean {
|
|
|
|
return isValueExpression(
|
|
|
|
this.parameter,
|
|
|
|
this.value as string | INodeParameterResourceLocator,
|
|
|
|
);
|
2022-09-21 06:44:45 -07:00
|
|
|
},
|
2021-09-11 01:15:36 -07:00
|
|
|
},
|
|
|
|
methods: {
|
2021-10-27 12:55:37 -07:00
|
|
|
onFocus() {
|
|
|
|
this.focused = true;
|
|
|
|
},
|
2021-09-11 01:15:36 -07:00
|
|
|
onBlur() {
|
2021-10-27 12:55:37 -07:00
|
|
|
this.blurredEver = true;
|
|
|
|
this.focused = false;
|
2021-09-11 01:15:36 -07:00
|
|
|
},
|
2022-07-20 04:32:51 -07:00
|
|
|
onMenuExpanded(expanded: boolean) {
|
|
|
|
this.menuExpanded = expanded;
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
optionSelected(command: string) {
|
2022-07-20 04:32:51 -07:00
|
|
|
if (this.$refs.param) {
|
|
|
|
(this.$refs.param as Vue).$emit('optionSelected', command);
|
|
|
|
}
|
|
|
|
},
|
2021-09-11 01:15:36 -07:00
|
|
|
valueChanged(parameterData: IUpdateInformation) {
|
|
|
|
this.$emit('change', parameterData);
|
|
|
|
},
|
2022-12-14 01:04:10 -08:00
|
|
|
onDocumentationUrlClick(): void {
|
2021-10-18 20:57:49 -07:00
|
|
|
this.$telemetry.track('User clicked credential modal docs link', {
|
|
|
|
docs_link: this.documentationUrl,
|
|
|
|
source: 'field',
|
2022-11-04 06:04:31 -07:00
|
|
|
workflow_id: this.workflowsStore.workflowId,
|
2021-10-18 20:57:49 -07:00
|
|
|
});
|
|
|
|
},
|
2021-09-11 01:15:36 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
2022-01-27 22:55:25 -08:00
|
|
|
|
|
|
|
<style lang="scss" module>
|
2022-12-14 01:04:10 -08:00
|
|
|
.errors {
|
|
|
|
margin-top: var(--spacing-2xs);
|
|
|
|
}
|
|
|
|
.hint {
|
|
|
|
margin-top: var(--spacing-4xs);
|
|
|
|
}
|
2022-01-27 22:55:25 -08:00
|
|
|
</style>
|