-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ui-studies): add on click fetch and display list of non studies folder #2224
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have an import error in components/Studies/SideNav.tsx
update this import StudyTree from "./StudyTree";
to: import StudyTree from "@/components/App/Studies/StudyTree";
do you have all frontend tools properly setup, eslint, typescript etc ?
webapp/src/services/api/study.ts
Outdated
export const getWorkspaces = async (): Promise<string[]> => { | ||
const res = await client.get(`/v1/private/explorer/_list_workspaces`); | ||
return res.data.map((folder: { name: string }) => folder.name); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can pass types to axios methods, like this:
interface Workspace {
name: string;
}
export const getWorkspaces = async => {
const res = await client.get<Workspace[]>(
`/v1/private/explorer/_list_workspaces`,
);
return res.data.map((workspace) => workspace.name);
};
webapp/src/services/api/study.ts
Outdated
@@ -48,6 +49,37 @@ export const getStudies = async (): Promise<StudyMetadata[]> => { | |||
}); | |||
}; | |||
|
|||
export const getWorkspaces = async (): Promise<string[]> => { | |||
const res = await client.get(`/v1/private/explorer/_list_workspaces`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason why we have underscores in the api url ? /v1/private/explorer/_list_workspaces
We follow REST conventions, this should be something like /v1/private/explorer/workspaces
, and if separators are needed we usually use a hyphen "-"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's as per the specs, convention for private routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The back-end side seems legit
7f3197d
to
700cfe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor feedback, otherwise it looks good to me 👍🏼
@@ -667,7 +669,9 @@ | |||
"studies.exportOutput": "Exporter une sortie", | |||
"studies.exportOutputFilter": "Exporter une sortie filtrée", | |||
"studies.selectOutput": "Selectionnez une sortie", | |||
"studies.variant": "Variante", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove also the key in the english file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was a duplicate in tis file or something
control={<Checkbox checked={isRecursiveScan} />} | ||
label={t("studies.requestDeepScan")} | ||
onChange={handleRecursiveScan} | ||
/>{" "} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove {" "}
onConfirm={handleFolderScan} | ||
alert="warning" | ||
open | ||
> | ||
{`${t("studies.scanFolder")} ${folder}?`} | ||
<FormControlLabel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use our component CheckBoxFE
treeWithWorkspaces, | ||
); | ||
setStudiesTree(updatedTree); | ||
failedPaths.forEach((path) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can flood the user with popups. Include them in one snackbar instead.
setStudiesTree(initialStudiesTree); | ||
enqueueErrorSnackbar( | ||
t("studies.tree.error.failToFetchWorkspace"), | ||
error as AxiosError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use toError(err)
@@ -0,0 +1,157 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not better to have a test folder inside component @hdinia?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed to not mix concerns if their is multiple files related to tests in a folder we should put them inside their __tests__
folder
t("studies.tree.error.detailsInConsole"), | ||
); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a line break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
); | ||
} | ||
} | ||
const chidrenPaths = studyTreeNode.children.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code and the code from the effect can be move in a common function
* @param path path of the subfolder to fetch, should sart with root, e.g. root/workspace/folder1 | ||
* @returns list of subfolders under the given path | ||
*/ | ||
async function fetchSubfolders(path: string): Promise<NonStudyFolderDTO[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async / await
and return type are not necessary
…factor code into a functional style
…cursive scan, show only studies in the current folder by default use a tree icon when we show studies for all descendants
f546844
to
eb1a170
Compare
No description provided.