Skip to content
Snippets Groups Projects

feat(export): elements download (MIN-157)

Merged mateusz-winiarczyk requested to merge MIN-157-elements-download into development
5 unresolved threads

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.

elementss

Edited by mateusz-winiarczyk

Merge request reports

Merge request pipeline #84794 passed

Merge request pipeline passed for 6424fd28

Test coverage 92.35% (0.05%) from 1 job
Approved by

Merged by mateusz-winiarczykmateusz-winiarczyk 1 year ago (Jan 24, 2024 8:15am UTC)

Merge details

  • Changes merged into development with 9d60cc66 (commits were squashed).
  • Deleted the source branch.

Pipeline #84813 passed

Pipeline passed for 9d60cc66 on development

Test coverage 92.35% (0.05%) from 1 job

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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();
  • 1 import { Loading } from '@/types/loadingState';
    2
    3 export type ExportState = {
    4 downloadElements: {
    • I'm not a fan of lifting state to redux when it's not needed (at least I don't see use case in this example). Isn't it simpler to use axiosInstance.post(...) method in component without adding redux boilerplate?

    • @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
    • You are right, I forgot about this discussion. It makes sense

    • Please register or sign in to reply
  • Hej @mateusz-winiarczyk probably 2 RFC from my side

    1. Mocking network call in test
    2. Reducing redux boilerplate - it might be discussed
  • added 1 commit

    • 68e9e0f6 - test(export): mock http download csv request

    Compare with previous version

  • 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 => {
  • 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 });
  • 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 };
  • LGTM

    One RFC - extractAndParseNumberIdFromCompartment

  • Adrian Orłów approved this merge request

    approved this merge request

  • added 1 commit

    • 7ccb9d4d - feat(export): remove columns and types sections and adjust download file

    Compare with previous version

  • added 1 commit

    • 1134ad4f - fix(export): add handling for incorrect comparment id

    Compare with previous version

  • added 4 commits

    Compare with previous version

  • mateusz-winiarczyk changed the description

    changed the description

  • added 3 commits

    Compare with previous version

  • Adrian Orłów approved this merge request

    approved this merge request

  • mentioned in commit 9d60cc66

  • Please register or sign in to reply
    Loading