Skip to content
4 changes: 3 additions & 1 deletion web/src/core/adapters/onyxiaApi/ApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type ApiTypes = {
};
data?: {
S3?: ArrayOrNot<{
profileName?: string;
URL: string;
pathStyleAccess?: true;

Expand All @@ -94,6 +95,7 @@ export type ApiTypes = {
{
roleARN: string;
roleSessionName: string;
profileName: string;
} & (
| { claimName?: undefined }
| {
Expand Down Expand Up @@ -125,7 +127,7 @@ export type ApiTypes = {
title: LocalizedString;
description?: LocalizedString;
tags?: LocalizedString[];
forStsRoleSessionName?: string | string[];
forProfileName?: string | string[];
} & (
| { claimName?: undefined }
| {
Expand Down
7 changes: 5 additions & 2 deletions web/src/core/adapters/onyxiaApi/onyxiaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ export function createOnyxiaApi(params: {
s3Config_api
): DeploymentRegion.S3Next.S3Profile => {
return {
profileName: s3Config_api.profileName,
url: s3Config_api.URL,
pathStyleAccess:
s3Config_api.pathStyleAccess ??
Expand Down Expand Up @@ -413,6 +414,8 @@ export function createOnyxiaApi(params: {
role_api.roleARN,
roleSessionName:
role_api.roleSessionName,
profileName:
role_api.profileName,
...(role_api.claimName ===
undefined
? {
Expand Down Expand Up @@ -462,10 +465,10 @@ export function createOnyxiaApi(params: {
tags:
bookmarkedDirectory_api.tags ??
[],
forStsRoleSessionNames:
forProfileNames:
(() => {
const v =
bookmarkedDirectory_api.forStsRoleSessionName;
bookmarkedDirectory_api.forProfileName;

if (
v ===
Expand Down
8 changes: 6 additions & 2 deletions web/src/core/adapters/sqlOlap/sqlOlap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const createDuckDbSqlOlap = (params: {
sourceUrl = sourceUrl_noRedirect;
}

const sqlQuery = `SELECT * FROM ${(() => {
let sqlQuery = `SELECT * FROM ${(() => {
switch (fileType) {
case "csv":
return `read_csv('${sourceUrl}')`;
Expand All @@ -287,7 +287,11 @@ export const createDuckDbSqlOlap = (params: {
case "json":
return `read_json('${sourceUrl}')`;
}
})()} LIMIT ${rowsPerPage} OFFSET ${rowsPerPage * (page - 1)}`;
})()} LIMIT ${rowsPerPage}`;

if (page !== 1) {
sqlQuery += ` OFFSET ${rowsPerPage * (page - 1)}`;
}

const conn = await db.connect();
const stmt = await conn.prepare(sqlQuery);
Expand Down
2 changes: 1 addition & 1 deletion web/src/core/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export async function bootstrapCore(
}

const result = await dispatch(
usecases.s3ProfilesManagement.protectedThunks.getS3ConfigAndClientForExplorer()
usecases.s3ProfilesManagement.protectedThunks.getS3ProfileAndClientForExplorer()
);

if (result === undefined) {
Expand Down
4 changes: 3 additions & 1 deletion web/src/core/ports/OnyxiaApi/DeploymentRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export namespace DeploymentRegion {
export namespace S3Next {
/** https://github.com/InseeFrLab/onyxia-api/blob/main/docs/region-configuration.md#s3 */
export type S3Profile = {
profileName: string | undefined;
url: string;
pathStyleAccess: boolean;
region: string | undefined;
Expand All @@ -190,6 +191,7 @@ export namespace DeploymentRegion {
export type StsRole = {
roleARN: string;
roleSessionName: string;
profileName: string;
} & (
| {
claimName: undefined;
Expand All @@ -208,7 +210,7 @@ export namespace DeploymentRegion {
title: LocalizedString;
description: LocalizedString | undefined;
tags: LocalizedString[];
forStsRoleSessionNames: string[];
forProfileNames: string[];
} & (
| {
claimName: undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ export const protectedSelectors = {
};

export type View = {
selectedS3ProfileId: string | undefined;
selectedS3Profile_creationTime: number | undefined;
availableS3Profiles: {
id: string;
displayName: string;
}[];
selectedS3ProfileName: string | undefined;
isSelectedS3ProfileEditable: boolean;
availableS3ProfileNames: string[];
bookmarks: {
displayName: LocalizedString | undefined;
s3UriPrefixObj: S3UriPrefixObj;
Expand All @@ -48,9 +45,9 @@ const view = createSelector(

if (routeParams.profile === undefined) {
return {
selectedS3ProfileId: undefined,
selectedS3Profile_creationTime: undefined,
availableS3Profiles: [],
selectedS3ProfileName: undefined,
isSelectedS3ProfileEditable: false,
availableS3ProfileNames: [],
bookmarks: [],
s3UriPrefixObj: undefined,
bookmarkStatus: {
Expand All @@ -59,10 +56,10 @@ const view = createSelector(
};
}

const selectedS3ProfileId = routeParams.profile;
const profileName = routeParams.profile;

const s3Profile = s3Profiles.find(
s3Profile => s3Profile.id === selectedS3ProfileId
s3Profile => s3Profile.profileName === profileName
);

// NOTE: We enforce this invariant while loading the route
Expand All @@ -77,15 +74,10 @@ const view = createSelector(
});

return {
selectedS3ProfileId,
selectedS3Profile_creationTime:
s3Profile.origin !== "created by user (or group project member)"
? undefined
: s3Profile.creationTime,
availableS3Profiles: s3Profiles.map(s3Profile => ({
id: s3Profile.id,
displayName: s3Profile.paramsOfCreateS3Client.url
})),
selectedS3ProfileName: profileName,
isSelectedS3ProfileEditable:
s3Profile.origin === "created by user (or group project member)",
availableS3ProfileNames: s3Profiles.map(s3Profile => s3Profile.profileName),
bookmarks: s3Profile.bookmarks,
s3UriPrefixObj,
bookmarkStatus: (() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export const { actions, reducer } = createUsecaseActions({
},
selectedS3ProfileUpdated: (
state,
{ payload }: { payload: { s3ProfileId: string } }
{ payload }: { payload: { profileName: string } }
) => {
const { s3ProfileId } = payload;
const { profileName } = payload;

state.routeParams.profile = s3ProfileId;
state.routeParams.profile = profileName;
state.routeParams.path = "";
}
}
Expand Down
32 changes: 17 additions & 15 deletions web/src/core/usecases/_s3Next/s3ExplorerRootUiController/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ export const thunks = {
const { routeParams } = params;

if (routeParams.profile !== undefined) {
const s3ProfileId = routeParams.profile;
const profileName = routeParams.profile;

{
const s3Profiles =
s3ProfilesManagement.selectors.s3Profiles(getState());

if (
s3Profiles.find(s3Profile => s3Profile.id === s3ProfileId) ===
undefined
s3Profiles.find(
s3Profile => s3Profile.profileName === profileName
) === undefined
) {
return dispatch(thunks.load({ routeParams: { path: "" } }));
}
}

await dispatch(
s3ProfilesManagement.protectedThunks.changeIsDefault({
s3ProfileId,
profileName,
usecase: "explorer",
value: true
})
Expand All @@ -49,12 +50,13 @@ export const thunks = {
return { routeParams_toSet: routeParams };
}

const wrap = await dispatch(
s3ProfilesManagement.protectedThunks.getS3ConfigAndClientForExplorer()
);
const { s3Profile } =
(await dispatch(
s3ProfilesManagement.protectedThunks.getS3ProfileAndClientForExplorer()
)) ?? {};

const routeParams_toSet: RouteParams = {
profile: wrap === undefined ? undefined : wrap.s3Profile.id,
profile: s3Profile === undefined ? undefined : s3Profile.profileName,
path: ""
};

Expand Down Expand Up @@ -87,23 +89,23 @@ export const thunks = {
dispatch(actions.s3UrlUpdated({ s3UriPrefixObj }));
},
updateSelectedS3Profile:
(params: { s3ProfileId: string }) =>
(params: { profileName: string }) =>
async (...args) => {
const [dispatch] = args;

const { s3ProfileId } = params;
const { profileName } = params;

await dispatch(
s3ProfilesManagement.protectedThunks.changeIsDefault({
s3ProfileId,
profileName,
usecase: "explorer",
value: true
})
);

dispatch(
actions.selectedS3ProfileUpdated({
s3ProfileId
profileName
})
);
},
Expand All @@ -120,15 +122,15 @@ export const thunks = {

const [dispatch, getState] = args;

const { selectedS3ProfileId, s3UriPrefixObj, bookmarkStatus } =
const { selectedS3ProfileName, s3UriPrefixObj, bookmarkStatus } =
selectors.view(getState());

assert(selectedS3ProfileId !== undefined);
assert(selectedS3ProfileName !== undefined);
assert(s3UriPrefixObj !== undefined);

await dispatch(
s3ProfilesManagement.protectedThunks.createDeleteOrUpdateBookmark({
s3ProfileId: selectedS3ProfileId,
profileName: selectedS3ProfileName,
s3UriPrefixObj,
action: bookmarkStatus.isBookmarked
? {
Expand Down
Loading