Skip to content

Commit

Permalink
Add changeIsDefault to s3ConfigManagment
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Sep 18, 2024
1 parent 04cea08 commit 2c5dd27
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions web/src/core/usecases/s3ConfigManagement/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,53 @@ export const thunks = {
);
}

await dispatch(
projectManagement.protectedThunks.updateConfigValue({
"key": "s3",
"value": projectConfigsS3
})
);
},
"changeIsDefault":
(params: {
s3ConfigId: string;
usecase: "defaultXOnyxia" | "explorer";
value: boolean;
}) =>
async (...args) => {
const { s3ConfigId, usecase, value } = params;

const [dispatch, getState] = args;

const projectConfigsS3 = structuredClone(
projectManagement.protectedSelectors.projectConfig(getState()).s3
);

const propertyName = (() => {
switch (usecase) {
case "defaultXOnyxia":
return "s3ConfigId_defaultXOnyxia";
case "explorer":
return "s3ConfigId_explorer";
}
})();

{
const currentDefault = projectConfigsS3[propertyName];

if (value) {
if (currentDefault === s3ConfigId) {
return;
}
} else {
if (currentDefault !== s3ConfigId) {
return;
}
}
}

projectConfigsS3[propertyName] = value ? s3ConfigId : undefined;

await dispatch(
projectManagement.protectedThunks.updateConfigValue({
"key": "s3",
Expand Down

0 comments on commit 2c5dd27

Please sign in to comment.