Skip to content

Commit

Permalink
Remove duplicated data connection creating calls
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoDaoNoCode committed Oct 9, 2024
1 parent 890ebb1 commit 01170cc
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions frontend/src/pages/projects/screens/spawner/SpawnerFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ import {
Stack,
StackItem,
} from '@patternfly/react-core';
import {
assembleSecret,
createNotebook,
createSecret,
K8sStatusError,
mergePatchUpdateNotebook,
updateNotebook,
} from '~/api';
import { createNotebook, K8sStatusError, mergePatchUpdateNotebook, updateNotebook } from '~/api';
import {
DataConnectionData,
EnvVariable,
Expand Down Expand Up @@ -136,26 +129,11 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
setCreateInProgress(true);
};

const handleDataConnection = async (dryRun: boolean) => {
if (dataConnection.type === 'creating') {
const dataAsRecord = dataConnection.creating?.values?.data.reduce<Record<string, string>>(
(acc, { key, value }) => ({ ...acc, [key]: value }),
{},
);
if (dataAsRecord) {
return createSecret(assembleSecret(projectName, dataAsRecord, 'aws'), { dryRun });
}
}
return undefined;
};

const updateNotebookPromise = async (dryRun: boolean) => {
if (!editNotebook) {
return;
}

await handleDataConnection(dryRun);

const pvcDetails = await replaceRootVolumesForNotebook(
projectName,
editNotebook,
Expand Down Expand Up @@ -207,7 +185,6 @@ const SpawnerFooter: React.FC<SpawnerFooterProps> = ({
};

const createNotebookPromise = async (dryRun: boolean) => {
await handleDataConnection(dryRun);
const newDataConnection =
dataConnection.enabled && dataConnection.type === 'creating' && dataConnection.creating
? [dataConnection.creating]
Expand Down

0 comments on commit 01170cc

Please sign in to comment.