-
Notifications
You must be signed in to change notification settings - Fork 75
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
Faulty list view when back navigating #1243
Faulty list view when back navigating #1243
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1243 +/- ##
==========================================
- Coverage 53.44% 53.10% -0.35%
==========================================
Files 103 105 +2
Lines 2928 2951 +23
Branches 544 549 +5
==========================================
+ Hits 1565 1567 +2
- Misses 1014 1030 +16
- Partials 349 354 +5 ☔ View full report in Codecov by Sentry. |
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.
Tested and it works well! Just some comment on code quality.
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.
I suggest the member fields to have proper type annotation, so that the compiler can detect errors if the fields are not assigned the correct value. Also, the fields should have proper initial values.
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.
Linter prevents me from adding type annotations to member fields that are initialized. Error: no-inferrable-types.
The initial values used are also what I deem proper as initially the tables are not sorted at all, internally matsort is initialised with an empty string which is what I am emulating here.
sortChange(newSort: Sort) { | ||
this.tableSettings.sortActiveId = newSort.active; | ||
this.tableSettings.sortDirection = newSort.direction; | ||
this.issueTableSettingsService.setTableSettings(this.table_name, this.tableSettings); | ||
} | ||
|
||
pageChange(pageEvent: PageEvent) { | ||
this.tableSettings.pageSize = pageEvent.pageSize; | ||
this.tableSettings.pageIndex = pageEvent.pageIndex; | ||
this.issueTableSettingsService.setTableSettings(this.table_name, this.tableSettings); | ||
} | ||
|
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.
I'm not sure if this is the best practice to sync settings of a table component with the service. I would suggest the following:
- Service's settings values to be of type
Observable<TableSettings>
- Table component settings to sync with service's settings value using
Observable::subscribe
- In these methods, only call
issueTableSettingsService::setTableSettings
@CATcher-org/2324s2 What do yall think?
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.
In this case wouldn't I still need these two functions to update the TableSettings in the service.
I am not sure of the benefit of the observable implementation since the only things listening and emitting these changes is from the tables component.
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.
i don't see the benefit for observables too. I think an observable implementation is beneficial if we have more than 1 table listening to the same set of settings but so far we are saving the settings for each table (or to be more precise table_name
, but currently each table has a unique table_name
).
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.
LGTM
@@ -0,0 +1,6 @@ | |||
export class TableSettings { | |||
public sortActiveId = ''; |
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.
mat-sort-active
is a angular-material term and may not be immediately obvious what it might be
perhaps some inline documentation so it will be clearer that sortActiveId
refers to the id of the column that the table is currently sorted by
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.
LGTM
private _tableSettingsMap: { [index: string]: TableSettings } = {}; | ||
|
||
public getTableSettings(tableName: string): TableSettings { | ||
console.log(this._tableSettingsMap); |
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.
Do remember to remove this console.log
line!
* Fix broken duplicate link (#1233) Fix the broken link of a duplicate issue Currently, the user cannot open the link to a duplicate issue when opening an issue, as described in #1228. The links now work as expected. * Add whitespace validation (#1237) * Add whitespace validation * Update whitespace validation for new issue * Update whitespace validation for title of new issues * Update whitespace validation for title of new issues * Move validators into core * Update import order --------- Co-authored-by: Misra Aditya <[email protected]> * Fix uncaught errors when attempting to access an invalid route There is an uncaught error when the users click on an invalid internal link in Markdown or enter an invalid link in browser. Internal links are unlikely to be used for bug reporting and are more likely to be invalid. Let's show an error toaster and stop the navigation when clicking on an internal link in Markdown. Also, redirect the users to the login page if the users enter invalid link in browser. * Set default branch to `main` Previously, image uploads depend on the user's default branch. Now, we set the branch for image upload to be `main`. Images will be uploaded to `main` as a result. --------- Co-authored-by: Chee Hong <[email protected]> * Preserve linebreaks (#1241) With preserving linebreaks, subset list items are rendered as a list, and paragraph rendering is the same as Github. * Faulty list view when back navigating (#1243) Issue table settings such as page index are not saved when table is re-mounted. This behavior inconveniences users as their settings are reset everytime they navigate to a specific issue and back. Let's lift up the table settings of each mounted table to a service which the tables pull from when mounted. * Upgrade to Angular 12 (#1242) Some of our packages are old and outdated. We should actively maintain and keep these packages up-to-date so it is easier to maintain in the future. Let's upgrade to Angular 12 to keep our packages up-to-date. * Fix markdown blockquote preview difference (#1245) Due to DOMPurify, the content used for preview is different. However, given that ngx-markdown already has sufficient sanitation by default, we remove sanitation by DOMPurify. * Create release for v3.5.3 --------- Co-authored-by: Nguyen <[email protected]> Co-authored-by: AdityaMisra <[email protected]> Co-authored-by: Misra Aditya <[email protected]> Co-authored-by: NereusWB922 <[email protected]> Co-authored-by: Chee Hong <[email protected]> Co-authored-by: Arif Khalid <[email protected]>
Summary:
Fixes #1227
Changes Made:
Proposed Commit Message: