mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 16:44:07 -08:00
chore(editor): Delete some of the unused code (no-changelog) (#11554)
This commit is contained in:
parent
1f25e8e096
commit
38da319507
|
@ -1,40 +0,0 @@
|
||||||
<script lang="ts" setup>
|
|
||||||
import { computed } from 'vue';
|
|
||||||
import TagsContainer from './TagsContainer.vue';
|
|
||||||
import { useAnnotationTagsStore } from '@/stores/tags.store';
|
|
||||||
import type { ITag } from '@/Interface';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
tagIds: string[];
|
|
||||||
limit?: number;
|
|
||||||
clickable?: boolean;
|
|
||||||
responsive?: boolean;
|
|
||||||
hoverable?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
defineProps<Props>();
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
click: [tagId: string];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const annotationTagsStore = useAnnotationTagsStore();
|
|
||||||
|
|
||||||
const tagsById = computed<Record<string, ITag>>(() => annotationTagsStore.tagsById);
|
|
||||||
|
|
||||||
function onClick(tagId: string) {
|
|
||||||
emit('click', tagId);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<TagsContainer
|
|
||||||
:tag-ids="tagIds"
|
|
||||||
:tags-by-id="tagsById"
|
|
||||||
:limit="limit"
|
|
||||||
:clickable="clickable"
|
|
||||||
:responsive="responsive"
|
|
||||||
:hoverable="hoverable"
|
|
||||||
@click="onClick"
|
|
||||||
/>
|
|
||||||
</template>
|
|
|
@ -1,57 +0,0 @@
|
||||||
import RBAC from '@/components/RBAC.vue';
|
|
||||||
import { createComponentRenderer } from '@/__tests__/render';
|
|
||||||
import { useRBACStore } from '@/stores/rbac.store';
|
|
||||||
|
|
||||||
const renderComponent = createComponentRenderer(RBAC);
|
|
||||||
|
|
||||||
vi.mock('vue-router', () => ({
|
|
||||||
useRoute: vi.fn(() => ({
|
|
||||||
path: '/workflows',
|
|
||||||
params: {},
|
|
||||||
})),
|
|
||||||
RouterLink: vi.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock('@/stores/rbac.store', () => ({
|
|
||||||
useRBACStore: vi.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('RBAC', () => {
|
|
||||||
it('renders default slot when hasScope is true', async () => {
|
|
||||||
vi.mocked(useRBACStore).mockImplementation(
|
|
||||||
() =>
|
|
||||||
({
|
|
||||||
hasScope: () => true,
|
|
||||||
}) as unknown as ReturnType<typeof useRBACStore>,
|
|
||||||
);
|
|
||||||
|
|
||||||
const wrapper = renderComponent({
|
|
||||||
props: { scope: 'worfklow:list' },
|
|
||||||
slots: {
|
|
||||||
default: 'Default Content',
|
|
||||||
fallback: 'Fallback Content',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.getByText('Default Content')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('renders fallback slot when hasScope is false', async () => {
|
|
||||||
vi.mocked(useRBACStore).mockImplementation(
|
|
||||||
() =>
|
|
||||||
({
|
|
||||||
hasScope: () => false,
|
|
||||||
}) as unknown as ReturnType<typeof useRBACStore>,
|
|
||||||
);
|
|
||||||
|
|
||||||
const wrapper = renderComponent({
|
|
||||||
props: { scope: 'worfklow:list' },
|
|
||||||
slots: {
|
|
||||||
default: 'Default Content',
|
|
||||||
fallback: 'Fallback Content',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.getByText('Fallback Content')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,61 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
import type { PropType } from 'vue';
|
|
||||||
import { computed, defineComponent } from 'vue';
|
|
||||||
import { useRBACStore } from '@/stores/rbac.store';
|
|
||||||
import type { ScopeMode, Scope, Resource } from '@n8n/permissions';
|
|
||||||
import {
|
|
||||||
inferProjectIdFromRoute,
|
|
||||||
inferResourceIdFromRoute,
|
|
||||||
inferResourceTypeFromRoute,
|
|
||||||
} from '@/utils/rbacUtils';
|
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
props: {
|
|
||||||
scope: {
|
|
||||||
type: [String, Array] as PropType<Scope | Scope[]>,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
mode: {
|
|
||||||
type: String as PropType<ScopeMode>,
|
|
||||||
default: 'allOf',
|
|
||||||
},
|
|
||||||
resourceType: {
|
|
||||||
type: String as PropType<Resource>,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
resourceId: {
|
|
||||||
type: String,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
projectId: {
|
|
||||||
type: String,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
setup(props, { slots }) {
|
|
||||||
const rbacStore = useRBACStore();
|
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
const hasScope = computed(() => {
|
|
||||||
const projectId = props.projectId ?? inferProjectIdFromRoute(route);
|
|
||||||
const resourceType = props.resourceType ?? inferResourceTypeFromRoute(route);
|
|
||||||
const resourceId = resourceType
|
|
||||||
? (props.resourceId ?? inferResourceIdFromRoute(route))
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return rbacStore.hasScope(
|
|
||||||
props.scope,
|
|
||||||
{
|
|
||||||
projectId,
|
|
||||||
resourceType,
|
|
||||||
resourceId,
|
|
||||||
},
|
|
||||||
{ mode: props.mode },
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => (hasScope.value ? slots.default?.() : slots.fallback?.());
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -4,7 +4,7 @@ import { useCanvasNode } from '@/composables/useCanvasNode';
|
||||||
import type { CanvasNodeStickyNoteRender } from '@/types';
|
import type { CanvasNodeStickyNoteRender } from '@/types';
|
||||||
import { ref, computed, useCssModule, onMounted, onBeforeUnmount } from 'vue';
|
import { ref, computed, useCssModule, onMounted, onBeforeUnmount } from 'vue';
|
||||||
import { NodeResizer } from '@vue-flow/node-resizer';
|
import { NodeResizer } from '@vue-flow/node-resizer';
|
||||||
import type { OnResize } from '@vue-flow/node-resizer/dist/types';
|
import type { OnResize } from '@vue-flow/node-resizer';
|
||||||
import type { XYPosition } from '@vue-flow/core';
|
import type { XYPosition } from '@vue-flow/core';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
|
|
|
@ -6,7 +6,6 @@ import ElementPlus, { ElLoading, ElMessageBox } from 'element-plus';
|
||||||
import { N8nPlugin } from 'n8n-design-system';
|
import { N8nPlugin } from 'n8n-design-system';
|
||||||
import { useMessage } from '@/composables/useMessage';
|
import { useMessage } from '@/composables/useMessage';
|
||||||
import EnterpriseEdition from '@/components/EnterpriseEdition.ee.vue';
|
import EnterpriseEdition from '@/components/EnterpriseEdition.ee.vue';
|
||||||
import RBAC from '@/components/RBAC.vue';
|
|
||||||
import ParameterInputList from '@/components/ParameterInputList.vue';
|
import ParameterInputList from '@/components/ParameterInputList.vue';
|
||||||
|
|
||||||
export const GlobalComponentsPlugin: Plugin = {
|
export const GlobalComponentsPlugin: Plugin = {
|
||||||
|
@ -14,7 +13,6 @@ export const GlobalComponentsPlugin: Plugin = {
|
||||||
const messageService = useMessage();
|
const messageService = useMessage();
|
||||||
|
|
||||||
app.component('EnterpriseEdition', EnterpriseEdition);
|
app.component('EnterpriseEdition', EnterpriseEdition);
|
||||||
app.component('RBAC', RBAC);
|
|
||||||
app.component('ParameterInputList', ParameterInputList);
|
app.component('ParameterInputList', ParameterInputList);
|
||||||
|
|
||||||
app.use(ElementPlus);
|
app.use(ElementPlus);
|
||||||
|
|
Loading…
Reference in a new issue