feat: add configurable default tab for proposal details page#2206
Open
feat: add configurable default tab for proposal details page#2206
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The
tabIndexMapkey type anddefaultProposalTab?: stringare both untyped strings; consider tightening this to a string union (e.g.'details' | 'datasets' | 'relatedProposals' | 'logbook') to catch invalid config values at compile time. - The
tabIndexMapwith hard-coded indices can easily get out of sync if tab order changes; consider deriving indices from the template (e.g. via an enum or a single source of truth for tab definitions) rather than maintaining a separate map. - The Cypress test asserts using
ng-reflect-selected-index, which is an internal Angular implementation detail; it would be more robust to assert the active tab via visible text or CSS classes (e.g. usingmat-tab-labeland checking for themat-tab-label-activeclass).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `tabIndexMap` key type and `defaultProposalTab?: string` are both untyped strings; consider tightening this to a string union (e.g. `'details' | 'datasets' | 'relatedProposals' | 'logbook'`) to catch invalid config values at compile time.
- The `tabIndexMap` with hard-coded indices can easily get out of sync if tab order changes; consider deriving indices from the template (e.g. via an enum or a single source of truth for tab definitions) rather than maintaining a separate map.
- The Cypress test asserts using `ng-reflect-selected-index`, which is an internal Angular implementation detail; it would be more robust to assert the active tab via visible text or CSS classes (e.g. using `mat-tab-label` and checking for the `mat-tab-label-active` class).
## Individual Comments
### Comment 1
<location> `src/app/app-config.service.ts:165` </location>
<code_context>
checkBoxFilterClickTrigger?: boolean;
hideEmptyMetadataTable?: boolean;
ingestorComponent?: IngestorComponentConfig;
+ defaultProposalTab?: string;
}
</code_context>
<issue_to_address>
**suggestion:** Narrow `defaultProposalTab` to a string-literal union to ensure only supported tabs are configured.
Since `defaultProposalTab` is typed as a plain `string`, invalid values won’t be caught until runtime and you’re relying on `resetTabs`’s fallback behavior. Consider restricting this to a union of the supported tabs (e.g. `defaultProposalTab?: 'details' | 'datasets' | 'relatedProposals' | 'logbook'`, or a type derived from `tabIndexMap`) so misconfigurations are caught at compile time and stay aligned with the component logic.
Suggested implementation:
```typescript
checkBoxFilterClickTrigger?: boolean;
hideEmptyMetadataTable?: boolean;
ingestorComponent?: IngestorComponentConfig;
defaultProposalTab?: 'details' | 'datasets' | 'relatedProposals' | 'logbook';
}
```
If there is a centralized source of truth for tab keys (e.g. a `tabIndexMap` or `type ProposalTab = keyof typeof tabIndexMap`), consider:
1. Extracting a reusable type, e.g. `type ProposalTab = keyof typeof tabIndexMap;`
2. Updating this property to `defaultProposalTab?: ProposalTab;`
This will ensure the config type stays automatically aligned if tabs are added or renamed.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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 adds a new config
defaultTabthat contains for now propertyproposalwhich allows users to set which tab should be displayed by default when viewing a proposal details page. The config accepts values like "details", "datasets", "relatedProposals" or "logbook". If not specified or if the given value is invalid, it will default to "details".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
Add support for configuring the default tab shown on the proposal details page and cover it with end-to-end tests.
New Features:
Tests: