Skip to content

Commit

Permalink
Fix connections fake entry & s3 button (#860)
Browse files Browse the repository at this point in the history
* Add getFakeEntry to registry

* Add type for getFakeEntry definition
  • Loading branch information
korvin89 authored Apr 10, 2024
1 parent 59d2fa5 commit 6a2a936
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/ui/registry/units/connections/functions-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {FormSchema} from 'shared/schema';
import {makeFunctionTemplate} from '../../../../shared/utils/makeFunctionTemplate';
import {EXAMPLE_FUNCTION} from '../common/constants/functions';

import type {GetFakeEntry} from './types/getFakeEntry';
import type {GetMockedFormArgs} from './types/getMockedForm';
import type {GetNewConnectionDestination} from './types/getNewConnectionDestination';

Expand All @@ -11,4 +12,5 @@ export const connectionsFunctionsMap = {
getMockedForm: makeFunctionTemplate<(args: GetMockedFormArgs) => FormSchema | undefined>(),
getConnectionsWithForceSkippedCopyTemplateInWorkbooks: makeFunctionTemplate<() => string[]>(),
getNewConnectionDestination: makeFunctionTemplate<GetNewConnectionDestination>(),
getFakeEntry: makeFunctionTemplate<GetFakeEntry>(),
} as const;
2 changes: 2 additions & 0 deletions src/ui/registry/units/connections/register.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {PreparedRowItem} from 'ui/units/connections/components/ConnectorForm/FormRow/PreparedRowItem';
import {getFakeEntry} from 'ui/units/connections/store/utils/entry';
import {getNewConnectionDestination} from 'ui/units/connections/utils/entry';

import {registry} from '../../../registry';
Expand All @@ -8,6 +9,7 @@ export const registerConnectionsPlugins = () => {
PreparedRowItem,
});
registry.connections.functions.register({
getFakeEntry,
getNewConnectionDestination,
});
};
4 changes: 4 additions & 0 deletions src/ui/registry/units/connections/types/getFakeEntry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type {GetEntryResponse} from 'shared/schema/types';

/** A function that creates mocked entry to have properly Breadcrumbs view. */
export type GetFakeEntry = (workbookId?: string) => GetEntryResponse;
2 changes: 1 addition & 1 deletion src/ui/units/connections/store/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {ConnectionsReduxDispatch, ConnectionsReduxState, GetState} from '../typi
import {
getConnectorItemFromFlattenList,
getDataForParamsChecking,
getFakeEntry,
getFetchedFormData,
getFlattenConnectors,
getFormDefaults,
Expand Down Expand Up @@ -74,6 +73,7 @@ export function setPageData({entryId, workbookId}: {entryId?: string | null; wor
}

if (!entry) {
const getFakeEntry = registry.connections.functions.get('getFakeEntry');
entry = getFakeEntry(workbookId);
}

Expand Down
9 changes: 4 additions & 5 deletions src/ui/units/connections/store/utils/entry.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {i18n} from 'i18n';
import {DL} from 'ui';
import {getFakeEntry as genericGetFakeEntry} from 'ui/components/ActionPanel';
import type {GetFakeEntry} from 'ui/registry/units/connections/types/getFakeEntry';

import {getFakeEntry as genericGetFakeEntry} from '../../../../components/ActionPanel';

export const getFakeEntry = (workbookId?: string) => {
export const getFakeEntry: GetFakeEntry = (workbookId) => {
const name = i18n('connections.form', 'section_creation-connection');

return genericGetFakeEntry({
workbookId,
key: `${DL.USER_FOLDER}${name}`,
key: name,
fakeName: name,
});
};

0 comments on commit 6a2a936

Please sign in to comment.