mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 20:00:02 +00:00
refactor(editor): Apply Prettier (no-changelog) (#4920)
* ⚡ Adjust `format` script * 🔥 Remove exemption for `editor-ui` * 🎨 Prettify * 👕 Fix lint
This commit is contained in:
@@ -8,7 +8,12 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-xs mb-l">
|
||||
<n8n-button size="large" block @click="$emit('click:add', $event)" data-test-id="resources-list-add">
|
||||
<n8n-button
|
||||
size="large"
|
||||
block
|
||||
@click="$emit('click:add', $event)"
|
||||
data-test-id="resources-list-add"
|
||||
>
|
||||
{{ $locale.baseText(`${resourceKey}.add`) }}
|
||||
</n8n-button>
|
||||
</div>
|
||||
@@ -23,9 +28,9 @@
|
||||
</template>
|
||||
|
||||
<div v-if="loading">
|
||||
<n8n-loading :class="[$style['header-loading'], 'mb-l']" variant="custom"/>
|
||||
<n8n-loading :class="[$style['card-loading'], 'mb-2xs']" variant="custom"/>
|
||||
<n8n-loading :class="$style['card-loading']" variant="custom"/>
|
||||
<n8n-loading :class="[$style['header-loading'], 'mb-l']" variant="custom" />
|
||||
<n8n-loading :class="[$style['card-loading'], 'mb-2xs']" variant="custom" />
|
||||
<n8n-loading :class="$style['card-loading']" variant="custom" />
|
||||
</div>
|
||||
<template v-else>
|
||||
<div class="ph-no-capture" v-if="resources.length === 0">
|
||||
@@ -33,9 +38,16 @@
|
||||
<n8n-action-box
|
||||
data-test-id="empty-resources-list"
|
||||
emoji="👋"
|
||||
:heading="$locale.baseText(usersStore.currentUser.firstName ? `${resourceKey}.empty.heading` : `${resourceKey}.empty.heading.userNotSetup`, {
|
||||
interpolate: { name: usersStore.currentUser.firstName }
|
||||
})"
|
||||
:heading="
|
||||
$locale.baseText(
|
||||
usersStore.currentUser.firstName
|
||||
? `${resourceKey}.empty.heading`
|
||||
: `${resourceKey}.empty.heading.userNotSetup`,
|
||||
{
|
||||
interpolate: { name: usersStore.currentUser.firstName },
|
||||
},
|
||||
)
|
||||
"
|
||||
:description="$locale.baseText(`${resourceKey}.empty.description`)"
|
||||
:buttonText="$locale.baseText(`${resourceKey}.empty.button`)"
|
||||
buttonType="secondary"
|
||||
@@ -57,19 +69,27 @@
|
||||
data-test-id="resources-list-search"
|
||||
>
|
||||
<template #prefix>
|
||||
<n8n-icon icon="search"/>
|
||||
<n8n-icon icon="search" />
|
||||
</template>
|
||||
</n8n-input>
|
||||
<div :class="$style['sort-and-filter']">
|
||||
<n8n-select
|
||||
v-model="sortBy"
|
||||
size="medium"
|
||||
data-test-id="resources-list-sort"
|
||||
>
|
||||
<n8n-option value="lastUpdated" :label="$locale.baseText(`${resourceKey}.sort.lastUpdated`)"/>
|
||||
<n8n-option value="lastCreated" :label="$locale.baseText(`${resourceKey}.sort.lastCreated`)"/>
|
||||
<n8n-option value="nameAsc" :label="$locale.baseText(`${resourceKey}.sort.nameAsc`)"/>
|
||||
<n8n-option value="nameDesc" :label="$locale.baseText(`${resourceKey}.sort.nameDesc`)"/>
|
||||
<n8n-select v-model="sortBy" size="medium" data-test-id="resources-list-sort">
|
||||
<n8n-option
|
||||
value="lastUpdated"
|
||||
:label="$locale.baseText(`${resourceKey}.sort.lastUpdated`)"
|
||||
/>
|
||||
<n8n-option
|
||||
value="lastCreated"
|
||||
:label="$locale.baseText(`${resourceKey}.sort.lastCreated`)"
|
||||
/>
|
||||
<n8n-option
|
||||
value="nameAsc"
|
||||
:label="$locale.baseText(`${resourceKey}.sort.nameAsc`)"
|
||||
/>
|
||||
<n8n-option
|
||||
value="nameDesc"
|
||||
:label="$locale.baseText(`${resourceKey}.sort.nameDesc`)"
|
||||
/>
|
||||
</n8n-select>
|
||||
<resource-filters-dropdown
|
||||
:keys="filterKeys"
|
||||
@@ -98,8 +118,17 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-xs mb-l">
|
||||
<ul :class="[$style.list, 'list-style-none']" v-if="filteredAndSortedSubviewResources.length > 0" data-test-id="resources-list">
|
||||
<li v-for="resource in filteredAndSortedSubviewResources" :key="resource.id" class="mb-2xs" data-test-id="resources-list-item">
|
||||
<ul
|
||||
:class="[$style.list, 'list-style-none']"
|
||||
v-if="filteredAndSortedSubviewResources.length > 0"
|
||||
data-test-id="resources-list"
|
||||
>
|
||||
<li
|
||||
v-for="resource in filteredAndSortedSubviewResources"
|
||||
:key="resource.id"
|
||||
class="mb-2xs"
|
||||
data-test-id="resources-list-item"
|
||||
>
|
||||
<slot :data="resource" />
|
||||
</li>
|
||||
</ul>
|
||||
@@ -108,11 +137,19 @@
|
||||
<template v-if="shouldSwitchToAllSubview">
|
||||
<span v-if="!filters.search">
|
||||
({{ $locale.baseText(`${resourceKey}.noResults.switchToShared.preamble`) }}
|
||||
<n8n-link @click="setOwnerSubview(false)">{{$locale.baseText(`${resourceKey}.noResults.switchToShared.link`) }}</n8n-link>)
|
||||
<n8n-link @click="setOwnerSubview(false)">{{
|
||||
$locale.baseText(`${resourceKey}.noResults.switchToShared.link`)
|
||||
}}</n8n-link
|
||||
>)
|
||||
</span>
|
||||
<span v-else>
|
||||
({{ $locale.baseText(`${resourceKey}.noResults.withSearch.switchToShared.preamble`) }}
|
||||
<n8n-link @click="setOwnerSubview(false)">{{$locale.baseText(`${resourceKey}.noResults.withSearch.switchToShared.link`) }}</n8n-link>)
|
||||
({{
|
||||
$locale.baseText(`${resourceKey}.noResults.withSearch.switchToShared.preamble`)
|
||||
}}
|
||||
<n8n-link @click="setOwnerSubview(false)">{{
|
||||
$locale.baseText(`${resourceKey}.noResults.withSearch.switchToShared.link`)
|
||||
}}</n8n-link
|
||||
>)
|
||||
</span>
|
||||
</template>
|
||||
</n8n-text>
|
||||
@@ -123,18 +160,18 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {showMessage} from '@/mixins/showMessage';
|
||||
import {IUser} from '@/Interface';
|
||||
import { showMessage } from '@/mixins/showMessage';
|
||||
import { IUser } from '@/Interface';
|
||||
import mixins from 'vue-typed-mixins';
|
||||
|
||||
import PageViewLayout from "@/components/layouts/PageViewLayout.vue";
|
||||
import PageViewLayoutList from "@/components/layouts/PageViewLayoutList.vue";
|
||||
import {EnterpriseEditionFeature} from "@/constants";
|
||||
import TemplateCard from "@/components/TemplateCard.vue";
|
||||
import Vue, {PropType} from "vue";
|
||||
import {debounceHelper} from '@/mixins/debounce';
|
||||
import ResourceOwnershipSelect from "@/components/forms/ResourceOwnershipSelect.ee.vue";
|
||||
import ResourceFiltersDropdown from "@/components/forms/ResourceFiltersDropdown.vue";
|
||||
import PageViewLayout from '@/components/layouts/PageViewLayout.vue';
|
||||
import PageViewLayoutList from '@/components/layouts/PageViewLayoutList.vue';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import TemplateCard from '@/components/TemplateCard.vue';
|
||||
import Vue, { PropType } from 'vue';
|
||||
import { debounceHelper } from '@/mixins/debounce';
|
||||
import ResourceOwnershipSelect from '@/components/forms/ResourceOwnershipSelect.ee.vue';
|
||||
import ResourceFiltersDropdown from '@/components/forms/ResourceFiltersDropdown.vue';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
import { useUsersStore } from '@/stores/users';
|
||||
@@ -160,10 +197,7 @@ type IResourceKeyType = 'credentials' | 'workflows';
|
||||
|
||||
const filterKeys = ['ownedBy', 'sharedWith'];
|
||||
|
||||
export default mixins(
|
||||
showMessage,
|
||||
debounceHelper,
|
||||
).extend({
|
||||
export default mixins(showMessage, debounceHelper).extend({
|
||||
name: 'resources-list-layout',
|
||||
components: {
|
||||
TemplateCard,
|
||||
@@ -212,17 +246,17 @@ export default mixins(
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapStores(
|
||||
useSettingsStore,
|
||||
useUsersStore,
|
||||
),
|
||||
...mapStores(useSettingsStore, useUsersStore),
|
||||
subviewResources(): IResource[] {
|
||||
if (!this.shareable) {
|
||||
return this.resources as IResource[];
|
||||
}
|
||||
|
||||
return (this.resources as IResource[]).filter((resource) => {
|
||||
if (this.isOwnerSubview && this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Sharing)) {
|
||||
if (
|
||||
this.isOwnerSubview &&
|
||||
this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Sharing)
|
||||
) {
|
||||
return !!(resource.ownedBy && resource.ownedBy.id === this.usersStore.currentUser?.id);
|
||||
}
|
||||
|
||||
@@ -241,7 +275,12 @@ export default mixins(
|
||||
}
|
||||
|
||||
if (this.filters.sharedWith) {
|
||||
matches = matches && !!(resource.sharedWith && resource.sharedWith.find((sharee) => sharee.id === this.filters.sharedWith));
|
||||
matches =
|
||||
matches &&
|
||||
!!(
|
||||
resource.sharedWith &&
|
||||
resource.sharedWith.find((sharee) => sharee.id === this.filters.sharedWith)
|
||||
);
|
||||
}
|
||||
|
||||
if (this.filters.search) {
|
||||
@@ -260,9 +299,9 @@ export default mixins(
|
||||
return filtered.sort((a, b) => {
|
||||
switch (this.sortBy) {
|
||||
case 'lastUpdated':
|
||||
return (new Date(b.updatedAt)).valueOf() - (new Date(a.updatedAt)).valueOf();
|
||||
return new Date(b.updatedAt).valueOf() - new Date(a.updatedAt).valueOf();
|
||||
case 'lastCreated':
|
||||
return (new Date(b.createdAt)).valueOf() - (new Date(a.createdAt)).valueOf();
|
||||
return new Date(b.createdAt).valueOf() - new Date(a.createdAt).valueOf();
|
||||
case 'nameAsc':
|
||||
return a.name.trim().localeCompare(b.name.trim());
|
||||
case 'nameDesc':
|
||||
@@ -305,7 +344,9 @@ export default mixins(
|
||||
this.isOwnerSubview = active;
|
||||
},
|
||||
getTelemetrySubview(): string {
|
||||
return this.$locale.baseText(`${this.resourceKey as IResourceKeyType}.menu.${this.isOwnerSubview ? 'my' : 'all'}`);
|
||||
return this.$locale.baseText(
|
||||
`${this.resourceKey as IResourceKeyType}.menu.${this.isOwnerSubview ? 'my' : 'all'}`,
|
||||
);
|
||||
},
|
||||
sendSubviewTelemetry() {
|
||||
this.$telemetry.track(`User changed ${this.resourceKey} sub view`, {
|
||||
@@ -326,7 +367,7 @@ export default mixins(
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(() => this.resettingFilters = false, 1500);
|
||||
setTimeout(() => (this.resettingFilters = false), 1500);
|
||||
}
|
||||
|
||||
const filters = this.filters as Record<string, string[] | string | boolean>;
|
||||
@@ -369,7 +410,7 @@ export default mixins(
|
||||
this.sendFiltersTelemetry('sharedWith');
|
||||
},
|
||||
'filters.search'() {
|
||||
this.callDebounced('sendFiltersTelemetry', {debounceTime: 1000, trailing: true}, 'search');
|
||||
this.callDebounced('sendFiltersTelemetry', { debounceTime: 1000, trailing: true }, 'search');
|
||||
},
|
||||
sortBy() {
|
||||
this.sendSortingTelemetry();
|
||||
|
||||
Reference in New Issue
Block a user