mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-24 23:22:38 +08:00
fix(core): Publish indicator not shown when lacking publish scope (no-changelog) (#24266)
This commit is contained in:
+21
-1
@@ -140,6 +140,7 @@ describe('WorkflowHeaderDraftPublishActions', () => {
|
||||
|
||||
const { queryByTestId } = renderComponent();
|
||||
|
||||
expect(queryByTestId('workflow-active-version-info')).not.toBeInTheDocument();
|
||||
expect(queryByTestId('workflow-active-version-indicator')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -148,6 +149,7 @@ describe('WorkflowHeaderDraftPublishActions', () => {
|
||||
|
||||
const { getByTestId } = renderComponent();
|
||||
|
||||
expect(getByTestId('workflow-active-version-info')).toBeInTheDocument();
|
||||
expect(getByTestId('workflow-active-version-indicator')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -199,9 +201,27 @@ describe('WorkflowHeaderDraftPublishActions', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(getByTestId('workflow-active-version-indicator')).toBeInTheDocument();
|
||||
expect(getByTestId('workflow-active-version-info')).toBeInTheDocument();
|
||||
expect(getByTestId('time-ago-stub')).toHaveTextContent(latestActivationDate);
|
||||
});
|
||||
|
||||
it('should show active version indicator when user does not have workflow:publish permission but workflow is currently published', () => {
|
||||
workflowsStore.workflow.activeVersion = createMockActiveVersion('active-version-1');
|
||||
const { getByTestId } = renderComponent({
|
||||
props: {
|
||||
...defaultWorkflowProps,
|
||||
readOnly: false,
|
||||
workflowPermissions: {
|
||||
...defaultWorkflowProps.workflowPermissions,
|
||||
update: true,
|
||||
publish: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(getByTestId('workflow-active-version-indicator')).toBeInTheDocument();
|
||||
expect(getByTestId('workflow-active-version-info')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Publish button visibility', () => {
|
||||
|
||||
+14
-2
@@ -150,7 +150,7 @@ const onPublishButtonClick = async () => {
|
||||
const publishButtonConfig = computed(() => {
|
||||
// Handle permission-denied state first
|
||||
if (!props.workflowPermissions.publish) {
|
||||
return {
|
||||
const defaultConfigForNoPermission = {
|
||||
text: i18n.baseText('workflows.publish'),
|
||||
enabled: false,
|
||||
showIndicator: false,
|
||||
@@ -158,6 +158,17 @@ const publishButtonConfig = computed(() => {
|
||||
tooltip: i18n.baseText('workflows.publish.permissionDenied'),
|
||||
showVersionInfo: false,
|
||||
};
|
||||
const isWorkflowPublished = !!workflowsStore.workflow.activeVersion;
|
||||
if (isWorkflowPublished) {
|
||||
return {
|
||||
...defaultConfigForNoPermission,
|
||||
showIndicator: true,
|
||||
showVersionInfo: true,
|
||||
indicatorClass: 'published',
|
||||
};
|
||||
} else {
|
||||
return defaultConfigForNoPermission;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle new workflow state
|
||||
@@ -288,7 +299,7 @@ defineExpose({
|
||||
{{ publishButtonConfig.tooltip }} <br />
|
||||
</template>
|
||||
<template v-if="activeVersion && publishButtonConfig.showVersionInfo">
|
||||
<span data-test-id="workflow-active-version-indicator">{{ activeVersionName }}</span
|
||||
<span data-test-id="workflow-active-version-info">{{ activeVersionName }}</span
|
||||
><br />{{ i18n.baseText('workflowHistory.item.active') }}
|
||||
<TimeAgo v-if="latestPublishDate" :date="latestPublishDate" />
|
||||
</template>
|
||||
@@ -304,6 +315,7 @@ defineExpose({
|
||||
<div :class="[$style.flex]">
|
||||
<span
|
||||
v-if="publishButtonConfig.showIndicator"
|
||||
data-test-id="workflow-active-version-indicator"
|
||||
:class="{
|
||||
[$style.indicatorDot]: true,
|
||||
[$style.indicatorPublished]: publishButtonConfig.indicatorClass === 'published',
|
||||
|
||||
Reference in New Issue
Block a user