-
Notifications
You must be signed in to change notification settings - Fork 35
fix: tables columns reset to default #2216
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
base: master
Are you sure you want to change the base?
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.
Hey - I've found 1 issue, and left some high level feedback:
- In both proposal and dataset tables, the previous fallback to store-derived default columns has been removed; consider preserving a fallback (e.g. to
defaultStoreColumns/defaultTableColumns.columns) whenappConfigdoes not define default list settings to avoid regressions or runtime issues. - You are casting
defaultConfigColumnstoTableColumn[]without checking forundefinedin both components; it would be safer to guard against missing config before callingconvertSavedColumnsor provide a sensible default array. - The
console.log("Dataset ngOnInit", ...)inDatasetTableComponentlooks like leftover debug logging and should be removed or routed through the application's logging mechanism.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In both proposal and dataset tables, the previous fallback to store-derived default columns has been removed; consider preserving a fallback (e.g. to `defaultStoreColumns` / `defaultTableColumns.columns`) when `appConfig` does not define default list settings to avoid regressions or runtime issues.
- You are casting `defaultConfigColumns` to `TableColumn[]` without checking for `undefined` in both components; it would be safer to guard against missing config before calling `convertSavedColumns` or provide a sensible default array.
- The `console.log("Dataset ngOnInit", ...)` in `DatasetTableComponent` looks like leftover debug logging and should be removed or routed through the application's logging mechanism.
## Individual Comments
### Comment 1
<location> `src/app/proposals/proposal-table/proposal-table.component.ts:130-131` </location>
<code_context>
const tableSort = this.getTableSort();
const paginationConfig = this.getTablePaginationConfig(count);
+ const defaultConfigColumns =
+ this.appConfig?.defaultDatasetsListSettings?.columns;
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard against missing or empty defaultConfigColumns before converting
Previously, missing/empty config columns fell back to `defaultStoreColumns`. Now `defaultConfigColumns` is passed straight into `convertSavedColumns` and cast to `TableColumn[]`, so an undefined/empty value could cause runtime errors or an empty table. Please either preserve the earlier fallback (e.g., to `userConfigColumns` or another default) or explicitly handle `!Array.isArray(defaultConfigColumns)` / `!defaultConfigColumns.length` before calling `convertSavedColumns`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| const defaultConfigColumns = | ||
| this.appConfig?.defaultProposalsListSettings?.columns; |
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.
issue (bug_risk): Guard against missing or empty defaultConfigColumns before converting
Previously, missing/empty config columns fell back to defaultStoreColumns. Now defaultConfigColumns is passed straight into convertSavedColumns and cast to TableColumn[], so an undefined/empty value could cause runtime errors or an empty table. Please either preserve the earlier fallback (e.g., to userConfigColumns or another default) or explicitly handle !Array.isArray(defaultConfigColumns) / !defaultConfigColumns.length before calling convertSavedColumns.
Junjiequan
left a comment
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.
looks good to me
) ## Description This PR updates the default frontend configuration with the latest settings for the columns of datasets and proposals lists. Frontend PR [2216](SciCatProject/frontend#2216) is the PR that uses this changes ## Motivation Frontend PR 2216 needs the new configuration file included in this PR ## Changes: * src/config/frontend.config.json ## Tests included - [ ] Included for each change/fix? - [ ] Passing? <!-- Merge will not be approved unless tests pass --> ## Documentation - [ ] swagger documentation updated (required for API changes) - [ ] official documentation updated ### official documentation info <!-- If you have updated the official documentation, please provide PR # and URL of the updated pages -->
Description
This PR enables the user to reload the default settings for datasets and proposals list tables, by selecting table settings menu -> default settings.
Once the default setting option is selected, the table columns will revert back to the defaults configured by the site admin and also the user settings are updated to contain the defaults.
Motivation
This PR is motivated by a better UX and to allow users to revert back to the default view configured by the site admin based to facility policies and to better show the data
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
Enable table columns in proposal and dataset lists to be reset to admin-defined defaults and persist those defaults to user settings.
New Features:
Enhancements: