fix(editor): Update tags filter/editor to not show non existing tag as a selectable option (#10297)

This commit is contained in:
Csaba Tuncsik 2024-08-06 15:29:55 +02:00 committed by GitHub
parent 74554d21d7
commit 557a76ec23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 10 deletions

View file

@ -1,4 +1,5 @@
import { WorkflowPage } from '../pages'; import { WorkflowPage } from '../pages';
import { getVisibleSelect } from '../utils';
const wf = new WorkflowPage(); const wf = new WorkflowPage();
@ -70,4 +71,20 @@ describe('Workflow tags', () => {
wf.getters.workflowTags().click(); wf.getters.workflowTags().click();
wf.getters.tagPills().should('have.length', TEST_TAGS.length - 1); wf.getters.tagPills().should('have.length', TEST_TAGS.length - 1);
}); });
it('should not show non existing tag as a selectable option', () => {
const NON_EXISTING_TAG = 'My Test Tag';
wf.getters.createTagButton().click();
wf.actions.addTags(TEST_TAGS);
cy.get('body').click(0, 0);
wf.getters.workflowTags().click();
wf.getters.tagsDropdown().find('input:focus').type(NON_EXISTING_TAG);
getVisibleSelect()
.find('li')
.should('have.length', 2)
.filter(`:contains("${NON_EXISTING_TAG}")`)
.should('not.have.length');
});
}); });

View file

@ -639,7 +639,6 @@ function showCreateWorkflowSuccessToast(id?: string) {
v-if="isTagsEditEnabled && !readOnly" v-if="isTagsEditEnabled && !readOnly"
ref="dropdown" ref="dropdown"
v-model="appliedTagIds" v-model="appliedTagIds"
:create-enabled="true"
:event-bus="tagsEventBus" :event-bus="tagsEventBus"
:placeholder="$locale.baseText('workflowDetails.chooseOrCreateATag')" :placeholder="$locale.baseText('workflowDetails.chooseOrCreateATag')"
class="tags-edit" class="tags-edit"

View file

@ -13,7 +13,6 @@
:filter-method="filterOptions" :filter-method="filterOptions"
filterable filterable
multiple multiple
:allow-create="createEnabled"
:reserve-keyword="false" :reserve-keyword="false"
loading-text="..." loading-text="..."
popper-class="tags-dropdown" popper-class="tags-dropdown"
@ -23,7 +22,7 @@
@remove-tag="onRemoveTag" @remove-tag="onRemoveTag"
> >
<n8n-option <n8n-option
v-if="options.length === 0 && filter && createEnabled" v-if="options.length === 0 && filter"
:key="CREATE_KEY" :key="CREATE_KEY"
ref="createRef" ref="createRef"
:value="CREATE_KEY" :value="CREATE_KEY"
@ -35,11 +34,11 @@
</span> </span>
</n8n-option> </n8n-option>
<n8n-option v-else-if="options.length === 0" value="message" disabled> <n8n-option v-else-if="options.length === 0" value="message" disabled>
<span v-if="createEnabled">{{ i18n.baseText('tagsDropdown.typeToCreateATag') }}</span> <span>{{ i18n.baseText('tagsDropdown.typeToCreateATag') }}</span>
<span v-else-if="allTags.length > 0">{{ <span v-if="allTags.length > 0">{{
i18n.baseText('tagsDropdown.noMatchingTagsExist') i18n.baseText('tagsDropdown.noMatchingTagsExist')
}}</span> }}</span>
<span v-else>{{ i18n.baseText('tagsDropdown.noTagsExist') }}</span> <span v-else-if="filter">{{ i18n.baseText('tagsDropdown.noTagsExist') }}</span>
</n8n-option> </n8n-option>
<!-- key is id+index for keyboard navigation to work well with filter --> <!-- key is id+index for keyboard navigation to work well with filter -->
@ -90,10 +89,6 @@ export default defineComponent({
type: Array as PropType<string[]>, type: Array as PropType<string[]>,
default: () => [], default: () => [],
}, },
createEnabled: {
type: Boolean,
default: false,
},
eventBus: { eventBus: {
type: Object as PropType<EventBus>, type: Object as PropType<EventBus>,
default: null, default: null,