diff --git a/packages/editor-ui/src/api/credentials.ts b/packages/editor-ui/src/api/credentials.ts index 6ddb37c16a..18bb7b3f3d 100644 --- a/packages/editor-ui/src/api/credentials.ts +++ b/packages/editor-ui/src/api/credentials.ts @@ -32,6 +32,7 @@ export async function getAllCredentials( ): Promise { return await makeRestApiRequest(context, 'GET', '/credentials', { ...(includeScopes ? { includeScopes } : {}), + includeData: true, ...(filter ? { filter } : {}), }); } diff --git a/packages/editor-ui/src/api/sourceControl.ts b/packages/editor-ui/src/api/sourceControl.ts index 3aa929b6af..4553856928 100644 --- a/packages/editor-ui/src/api/sourceControl.ts +++ b/packages/editor-ui/src/api/sourceControl.ts @@ -33,7 +33,7 @@ export const pushWorkfolder = async ( export const pullWorkfolder = async ( context: IRestApiContext, data: PullWorkFolderRequestDto, -): Promise => { +): Promise => { return await makeRestApiRequest(context, 'POST', `${sourceControlApiRoot}/pull-workfolder`, data); }; diff --git a/packages/editor-ui/src/components/CredentialCard.vue b/packages/editor-ui/src/components/CredentialCard.vue index db40f0d274..4d4dd131f6 100644 --- a/packages/editor-ui/src/components/CredentialCard.vue +++ b/packages/editor-ui/src/components/CredentialCard.vue @@ -29,6 +29,7 @@ const props = withDefaults( defineProps<{ data: ICredentialsResponse; readOnly?: boolean; + needsSetup?: boolean; }>(), { data: () => ({ @@ -146,6 +147,9 @@ function moveResource() { {{ locale.baseText('credentials.item.readonly') }} + + {{ locale.baseText('credentials.item.needsSetup') }} +
@@ -195,10 +199,6 @@ function moveResource() { .cardHeading { font-size: var(--font-size-s); padding: var(--spacing-s) 0 0; - - span { - color: var(--color-text-light); - } } .cardDescription { diff --git a/packages/editor-ui/src/components/MainSidebarSourceControl.test.ts b/packages/editor-ui/src/components/MainSidebarSourceControl.test.ts index 4c192ffba6..dc3e805b05 100644 --- a/packages/editor-ui/src/components/MainSidebarSourceControl.test.ts +++ b/packages/editor-ui/src/components/MainSidebarSourceControl.test.ts @@ -3,7 +3,7 @@ import { waitFor } from '@testing-library/vue'; import userEvent from '@testing-library/user-event'; import { createTestingPinia } from '@pinia/testing'; import { merge } from 'lodash-es'; -import { SOURCE_CONTROL_PULL_MODAL_KEY, STORES } from '@/constants'; +import { SOURCE_CONTROL_PULL_MODAL_KEY, SOURCE_CONTROL_PUSH_MODAL_KEY, STORES } from '@/constants'; import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils'; import MainSidebarSourceControl from '@/components/MainSidebarSourceControl.vue'; import { useSourceControlStore } from '@/stores/sourceControl.store'; @@ -18,8 +18,9 @@ let rbacStore: ReturnType; const showMessage = vi.fn(); const showError = vi.fn(); +const showToast = vi.fn(); vi.mock('@/composables/useToast', () => ({ - useToast: () => ({ showMessage, showError }), + useToast: () => ({ showMessage, showError, showToast }), })); const renderComponent = createComponentRenderer(MainSidebarSourceControl); @@ -131,5 +132,129 @@ describe('MainSidebarSourceControl', () => { ), ); }); + + it('should open push modal when there are changes', async () => { + const status = [ + { + id: '014da93897f146d2b880-baa374b9d02d', + name: 'vuelfow2', + type: 'workflow' as const, + status: 'created' as const, + location: 'local' as const, + conflict: false, + file: '/014da93897f146d2b880-baa374b9d02d.json', + updatedAt: '2025-01-09T13:12:24.580Z', + }, + ]; + vi.spyOn(sourceControlStore, 'getAggregatedStatus').mockResolvedValueOnce(status); + const openModalSpy = vi.spyOn(uiStore, 'openModalWithData'); + + const { getAllByRole } = renderComponent({ + pinia, + props: { isCollapsed: false }, + }); + + await userEvent.click(getAllByRole('button')[1]); + await waitFor(() => + expect(openModalSpy).toHaveBeenCalledWith( + expect.objectContaining({ + name: SOURCE_CONTROL_PUSH_MODAL_KEY, + data: expect.objectContaining({ + status, + }), + }), + ), + ); + }); + + it("should show user's feedback when pulling", async () => { + vi.spyOn(sourceControlStore, 'pullWorkfolder').mockResolvedValueOnce([ + { + id: '014da93897f146d2b880-baa374b9d02d', + name: 'vuelfow2', + type: 'workflow', + status: 'created', + location: 'remote', + conflict: false, + file: '/014da93897f146d2b880-baa374b9d02d.json', + updatedAt: '2025-01-09T13:12:24.580Z', + }, + { + id: 'a102c0b9-28ac-43cb-950e-195723a56d54', + name: 'Gmail account', + type: 'credential', + status: 'created', + location: 'remote', + conflict: false, + file: '/a102c0b9-28ac-43cb-950e-195723a56d54.json', + updatedAt: '2025-01-09T13:12:24.586Z', + }, + { + id: 'variables', + name: 'variables', + type: 'variables', + status: 'modified', + location: 'remote', + conflict: false, + file: '/variable_stubs.json', + updatedAt: '2025-01-09T13:12:24.588Z', + }, + { + id: 'mappings', + name: 'tags', + type: 'tags', + status: 'modified', + location: 'remote', + conflict: false, + file: '/tags.json', + updatedAt: '2024-12-16T12:53:12.155Z', + }, + ]); + + const { getAllByRole } = renderComponent({ + pinia, + props: { isCollapsed: false }, + }); + + await userEvent.click(getAllByRole('button')[0]); + await waitFor(() => { + expect(showToast).toHaveBeenNthCalledWith( + 1, + expect.objectContaining({ + title: 'Finish setting up your new variables to use in workflows', + }), + ); + expect(showToast).toHaveBeenNthCalledWith( + 2, + expect.objectContaining({ + title: 'Finish setting up your new credentials to use in workflows', + }), + ); + expect(showToast).toHaveBeenNthCalledWith( + 3, + expect.objectContaining({ + message: '1 Workflow, 1 Credential, Variables, and Tags were pulled', + }), + ); + }); + }); + + it('should show feedback where there are no change to pull', async () => { + vi.spyOn(sourceControlStore, 'pullWorkfolder').mockResolvedValueOnce([]); + + const { getAllByRole } = renderComponent({ + pinia, + props: { isCollapsed: false }, + }); + + await userEvent.click(getAllByRole('button')[0]); + await waitFor(() => { + expect(showMessage).toHaveBeenCalledWith( + expect.objectContaining({ + title: 'Up to date', + }), + ); + }); + }); }); }); diff --git a/packages/editor-ui/src/components/MainSidebarSourceControl.vue b/packages/editor-ui/src/components/MainSidebarSourceControl.vue index 1fa8338a3f..af861e93c9 100644 --- a/packages/editor-ui/src/components/MainSidebarSourceControl.vue +++ b/packages/editor-ui/src/components/MainSidebarSourceControl.vue @@ -1,5 +1,5 @@