diff --git a/CHANGELOG.md b/CHANGELOG.md index aa4c83a238..28f4e8eeb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to ### Fixed +- Allow credentials (raw JSON, HTTP, OAuth) on common adaptor jobs + [#4513](https://github.com/OpenFn/lightning/pull/4513) - Migrate form error display from `phx-feedback-for` to `used_input?/1` so validation errors only appear on fields the user has interacted with [#4472](https://github.com/OpenFn/lightning/pull/4472) diff --git a/assets/js/collaborative-editor/components/ConfigureAdaptorModal.tsx b/assets/js/collaborative-editor/components/ConfigureAdaptorModal.tsx index 9b3597e98c..935da823ba 100644 --- a/assets/js/collaborative-editor/components/ConfigureAdaptorModal.tsx +++ b/assets/js/collaborative-editor/components/ConfigureAdaptorModal.tsx @@ -277,13 +277,6 @@ export function ConfigureAdaptorModal({ onCredentialChange, ]); - // Check if the adaptor requires credentials - const adaptorNeedsCredentials = useMemo(() => { - const adaptorName = extractAdaptorName(currentAdaptor); - // Common adaptor doesn't require credentials - return adaptorName !== 'common'; - }, [currentAdaptor]); - // Filter credentials into sections const credentialSections = useMemo(() => { const adaptorName = extractAdaptorName(currentAdaptor); @@ -442,7 +435,10 @@ export function ConfigureAdaptorModal({ const handleCreateCredential = () => { const adaptorName = extractAdaptorName(currentAdaptor); if (adaptorName) { - onOpenCredentialModal(adaptorName); + // Adaptors like "common" have no credential schema file, so default + // to "raw" (Raw JSON) which is the most flexible credential type. + const schema = adaptorName === 'common' ? 'raw' : adaptorName; + onOpenCredentialModal(schema); } }; @@ -590,27 +586,19 @@ export function ConfigureAdaptorModal({ /> - {adaptorNeedsCredentials && ( - - )} + - {!adaptorNeedsCredentials ? ( -
-

- This adaptor does not require credentials. -

-
- ) : credentialSections.schemaMatched.length === 0 && - credentialSections.universal.length === 0 && - credentialSections.keychain.length === 0 ? ( + {credentialSections.schemaMatched.length === 0 && + credentialSections.universal.length === 0 && + credentialSections.keychain.length === 0 ? (

No credentials found in this project diff --git a/assets/test/collaborative-editor/components/ConfigureAdaptorModal.test.tsx b/assets/test/collaborative-editor/components/ConfigureAdaptorModal.test.tsx index 78115c4e6d..68ffb84a47 100644 --- a/assets/test/collaborative-editor/components/ConfigureAdaptorModal.test.tsx +++ b/assets/test/collaborative-editor/components/ConfigureAdaptorModal.test.tsx @@ -742,7 +742,7 @@ describe('ConfigureAdaptorModal', () => { expect(radioButtons.length).toBe(3); }); - it("shows informative message for adaptors that don't need credentials", () => { + it('shows universal and keychain credentials for common adaptor', () => { renderWithProviders( { /> ); - // Should show message that adaptor doesn't need credentials + // Should NOT show message that adaptor doesn't need credentials expect( - screen.getByText('This adaptor does not require credentials.') - ).toBeInTheDocument(); - - // Should NOT show credential list or New Credential button - expect(screen.queryByText('HTTP API Key')).not.toBeInTheDocument(); - expect(screen.queryByText('Keychain Salesforce')).not.toBeInTheDocument(); - expect( - screen.queryByText('Salesforce Production') + screen.queryByText('This adaptor does not require credentials.') ).not.toBeInTheDocument(); - // New Credential button should be hidden + // Should show universal credentials (http, raw, oauth) and keychain + expect(screen.getByText('HTTP API Key')).toBeInTheDocument(); + expect(screen.getByText('Keychain Salesforce')).toBeInTheDocument(); + + // Should NOT show schema-specific credentials (no schema matches "common") expect( - screen.queryByRole('button', { name: /new credential/i }) + screen.queryByText('Salesforce Production') ).not.toBeInTheDocument(); - // Should NOT show "Back to matching credentials" link (no matching credentials to go back to) + // New Credential button should be available expect( - screen.queryByText(/back to matching credentials/i) - ).not.toBeInTheDocument(); + screen.getByRole('button', { name: /new credential/i }) + ).toBeInTheDocument(); }); it('allows manual toggle between matching and other credentials', async () => {