Skip to content
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

Ia 2976 remove single table #1322

Merged
merged 59 commits into from
Jun 19, 2024
Merged

Ia 2976 remove single table #1322

merged 59 commits into from
Jun 19, 2024

Conversation

quang-le
Copy link
Member

@quang-le quang-le commented May 22, 2024

The (deprecated) SingleTable component was causing double API fetching in Forms page and making parts of the codebase hard to maintain

Related JIRA tickets : IA-2976, IA-2983, IA-989, IA-1730, IA-1719, IA-1714, IA-1705

Self proofreading checklist

  • Did I use eslint and black formatters
  • Is my code clear enough and well documented
  • Are my typescript files well typed
  • New translations have been added or updated if new strings have been introduced in the frontend
  • My migrations file are included
  • Are there enough tests
  • Documentation has been included (for new feature)

Doc

  • Comments in the code

Changes

  • Forms:

    • Add FormsTable components based on TableWithDeepLink
    • Replace SingleTable
    • Replace SingleTable for "Forms" tab in Org unit details
    • Move API calls to react-query
    • Add custom success messages for form deletion and restoration
    • Remove unused query params all from API calls
    • Remove searchActive params: was not working, and the actual behaviour was correct that way
    • Add method to generate csv and xlsx download urls
  • Form versions:

    • Add FormVersions table
    • Convert method to get columns to hook
    • Add useGetFormVersions hook to replace redux fetching
    • Replace useEffect with useMemo in FormVersionsDialog
  • Data sources:

    • Add react-query hooks to replace redux fetching
    • move table column config in hook
    • Replace FormattedMessage with formatMessage
    • Force re-render of index via react-query key invalidation, i.o forceRefresh state value
    • delete obsolete request
  • Devices:

    • Convert main component to TS
    • Convert method to get columns to hook
    • Move API calls to react-query
    • Replace SingleTable with TableWithDeepLink
  • Org Unit History:

    • Move Logs components to org units, as they are not so generic
    • Add useGetLogs and useGetLogsDetails hooks (generic, so not in org units folder)
    • Convert LogsComponent to TS
    • Convert LogsDetails to TS and to function component
    • delete fetchLogDetails 'redux' request
  • Links:

    • Add react-query hooks to fetch all filter dropdowns
    • Add react-query hook to update/validate links
    • Add LinkFilters and LinkTable components
    • Add LinkTableWithDownloads component, that wraps the LinkTable and the DownloadButtonsComponent, handles loading state, conditional rendering and url formatting for both, and can be passed filters as children, so it's easily reusable in org unit details.
    • remove unused APi call from queries array
    • Convert config and messages to TS
  • Org Unit Details Links:

    • Add OrgUnitLinks component: uses LinksWithDownloadButtons and a LinkFilters made specifically for the links tab
  • Org Unit Details Children:

    • Add custom Filter and Table components
    • Add API hooks to get data and dropdown data when necessary
    • Add hooks for location and instances dropdowns
    • Add custom hook to handle 'Only direct childre" filter, as the name of the param to send to the APi changes with the filter value
    • Fix some TS issues
  • Org Unit Details (general):

    • Replace classes.hiddenOpacity with conditional rendering for all tabs. (This fixes IA-3026)
    • Add useOrgUnitTabParams hook to pass the correct params (with Prefixes) to the tab tables
    • Move all params Prefixes to constants in urls.ts
    • Replace all methods generating the params with prefixes with plain arrays in urls.ts (easier to read)
    • Fix query key of the groups API call, so that the right params are sent to the API
  • Algorithm Runs:

    • Move components to own folder
    • Add filters component
    • Add API hooks
    • Rewrite "Add run" modal: remove deprecated modal, add formik, add validation
    • update import in routes.tsx
    • Convert to TS
  • Redux:

    • remove obsolete redux API calls (in requests.js)
    • remove links from the store

SingleTable
- Delete component
- Delete all filter configs

  • Other changes:
    • Improve typing of useApiParams
    • Remove useless state in PeriodPicker
    • Add useTableState hook to handle ordering and pagination for non-deep-linked tables
    • Add method o useFilterState to update the whole state while also handling filtersUpdatedstatus
    • Update useFilterState to have finer managment of filtersUpdated
    • Enable useFilterState to launch search when filter not updated
    • Add makeQueryString and useQueryString utils in routing
    • Delete duplicate useGetOrgUnitTypes hook
    • Remove useless cy.intercept in Org unit tab tests
    • Remove useless cy.visit in forms cypress test (halves duration of that test)

How to test

  • For each domain impacted:
    • go to the page
    • test the table:
      • data loading and rendering
      • sorting/ordering
      • pagination
      • filters when they exist
      • deep linking when applicale
      • xlsx, csv and gpkg download when applicable

Print screen / video

Nothing should change

Notes

  • cypress successful run: https://github.com/BLSQ/iaso/actions/runs/9452079172

  • Sorry for the PR size, it just got much bigger than expected, especially when refactoring class components became unavoidable

  • TS typing may be a bit light in some places, but I think this can be fixed separately

quang-le added 4 commits May 22, 2024 10:36
- Use TableWithDeepLink
- move API calls to react-query
- Update useFilterState to have finer managment of filtersUpdated
- Add method to generate csv and xlsx download urls
- Add custom success messages for form deletion and restoration
@quang-le quang-le marked this pull request as draft May 22, 2024 15:37
@quang-le quang-le changed the base branch from main to IA-2966_add_react_router_doc May 22, 2024 15:46
quang-le added 24 commits May 23, 2024 10:15
- remove SingleTable
- Adapt FormsTable to handle params with prefix
- Remove "all=true" query param from useGetForms as doesn't do anything
- Add react-query hooks to fetch all filter dropdowns
- Add react-quzry hook to update/validate links
- Add LinkFilters and LinkTable components
- Add makeQueryString utils in routing
- Add method to update the whole state while also handling filtersUpdated status
- remove useless param from csv and xlsx urls
- Add comment/doc about useGetForm use
- Simplify params for forms fetching in FormsTable
- Delete unused "redux" requests
- Add custom link filters for the org unit details links tab
- remove obsolete redux AI calls
- remove unused SingleTable filter configs
- remove unused APi call from queries array
- Add FormVersions table
- convert method to get colulmns to hook
- improve typing of useApiParams
- add useGetFormVersions hook
- Remove useless state in PeriodPicker
- Replace useEffect with useMemo in FormVersionsDialog
- Move Logs components to org units, as they are not so generic
- Add useGetLogs and useGetLogsDetails hooks (generic, so not in org units folder)
- Convert LogsComponent to TS
- Convert LogsDetails to TS and to function component
- delete fetchLogDetails 'redux' request
- Add react-query hooks
- remove redux fetching
- move table column config in hook
- remove FormattedMessage
- Force re-render of index.js via react-query key invalidation, i.o "forceRefresh" state value
- delete (now) unused request
@quang-le quang-le changed the base branch from IA-2966_add_react_router_doc to main June 5, 2024 11:07
quang-le added 10 commits June 10, 2024 16:23
- adapt list test: download buttons are disabled i.o. not rendered if no results
- adapt API urls in tables and hooks so they are consistent (i.e always include table params)
- wait for necessary requests
- remove unnecessarty intercepts
- Add default values for table params in OrgUnitChildren
- Make validation status non clearable in filter
- remove useless intercepts in test
- fix urls in tests
- Add LinkTableWithDownoads component
- Refactor LinkTable to receive data, params and other url related data as props, i.o fetching it itself
- Refactor Links to use LinkTableWithDownloads
- Add OrgUnitLinks component and use it in org unit details
…no data

- to avoid infinite error loop in FormVersions
- Pass tableDefaults as prop to the table to make the default behaviour clearer
@quang-le quang-le marked this pull request as ready for review June 10, 2024 16:18
@beygorghor beygorghor added the postrelease Should be merged just after the release label Jun 12, 2024
Copy link
Collaborator

@beygorghor beygorghor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small remarks. Very nice job! Iaso codebase is looking better everyday 😃

@quang-le quang-le merged commit 869979c into main Jun 19, 2024
3 checks passed
@quang-le quang-le deleted the IA-2976_remove_SingleTable branch June 19, 2024 07:17
@quang-le quang-le added Released and removed postrelease Should be merged just after the release labels Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants