feat: RBAC (#8922)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: Val <68596159+valya@users.noreply.github.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Valya Bullions <valya@n8n.io> Co-authored-by: Danny Martini <danny@n8n.io> Co-authored-by: Danny Martini <despair.blue@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Ayato Hayashi <go12limchangyong@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
icon="filter"
|
||||
type="tertiary"
|
||||
:active="hasFilters"
|
||||
:class="[$style['filter-button'], 'ml-2xs']"
|
||||
:class="$style['filter-button']"
|
||||
data-test-id="resources-list-filters-trigger"
|
||||
>
|
||||
<n8n-badge v-show="filtersLength > 0" theme="primary" class="mr-4xs">
|
||||
@@ -17,39 +17,22 @@
|
||||
<div :class="$style['filters-dropdown']" data-test-id="resources-list-filters-dropdown">
|
||||
<slot :filters="modelValue" :set-key-value="setKeyValue" />
|
||||
<enterprise-edition
|
||||
v-if="shareable"
|
||||
class="mb-s"
|
||||
v-if="shareable && projectsStore.isProjectHome"
|
||||
:features="[EnterpriseEditionFeature.Sharing]"
|
||||
>
|
||||
<n8n-input-label
|
||||
:label="$locale.baseText('forms.resourceFiltersDropdown.ownedBy')"
|
||||
:label="$locale.baseText('forms.resourceFiltersDropdown.owner')"
|
||||
:bold="false"
|
||||
size="small"
|
||||
color="text-base"
|
||||
class="mb-3xs"
|
||||
/>
|
||||
<n8n-user-select
|
||||
:users="ownedByUsers"
|
||||
:current-user-id="usersStore.currentUser.id"
|
||||
:model-value="modelValue.ownedBy"
|
||||
size="medium"
|
||||
@update:model-value="setKeyValue('ownedBy', $event)"
|
||||
/>
|
||||
</enterprise-edition>
|
||||
<enterprise-edition v-if="shareable" :features="[EnterpriseEditionFeature.Sharing]">
|
||||
<n8n-input-label
|
||||
:label="$locale.baseText('forms.resourceFiltersDropdown.sharedWith')"
|
||||
:bold="false"
|
||||
size="small"
|
||||
color="text-base"
|
||||
class="mb-3xs"
|
||||
/>
|
||||
<n8n-user-select
|
||||
:users="sharedWithUsers"
|
||||
:current-user-id="usersStore.currentUser.id"
|
||||
:model-value="modelValue.sharedWith"
|
||||
size="medium"
|
||||
@update:model-value="setKeyValue('sharedWith', $event)"
|
||||
<ProjectSharing
|
||||
v-model="selectedProject"
|
||||
class="pt-2xs"
|
||||
:projects="projectsStore.projects"
|
||||
:placeholder="$locale.baseText('forms.resourceFiltersDropdown.owner.placeholder')"
|
||||
@update:model-value="setKeyValue('homeProject', ($event as ProjectSharingData).id)"
|
||||
/>
|
||||
</enterprise-edition>
|
||||
<div v-if="hasFilters" :class="[$style['filters-dropdown-footer'], 'mt-s']">
|
||||
@@ -65,13 +48,17 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { useProjectsStore } from '@/features/projects/projects.store';
|
||||
import type { PropType } from 'vue';
|
||||
import type { IUser } from '@/Interface';
|
||||
import type { ProjectSharingData } from '@/features/projects/projects.types';
|
||||
import ProjectSharing from '@/features/projects/components/ProjectSharing.vue';
|
||||
|
||||
export type IResourceFiltersType = Record<string, boolean | string | string[]>;
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
ProjectSharing,
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
type: Object as PropType<IResourceFiltersType>,
|
||||
@@ -87,25 +74,17 @@ export default defineComponent({
|
||||
},
|
||||
reset: {
|
||||
type: Function as PropType<() => void>,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
EnterpriseEditionFeature,
|
||||
selectedProject: null as ProjectSharingData | null,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapStores(useUsersStore),
|
||||
ownedByUsers(): IUser[] {
|
||||
return this.usersStore.allUsers.map((user) =>
|
||||
user.id === this.modelValue.sharedWith ? { ...user, disabled: true } : user,
|
||||
);
|
||||
},
|
||||
sharedWithUsers(): IUser[] {
|
||||
return this.usersStore.allUsers.map((user) =>
|
||||
user.id === this.modelValue.ownedBy ? { ...user, disabled: true } : user,
|
||||
);
|
||||
},
|
||||
...mapStores(useProjectsStore),
|
||||
filtersLength(): number {
|
||||
let length = 0;
|
||||
|
||||
@@ -134,6 +113,12 @@ export default defineComponent({
|
||||
this.$emit('update:filtersLength', value);
|
||||
},
|
||||
},
|
||||
async beforeMount() {
|
||||
await this.projectsStore.getAllProjects();
|
||||
this.selectedProject =
|
||||
this.projectsStore.projects.find((project) => project.id === this.modelValue.homeProject) ??
|
||||
null;
|
||||
},
|
||||
methods: {
|
||||
setKeyValue(key: string, value: unknown) {
|
||||
const filters = {
|
||||
@@ -155,6 +140,7 @@ export default defineComponent({
|
||||
|
||||
this.$emit('update:modelValue', filters);
|
||||
}
|
||||
this.selectedProject = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<template>
|
||||
<div class="resource-ownership-select">
|
||||
<n8n-menu
|
||||
:items="menuItems"
|
||||
mode="tabs"
|
||||
:model-value="value ? 'owner' : 'all'"
|
||||
@update:model-value="onSelectOwner"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import type { IMenuItem } from 'n8n-design-system';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
value: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
myResourcesLabel: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
allResourcesLabel: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
menuItems(): IMenuItem[] {
|
||||
return [
|
||||
{
|
||||
id: 'all',
|
||||
icon: 'globe-americas',
|
||||
label: this.allResourcesLabel,
|
||||
position: 'top',
|
||||
},
|
||||
{
|
||||
id: 'owner',
|
||||
icon: 'user',
|
||||
label: this.myResourcesLabel,
|
||||
position: 'top',
|
||||
},
|
||||
];
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onSelectOwner(type: string) {
|
||||
this.$emit('update:modelValue', type === 'owner');
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.menu-container {
|
||||
--menu-background: transparent;
|
||||
--menu-padding: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user