Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions server_manager/www/ui_components/outline-server-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,14 @@ export class ServerView extends DirMixin(PolymerElement) {
ready() {
super.ready();

this._restoreAccessKeySortPreference();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Saved sorts lack tests

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!


this.addEventListener(
AccessKeyDataTableEvent.SORT,
(event: CustomEvent) => {
this.accessKeyDataSortDirection = event.detail.sortDirection;
this.accessKeyDataSortColumnId = event.detail.columnId;
this._persistAccessKeySortPreference();
}
);

Expand Down Expand Up @@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Old sort choices stop working

If an update removes or renames a sortable column, _restoreAccessKeySortPreference() still applies its saved name. The table then shows the keys unsorted without clearing that choice. Check the saved column and direction before applying them, and use a default when either is no longer valid.

Knowledge Base Used: Server operations console

}
} catch (e) {
// Ignore corrupt preference.
}
}
cloudId = '';
cloudLocation: CloudLocation = null;
defaultDataLimitBytes: number = null;
Expand Down