feat(export): elements download (MIN-157)
Added the possibility to download data from elements from the export tab. We send the items selected by the user to the backend and the backend returns the text to be saved in a file. The data is saved in a .csv file An improvement reported by Marek regarding removing types and columns sections, displaying only available annotations and removing special characters from their names has also been added.
Merge request reports
Activity
assigned to @mateusz-winiarczyk
183 excludedCompartmentPathways.click(); 184 }); 185 const excludedCompartmentPathwaysInput = screen.getAllByLabelText( 186 SECOND_COMPARMENT_PATHWAY_NAME, 187 )[1]; 188 189 await act(() => { 190 excludedCompartmentPathwaysInput.click(); 191 }); 192 193 expect(excludedCompartmentPathwaysInput).toBeChecked(); 194 195 const downloadButton = screen.getByText('Download'); 196 197 await act(() => { 198 downloadButton.click(); - src/redux/export/export.types.ts 0 → 100644
1 import { Loading } from '@/types/loadingState'; 2 3 export type ExportState = { 4 downloadElements: { @teoMiesiac I'm not a big fan of adding this to the redux. But this is related to our discussion with plugins. We have an export plugin and, as far as I remember, we don't know its exact scope (please correct me if I'm wrong). That's why I assumed here that it would be safer to expose core methods that are related to plugins that we know about as public thunks. This is not that terrible from an architectural point of view, but later it can help us in exposing public methods for plugins. We then have access to the download method using one dispatch with payload and the loading, error status to use in store. If we left it as a private method in context/component it would make things a lot more difficult. If my assumption is wrong, then as you say the regular method from
axios.post
will also be fine.Edited by mateusz-winiarczyk
Hej @mateusz-winiarczyk probably 2 RFC from my side
- Mocking network call in test
- Reducing redux boilerplate - it might be discussed
added 1 commit
- 68e9e0f6 - test(export): mock http download csv request
- src/redux/export/export.thunks.ts 0 → 100644
4 import { PROJECT_ID } from '@/constants'; 5 import { ExportElements } from '@/types/models'; 6 import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; 7 import { exportElementsSchema } from '@/models/exportSchema'; 8 import { apiPath } from '../apiPath'; 9 10 type DownloadElementsBodyRequest = { 11 types: string[]; 12 columns: string[]; 13 submaps: number[]; 14 annotations: string[]; 15 includedCompartmentIds: number[]; 16 excludedCompartmentIds: number[]; 17 }; 18 19 const downloadFileFromBlob = (data: ExportElements): void => { changed this line in version 4 of the diff
139 140 await act(() => { 141 elementTypeInput.click(); 142 }); 143 144 expect(elementTypeInput).toBeChecked(); 145 146 const columns = screen.getByText('Select column'); 147 await act(() => { 148 columns.click(); 149 }); 150 const columnInput = screen.getByLabelText('Description'); 151 152 await act(() => { 153 columnInput.click(); 154 }); That's de facto an E2E test because it's simulating whole behavior scenario
IMO it would be better to just mock context here (simpler, less code, easier to understand and test more cases) but as far as I can see, it wouldn't be easy.
That's an architectural issue, I believe it's worth resolving but that's not an RFC
changed this line in version 3 of the diff
18 18 excludedCompartmentPathways: CheckboxItem[]; 19 19 }; 20 20 21 const extractAndParseNumberIdFromCompartment = (compartment: CheckboxItem): number => { 22 const [, id] = compartment.id.split('-'); 23 return Number(id); 24 }; added 1 commit
- 7ccb9d4d - feat(export): remove columns and types sections and adjust download file
added 1 commit
- 1134ad4f - fix(export): add handling for incorrect comparment id
added 4 commits
-
1134ad4f...ab449b1e - 3 commits from branch
development
- 1f280b69 - Merge remote-tracking branch 'origin/development' into MIN-157-elements-download
-
1134ad4f...ab449b1e - 3 commits from branch
added 3 commits
-
1f280b69...2e797ddc - 2 commits from branch
development
- 6424fd28 - Merge remote-tracking branch 'origin/development' into MIN-157-elements-download
-
1f280b69...2e797ddc - 2 commits from branch
mentioned in commit 9d60cc66