diff --git a/packages/editor-ui/src/components/MainHeader/MainHeader.vue b/packages/editor-ui/src/components/MainHeader/MainHeader.vue index b586e9722cf26..0625d2ff2c5f2 100644 --- a/packages/editor-ui/src/components/MainHeader/MainHeader.vue +++ b/packages/editor-ui/src/components/MainHeader/MainHeader.vue @@ -164,7 +164,16 @@ async function navigateToExecutionsView(openInNewTab: boolean) {
- + { it('renders workflow name and tags', async () => { const { getByTestId, getByText } = renderComponent({ props: { - workflow, + ...workflow, readOnly: false, }, }); @@ -76,7 +76,7 @@ describe('WorkflowDetails', () => { const onSaveButtonClick = vi.fn(); const { getByTestId } = renderComponent({ props: { - workflow, + ...workflow, readOnly: false, }, global: { @@ -95,7 +95,7 @@ describe('WorkflowDetails', () => { const { getByTestId } = renderComponent({ props: { - workflow, + ...workflow, readOnly: false, }, }); diff --git a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue index de687771d8cf4..36d18eae1ce10 100644 --- a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue +++ b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue @@ -58,8 +58,13 @@ import { useNpsSurveyStore } from '@/stores/npsSurvey.store'; import { useLocalStorage } from '@vueuse/core'; const props = defineProps<{ - workflow: IWorkflowDb; readOnly?: boolean; + id: IWorkflowDb['id']; + tags: IWorkflowDb['tags']; + name: IWorkflowDb['name']; + meta: IWorkflowDb['meta']; + scopes: IWorkflowDb['scopes']; + active: IWorkflowDb['active']; }>(); const $style = useCssModule(); @@ -115,11 +120,7 @@ const hasChanged = (prev: string[], curr: string[]) => { }; const isNewWorkflow = computed(() => { - return ( - !props.workflow.id || - props.workflow.id === PLACEHOLDER_EMPTY_WORKFLOW_ID || - props.workflow.id === 'new' - ); + return !props.id || props.id === PLACEHOLDER_EMPTY_WORKFLOW_ID || props.id === 'new'; }); const isWorkflowSaving = computed(() => { @@ -138,9 +139,7 @@ const onExecutionsTab = computed(() => { ].includes((route.name as string) || ''); }); -const workflowPermissions = computed( - () => getResourcePermissions(workflowsStore.getWorkflowById(props.workflow.id)?.scopes).workflow, -); +const workflowPermissions = computed(() => getResourcePermissions(props.scopes).workflow); const workflowMenuItems = computed(() => { const actions: ActionDropdownItem[] = [ @@ -155,7 +154,7 @@ const workflowMenuItems = computed(() => { actions.unshift({ id: WORKFLOW_MENU_ACTIONS.DUPLICATE, label: locale.baseText('menuActions.duplicate'), - disabled: !onWorkflowPage.value || !props.workflow.id, + disabled: !onWorkflowPage.value || !props.id, }); actions.push( @@ -219,11 +218,11 @@ const isWorkflowHistoryFeatureEnabled = computed(() => { }); const workflowTagIds = computed(() => { - return (props.workflow.tags ?? []).map((tag) => (typeof tag === 'string' ? tag : tag.id)); + return (props.tags ?? []).map((tag) => (typeof tag === 'string' ? tag : tag.id)); }); watch( - () => props.workflow.id, + () => props.id, () => { isTagsEditEnabled.value = false; isNameEditEnabled.value = false; @@ -232,8 +231,8 @@ watch( function getWorkflowId(): string | undefined { let id: string | undefined = undefined; - if (props.workflow.id !== PLACEHOLDER_EMPTY_WORKFLOW_ID) { - id = props.workflow.id; + if (props.id !== PLACEHOLDER_EMPTY_WORKFLOW_ID) { + id = props.id; } else if (route.params.name && route.params.name !== 'new') { id = route.params.name as string; } @@ -249,8 +248,8 @@ async function onSaveButtonClick() { const id = getWorkflowId(); - const name = props.workflow.name; - const tags = props.workflow.tags as string[]; + const name = props.name; + const tags = props.tags as string[]; const saved = await workflowHelpers.saveCurrentWorkflow({ id, @@ -266,7 +265,7 @@ async function onSaveButtonClick() { if (route.name === VIEWS.EXECUTION_DEBUG) { await router.replace({ name: VIEWS.WORKFLOW, - params: { name: props.workflow.id }, + params: { name: props.id }, }); } } @@ -275,18 +274,18 @@ async function onSaveButtonClick() { function onShareButtonClick() { uiStore.openModalWithData({ name: WORKFLOW_SHARE_MODAL_KEY, - data: { id: props.workflow.id }, + data: { id: props.id }, }); telemetry.track('User opened sharing modal', { - workflow_id: props.workflow.id, + workflow_id: props.id, user_id_sharer: usersStore.currentUser?.id, sub_view: route.name === VIEWS.WORKFLOWS ? 'Workflows listing' : 'Workflow editor', }); } function onTagsEditEnable() { - appliedTagIds.value = (props.workflow.tags ?? []) as string[]; + appliedTagIds.value = (props.tags ?? []) as string[]; isTagsEditEnabled.value = true; setTimeout(() => { @@ -297,7 +296,7 @@ function onTagsEditEnable() { } async function onTagsBlur() { - const current = (props.workflow.tags ?? []) as string[]; + const current = (props.tags ?? []) as string[]; const tags = appliedTagIds.value; if (!hasChanged(current, tags)) { isTagsEditEnabled.value = false; @@ -311,7 +310,7 @@ async function onTagsBlur() { const saved = await workflowHelpers.saveCurrentWorkflow({ tags }); telemetry.track('User edited workflow tags', { - workflow_id: props.workflow.id, + workflow_id: props.id, new_tag_count: tags.length, }); @@ -355,7 +354,7 @@ async function onNameSubmit({ return; } - if (newName === props.workflow.name) { + if (newName === props.name) { isNameEditEnabled.value = false; onSubmit(true); @@ -405,9 +404,9 @@ async function onWorkflowMenuSelect(action: WORKFLOW_MENU_ACTIONS): Promise { @@ -432,7 +431,7 @@ async function onWorkflowMenuSelect(action: WORKFLOW_MENU_ACTIONS): Promise