feat(editor): Show Collaboration pane only when there are multiple active users (#10772)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-09-11 18:18:19 +02:00 committed by GitHub
parent 755188897b
commit a0af1d9a06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 2 deletions

View file

@ -18,6 +18,8 @@ watch(visibility, (visibilityState) => {
} }
}); });
const showUserStack = computed(() => collaborationStore.collaborators.length > 1);
const collaboratorsSorted = computed(() => { const collaboratorsSorted = computed(() => {
const currentWorkflowUsers = collaborationStore.collaborators.map(({ user }) => user); const currentWorkflowUsers = collaborationStore.collaborators.map(({ user }) => user);
const owner = currentWorkflowUsers.find(isUserGlobalOwner); const owner = currentWorkflowUsers.find(isUserGlobalOwner);
@ -44,7 +46,11 @@ onBeforeUnmount(() => {
:class="`collaboration-pane-container ${$style.container}`" :class="`collaboration-pane-container ${$style.container}`"
data-test-id="collaboration-pane" data-test-id="collaboration-pane"
> >
<n8n-user-stack :users="collaboratorsSorted" :current-user-email="currentUserEmail" /> <n8n-user-stack
v-if="showUserStack"
:users="collaboratorsSorted"
:current-user-email="currentUserEmail"
/>
</div> </div>
</template> </template>

View file

@ -668,7 +668,7 @@ function showCreateWorkflowSuccessToast(id?: string) {
</span> </span>
<EnterpriseEdition :features="[EnterpriseEditionFeature.Sharing]"> <EnterpriseEdition :features="[EnterpriseEditionFeature.Sharing]">
<div :class="$style.group"> <div :class="$style.group">
<CollaborationPane v-if="nodeViewVersion === '2' && !isNewWorkflow" /> <CollaborationPane v-if="!isNewWorkflow" />
<N8nButton <N8nButton
type="secondary" type="secondary"
data-test-id="workflow-share-button" data-test-id="workflow-share-button"

View file

@ -96,4 +96,22 @@ describe('CollaborationPane', () => {
// Owner is second in the store but should be rendered first // Owner is second in the store but should be rendered first
expect(firstAvatar).toHaveAttribute('data-test-id', `user-stack-avatar-${OWNER_USER.id}`); expect(firstAvatar).toHaveAttribute('data-test-id', `user-stack-avatar-${OWNER_USER.id}`);
}); });
it('should not render the user-stack if there is only one user', async () => {
const { getByTestId } = renderComponent({
pinia: createTestingPinia({
initialState: {
...initialState,
[STORES.COLLABORATION]: {
collaborators: [{ lastSeen: '2023-11-22T10:17:12.246Z', user: OWNER_USER }],
},
},
}),
});
await waitAllPromises();
const collaborationPane = getByTestId('collaboration-pane');
expect(collaborationPane).toBeInTheDocument();
expect(collaborationPane.querySelector('[data-test-id=user-stack-avatars]')).toBeNull();
});
}); });