Repository navigation
feat(manager): persist access-key table sort preference #2885
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -651,11 +651,14 @@ export class ServerView extends DirMixin(PolymerElement) { | |
| ready() { | ||
| super.ready(); | ||
|
|
||
| this._restoreAccessKeySortPreference(); | ||
|
|
||
| this.addEventListener( | ||
| AccessKeyDataTableEvent.SORT, | ||
| (event: CustomEvent) => { | ||
| this.accessKeyDataSortDirection = event.detail.sortDirection; | ||
| this.accessKeyDataSortColumnId = event.detail.columnId; | ||
| this._persistAccessKeySortPreference(); | ||
| } | ||
| ); | ||
|
|
||
|
|
@@ -711,6 +714,45 @@ export class ServerView extends DirMixin(PolymerElement) { | |
| accessKeyData: AccessKeyDataTableRow[] = []; | ||
| accessKeyDataSortDirection: DataTableSortDirection; | ||
| accessKeyDataSortColumnId: string; | ||
|
|
||
| private _accessKeySortStorageKey(): string { | ||
| return `outline-manager-access-key-sort:${this.serverId || 'default'}`; | ||
| } | ||
|
|
||
| private _persistAccessKeySortPreference(): void { | ||
| try { | ||
| window.localStorage.setItem( | ||
| this._accessKeySortStorageKey(), | ||
| JSON.stringify({ | ||
| columnId: this.accessKeyDataSortColumnId, | ||
| sortDirection: this.accessKeyDataSortDirection, | ||
| }) | ||
| ); | ||
| } catch (e) { | ||
| // Ignore quota / private-mode failures. | ||
| } | ||
| } | ||
|
|
||
| private _restoreAccessKeySortPreference(): void { | ||
| try { | ||
| const raw = window.localStorage.getItem(this._accessKeySortStorageKey()); | ||
| if (!raw) { | ||
| return; | ||
| } | ||
| const parsed = JSON.parse(raw) as { | ||
| columnId?: string; | ||
| sortDirection?: DataTableSortDirection; | ||
| }; | ||
| if (parsed.columnId) { | ||
| this.accessKeyDataSortColumnId = parsed.columnId; | ||
| } | ||
| if (parsed.sortDirection) { | ||
| this.accessKeyDataSortDirection = parsed.sortDirection; | ||
|
Comment on lines
+746
to
+750
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If an update removes or renames a sortable column, Knowledge Base Used: Server operations console |
||
| } | ||
| } catch (e) { | ||
| // Ignore corrupt preference. | ||
| } | ||
| } | ||
| cloudId = ''; | ||
| cloudLocation: CloudLocation = null; | ||
| defaultDataLimitBytes: number = null; | ||
|
|
||
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.
The new save-and-restore path has no test for reopening the Manager or keeping two servers’ choices separate. Add coverage for both flows so a later change to view startup or server selection does not silently undo this feature.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!