refactor(PublishedData): replace published data table with dynamic mat table#2358
Open
abdimo101 wants to merge 8 commits into
Open
refactor(PublishedData): replace published data table with dynamic mat table#2358abdimo101 wants to merge 8 commits into
abdimo101 wants to merge 8 commits into
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The new
loadData/getSortflow mixes parameters and internal state (e.g.loadData(filters, ...)then readingthis.currentFilters.sortFieldinstead offilters.sortField), and also leaves theconst [field, direction]destructuring inngOnInitunused, so it would be good to either consistently derive sort from the passed filters or remove the unused code to avoid confusion. - The
pendingflag is alwaysfalseand never updated aroundloadAllData, so the dynamic table’s loading state will never be shown; consider togglingpendingwhen issuing requests and when data arrives (e.g. aroundloadDataor via the data source observables). - The previous table supported row navigation and DOI sharing (
onRowClick,onShareClick, selection handlers), but these behaviors have been removed with the switch todynamic-mat-table; if they are still required, consider re-implementing them via row click handlers or action menus on the new table.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `loadData`/`getSort` flow mixes parameters and internal state (e.g. `loadData(filters, ...)` then reading `this.currentFilters.sortField` instead of `filters.sortField`), and also leaves the `const [field, direction]` destructuring in `ngOnInit` unused, so it would be good to either consistently derive sort from the passed filters or remove the unused code to avoid confusion.
- The `pending` flag is always `false` and never updated around `loadAllData`, so the dynamic table’s loading state will never be shown; consider toggling `pending` when issuing requests and when data arrives (e.g. around `loadData` or via the data source observables).
- The previous table supported row navigation and DOI sharing (`onRowClick`, `onShareClick`, selection handlers), but these behaviors have been removed with the switch to `dynamic-mat-table`; if they are still required, consider re-implementing them via row click handlers or action menus on the new table.
## Individual Comments
### Comment 1
<location path="src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.ts" line_range="101-102" />
<code_context>
+ const { skip, limit, sortField } = vm.filters;
+ const pageIndex = skip / limit;
+
+ const [field, direction] = sortField
+ ? sortField.split(" ")
+ : ["", "asc"];
+
</code_context>
<issue_to_address>
**nitpick:** Remove unused `field`/`direction` variables in `ngOnInit`.
`field` and `direction` from `sortField` in `ngOnInit` are never used, and `loadData` already derives sorting via `getSort`. Please remove this unused destructuring to avoid confusion about the sort source of truth.
</issue_to_address>
### Comment 2
<location path="src/app/publisheddata/publisheddata-dashboard/publisheddata-dashboard.component.ts" line_range="162-169" />
<code_context>
+ return sortField ? sortField.split(" ") : ["", "asc"];
+ }
+
+ loadData(filters: any, pageIndex: number, pageSize: number) {
+ const [field, direction] = this.getSort();
+ this.scicatDataSource.loadAllData(
+ filters,
+ field,
+ direction,
+ pageIndex,
+ pageSize,
+ );
}
</code_context>
<issue_to_address>
**issue (bug_risk):** `loadData` ignores the `filters` argument for sorting and relies on `currentFilters`, which may be stale.
Because `getSort` reads from `this.currentFilters`, there are paths (e.g. `onGlobalTextSearchAction`) where `loadData` is invoked before `currentFilters` is updated, so the request can be sent with stale sort parameters. Consider either deriving `field`/`direction` directly from the `filters` argument, or updating `this.currentFilters` before calling `loadData` and then always treating `currentFilters` as the single source of truth.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…t/frontend into replace-publisheddata-table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR replaces the old published data table with dynamic mat table & adds published data columns to externalSettings
Motivation
Background on use case, changes needed
Fixes:
Please provide a list of the fixes implemented in this PR
Changes:
Please provide a list of the changes implemented by this PR
Tests included
Documentation
official documentation info
If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included
Backend version
Summary by Sourcery
Replace the published data dashboard table with a dynamic Material table using server-side pagination and global text search.
New Features:
Enhancements: