Skip to content

Commit

Permalink
Complete S3 project settings migration
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Sep 19, 2024
1 parent 2c5dd27 commit b7a04c3
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 285 deletions.
8 changes: 4 additions & 4 deletions web/src/core/usecases/s3ConfigCreation/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,25 @@ export const { reducer, actions } = createUsecaseActions({
payload
}: {
payload: {
s3ConfigId: string | undefined;
s3ConfigIdToEdit: string | undefined;
initialFormValues: State.Ready["formValues"];
};
}
) => {
const { s3ConfigId, initialFormValues } = payload;
const { s3ConfigIdToEdit, initialFormValues } = payload;

return id<State.Ready>({
"stateDescription": "ready",
"formValues": initialFormValues,
"action":
s3ConfigId === undefined
s3ConfigIdToEdit === undefined
? {
"type": "create new config",
"creationTime": Date.now()
}
: {
"type": "update existing config",
s3ConfigId
"s3ConfigId": s3ConfigIdToEdit
}
});
},
Expand Down
41 changes: 34 additions & 7 deletions web/src/core/usecases/s3ConfigCreation/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,33 @@ import * as deploymentRegionManagement from "core/usecases/deploymentRegionManag
import { getWorkingDirectoryPath } from "core/usecases/s3ConfigManagement/decoupledLogic/getWorkingDirectoryPath";
import * as projectManagement from "core/usecases/projectManagement";
import * as userAuthentication from "core/usecases/userAuthentication";
import * as s3ConfigConnectionTest from "core/usecases/s3ConfigConnectionTest";

export const thunks = {
"initialize":
(params: { s3ConfigId: string | undefined }) =>
(params: { s3ConfigIdToEdit: string | undefined }) =>
async (...args) => {
const { s3ConfigId } = params;
const { s3ConfigIdToEdit } = params;

const [dispatch, getState] = args;

const s3Configs = s3ConfigManagement.selectors.s3Configs(getState());

update_existing_config: {
if (s3ConfigId === undefined) {
if (s3ConfigIdToEdit === undefined) {
break update_existing_config;
}

const s3Config = s3Configs.find(s3Config => s3Config.id === s3ConfigId);
const s3Config = s3Configs.find(
s3Config => s3Config.id === s3ConfigIdToEdit
);

assert(s3Config !== undefined);
assert(s3Config.origin === "project");

dispatch(
actions.initialized({
s3ConfigId,
s3ConfigIdToEdit,
"initialFormValues": {
"friendlyName": s3Config.friendlyName,
"url": s3Config.paramsOfCreateS3Client.url,
Expand Down Expand Up @@ -77,7 +80,7 @@ export const thunks = {
if (s3ConfigCreationFormDefaults === undefined) {
dispatch(
actions.initialized({
"s3ConfigId": undefined,
"s3ConfigIdToEdit": undefined,
"initialFormValues": {
"friendlyName": "",
"url": "",
Expand Down Expand Up @@ -121,7 +124,7 @@ export const thunks = {

dispatch(
actions.initialized({
"s3ConfigId": undefined,
"s3ConfigIdToEdit": undefined,
"initialFormValues": {
"friendlyName": "",
"url": s3ConfigCreationFormDefaults.url,
Expand Down Expand Up @@ -204,5 +207,29 @@ export const thunks = {
break preset_pathStyleAccess;
}
}
},
"testConnection":
() =>
async (...args) => {
const [dispatch, getState] = args;

const projectS3Config =
privateSelectors.submittableFormValuesAsProjectS3Config(getState());

assert(projectS3Config !== null);
assert(projectS3Config !== undefined);

await dispatch(
s3ConfigConnectionTest.protectedThunks.testS3Connection({
"paramsOfCreateS3Client": {
"isStsEnabled": false,
"url": projectS3Config.url,
"pathStyleAccess": projectS3Config.pathStyleAccess,
"region": projectS3Config.region,
"credentials": projectS3Config.credentials
},
"workingDirectoryPath": projectS3Config.workingDirectoryPath
})
);
}
} satisfies Thunks;
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ export function getS3Configs(params: {
const paramsOfCreateS3Client: ParamsOfCreateS3Client.NoSts = {
url,
pathStyleAccess,
isStsEnabled: false,
"isStsEnabled": false,
region,
credentials: c.credentials
"credentials": c.credentials
};

return {
Expand Down
1 change: 1 addition & 0 deletions web/src/core/usecases/s3ConfigManagement/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./state";
export * from "./selectors";
export * from "./thunks";
export type { S3Config } from "./decoupledLogic/getS3Configs";
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/de.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ export const translations: Translations<"de"> = {
</>
),
"account credentials": "Kontozugangsdaten",
"accountFriendlyName textField label": "Benutzerfreundlicher Kontoname",
"accountFriendlyName textField helper text":
"Dient nur zur Identifikation dieses Kontos. Beispiel: Mein persönliches Konto",
"friendlyName textField label": "Konfigurationsname",
"friendlyName textField helper text":
"Dies hilft Ihnen nur, diese Konfiguration zu identifizieren. Beispiel: Mein AWS-Bucket",
"isAnonymous switch label": "Anonymer Zugang",
"isAnonymous switch helper text":
"Auf EIN stellen, wenn kein geheimer Zugangsschlüssel erforderlich ist",
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/en.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ export const translations: Translations<"en"> = {
</>
),
"account credentials": "Account credentials",
"accountFriendlyName textField label": "Account friendly name",
"accountFriendlyName textField helper text":
"This is just to help you identify this account. Example: My personal account",
"friendlyName textField label": "Configuration Name",
"friendlyName textField helper text":
"This is just to help you identify this configuration. Example: My AWS bucket",
"isAnonymous switch label": "Anonymous access",
"isAnonymous switch helper text": "Set to ON if no secret access key is required",
"accessKeyId textField label": "Access key ID",
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/es.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export const translations: Translations<"en"> = {
</>
),
"account credentials": "Credenciales de cuenta",
"accountFriendlyName textField label": "Nombre de cuenta amigable",
"accountFriendlyName textField helper text":
"Esto es solo para ayudarte a identificar esta cuenta. Ejemplo: Mi cuenta personal",
"friendlyName textField label": "Nombre de configuración",
"friendlyName textField helper text":
"Esto es solo para ayudarle a identificar esta configuración. Ejemplo: Mi bucket de AWS",
"isAnonymous switch label": "Acceso anónimo",
"isAnonymous switch helper text":
"Activa esta opción si no se requiere una clave de acceso secreto",
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/fi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export const translations: Translations<"fi"> = {
</>
),
"account credentials": "Tilin tunnistetiedot",
"accountFriendlyName textField label": "Tilin ystävällinen nimi",
"accountFriendlyName textField helper text":
"Tämä on vain avuksi tilin tunnistamisessa. Esimerkki: Oma henkilökohtainen tili",
"friendlyName textField label": "Konfiguraation nimi",
"friendlyName textField helper text":
"Tämä auttaa sinua tunnistamaan tämän konfiguraation. Esimerkki: Minun AWS-bucket",
"isAnonymous switch label": "Anonyymi pääsy",
"isAnonymous switch helper text":
"Aseta PÄÄLLE, jos salainen pääsyavain ei ole tarpeen",
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/fr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ export const translations: Translations<"fr"> = {
</>
),
"account credentials": "Identifiants du compte",
"accountFriendlyName textField label": "Nom convivial du compte",
"accountFriendlyName textField helper text":
"Ceci est juste pour vous aider à identifier ce compte. Exemple : Mon compte personnel",
"friendlyName textField label": "Nom de la configuration",
"friendlyName textField helper text":
"Ceci est juste pour vous aider à identifier cette configuration. Exemple : Mon bucket AWS",
"isAnonymous switch label": "Accès anonyme",
"isAnonymous switch helper text":
"Mettre sur ON si aucune clé d'accès secrète n'est requise",
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/it.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ export const translations: Translations<"it"> = {
</>
),
"account credentials": "Credenziali dell'account",
"accountFriendlyName textField label": "Nome amichevole dell'account",
"accountFriendlyName textField helper text":
"Questo serve solo per aiutarti a identificare questo account. Esempio: Il mio account personale",
"friendlyName textField label": "Nome della configurazione",
"friendlyName textField helper text":
"Questo serve solo ad aiutarti a identificare questa configurazione. Esempio: Il mio bucket AWS",

"isAnonymous switch label": "Accesso anonimo",
"isAnonymous switch helper text":
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/nl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ export const translations: Translations<"nl"> = {
</>
),
"account credentials": "Accountgegevens",
"accountFriendlyName textField label": "Vriendelijke naam van het account",
"accountFriendlyName textField helper text":
"Dit is slechts om u te helpen dit account te identificeren. Voorbeeld: Mijn persoonlijke account",
"friendlyName textField label": "Configuratienaam",
"friendlyName textField helper text":
"Dit helpt je alleen om deze configuratie te identificeren. Voorbeeld: Mijn AWS-bucket",

"isAnonymous switch label": "Anonieme toegang",
"isAnonymous switch helper text":
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/no.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ export const translations: Translations<"no"> = {
</>
),
"account credentials": "Kontoinformasjon",
"accountFriendlyName textField label": "Brukervennlig kontonavn",
"accountFriendlyName textField helper text":
"Dette er bare for å hjelpe deg med å identifisere denne kontoen. Eksempel: Min personlige konto",
"friendlyName textField label": "Konfigurasjonsnavn",
"friendlyName textField helper text":
"Dette er bare for å hjelpe deg med å identifisere denne konfigurasjonen. Eksempel: Min AWS-bøtte",

"isAnonymous switch label": "Anonym tilgang",
"isAnonymous switch helper text":
Expand Down
6 changes: 3 additions & 3 deletions web/src/ui/i18n/resources/zh-CN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ export const translations: Translations<"zh-CN"> = {
</>
),
"account credentials": "账户凭证",
"accountFriendlyName textField label": "账户友好名称",
"accountFriendlyName textField helper text":
"这只是为了帮助你识别这个账户。例如:我的个人账户",
"friendlyName textField label": "配置名称",
"friendlyName textField helper text":
"这只是帮助您识别此配置。例如:我的 AWS 存储桶",
"isAnonymous switch label": "匿名访问",
"isAnonymous switch helper text": "如果不需要密钥,请将其设置为开启",
"accessKeyId textField label": "访问密钥 ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,90 +55,51 @@ export const ProjectSettingsS3ConfigTab = memo((props: Props) => {
<div className={classes.cardsWrapper}>
{s3Configs.map(s3Config => (
<S3ConfigCard
key={s3Config.id}
className={classes.card}
key={s3Config.customConfigIndex ?? -1}
dataSource={s3Config.dataSource}
region={s3Config.region}
isUsedForExplorer={s3Config.isUsedForExplorer}
isUsedForXOnyxia={s3Config.isUsedForXOnyxia}
accountFriendlyName={s3Config.accountFriendlyName}
s3Config={s3Config}
onDelete={(() => {
const { customConfigIndex } = s3Config;

if (customConfigIndex === undefined) {
if (s3Config.origin !== "project") {
return undefined;
}

return () =>
evtConfirmCustomS3ConfigDeletionDialogOpen.post({
"resolveDoProceed": doProceed => {
if (!doProceed) {
return;
}

s3ConfigManagement.deleteCustomS3Config({
customConfigIndex
});
}
});
})()}
onIsUsedForExplorerValueChange={(() => {
if (
s3Config.accountFriendlyName === undefined &&
s3Config.isUsedForExplorer
) {
return undefined;
}

return isUsed =>
s3ConfigManagement.setConfigUsage({
"customConfigIndex": s3Config.customConfigIndex,
"usedFor": "explorer",
isUsed
});
})()}
onIsUsedForXOnyxiaValueChange={(() => {
if (
s3Config.accountFriendlyName === undefined &&
s3Config.isUsedForXOnyxia
) {
return undefined;
}

return isUsed =>
s3ConfigManagement.setConfigUsage({
"customConfigIndex": s3Config.customConfigIndex,
"usedFor": "xOnyxia",
isUsed
s3ConfigManagement.deleteS3Config({
"projectS3ConfigId": s3Config.id
});
})()}
onIsExplorerConfigChange={value =>
s3ConfigManagement.changeIsDefault({
"s3ConfigId": s3Config.id,
"usecase": "explorer",
value
})
}
onIsOnyxiaDefaultChange={value =>
s3ConfigManagement.changeIsDefault({
"s3ConfigId": s3Config.id,
"usecase": "defaultXOnyxia",
value
})
}
onEdit={(() => {
const { customConfigIndex } = s3Config;

if (customConfigIndex === undefined) {
if (s3Config.origin !== "project") {
return undefined;
}

return () =>
evtAddCustomS3ConfigDialogOpen.post({
customConfigIndex
"s3ConfigIdToEdit": s3Config.id
});
})()}
doHideUsageSwitches={
s3Config.accountFriendlyName === undefined &&
s3Configs.length === 1
}
connectionTestStatus={s3Config.connectionTestStatus}
onTestConnection={(() => {
const { customConfigIndex } = s3Config;

if (customConfigIndex === undefined) {
if (s3Config.origin !== "project") {
return undefined;
}

return () =>
s3ConfigManagement.testConnection({
customConfigIndex
s3ConfigManagement.testS3Connection({
"projectS3ConfigId": s3Config.id
});
})()}
/>
Expand All @@ -163,7 +124,7 @@ export const ProjectSettingsS3ConfigTab = memo((props: Props) => {
}

evtAddCustomS3ConfigDialogOpen.post({
"customConfigIndex": undefined
"s3ConfigIdToEdit": undefined
});
}}
>
Expand Down
Loading

0 comments on commit b7a04c3

Please sign in to comment.