diff --git a/src-ui/src/app/components/document-list/document-list.component.spec.ts b/src-ui/src/app/components/document-list/document-list.component.spec.ts index 60e3165bc..52681fe30 100644 --- a/src-ui/src/app/components/document-list/document-list.component.spec.ts +++ b/src-ui/src/app/components/document-list/document-list.component.spec.ts @@ -579,8 +579,6 @@ describe('DocumentListComponent', () => { expect(savedViewServiceCreate).toHaveBeenCalledWith( expect.objectContaining({ name: 'Foo Bar', - show_on_dashboard: false, - show_in_sidebar: false, owner: permissions.owner, set_permissions: permissions.set_permissions, }) diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts index d5674779d..b4d32857d 100644 --- a/src-ui/src/app/components/document-list/document-list.component.ts +++ b/src-ui/src/app/components/document-list/document-list.component.ts @@ -446,9 +446,6 @@ export class DocumentListComponent modal.componentInstance.buttonsEnabled = false let savedView: SavedView = { name: formValue.name, - // Visibility is in per-user UISettings. - show_on_dashboard: false, - show_in_sidebar: false, filter_rules: this.list.filterRules, sort_reverse: this.list.sortReverse, sort_field: this.list.sortField, diff --git a/src-ui/src/app/data/ui-settings.ts b/src-ui/src/app/data/ui-settings.ts index de3f1426c..cec804f99 100644 --- a/src-ui/src/app/data/ui-settings.ts +++ b/src-ui/src/app/data/ui-settings.ts @@ -255,12 +255,12 @@ export const SETTINGS: UiSetting[] = [ { key: SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS, type: 'array', - default: null, + default: [], }, { key: SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS, type: 'array', - default: null, + default: [], }, { key: SETTINGS_KEYS.DASHBOARD_VIEWS_SORT_ORDER, diff --git a/src-ui/src/app/services/rest/saved-view.service.spec.ts b/src-ui/src/app/services/rest/saved-view.service.spec.ts index 03c70d1b2..c72fb5409 100644 --- a/src-ui/src/app/services/rest/saved-view.service.spec.ts +++ b/src-ui/src/app/services/rest/saved-view.service.spec.ts @@ -57,6 +57,11 @@ describe(`Additional service tests for SavedViewService`, () => { let settingsService it('should retrieve saved views and sort them', () => { + jest.spyOn(settingsService, 'get').mockImplementation((key) => { + if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS) return [1, 2, 3] + if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS) return [1, 2, 3] + return [] + }) service.reload() const req = httpTestingController.expectOne( `${environment.apiBaseUrl}${endpoint}/?page=1&page_size=100000` @@ -93,7 +98,9 @@ describe(`Additional service tests for SavedViewService`, () => { it('should sort dashboard views', () => { service['savedViews'] = saved_views jest.spyOn(settingsService, 'get').mockImplementation((key) => { + if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS) return [1, 2, 3] if (key === SETTINGS_KEYS.DASHBOARD_VIEWS_SORT_ORDER) return [3, 1, 2] + return [] }) expect(service.dashboardViews).toEqual([ saved_views[2], @@ -114,7 +121,9 @@ describe(`Additional service tests for SavedViewService`, () => { it('should sort sidebar views', () => { service['savedViews'] = saved_views jest.spyOn(settingsService, 'get').mockImplementation((key) => { + if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS) return [1, 2, 3] if (key === SETTINGS_KEYS.SIDEBAR_VIEWS_SORT_ORDER) return [3, 1, 2] + return [] }) expect(service.sidebarViews).toEqual([ saved_views[2], diff --git a/src-ui/src/app/services/rest/saved-view.service.ts b/src-ui/src/app/services/rest/saved-view.service.ts index e2f7ad13b..d9baec22b 100644 --- a/src-ui/src/app/services/rest/saved-view.service.ts +++ b/src-ui/src/app/services/rest/saved-view.service.ts @@ -67,9 +67,9 @@ export class SavedViewService extends AbstractPaperlessService { return this.savedViews } - private getVisibleViewIds(setting: string): number[] | null { + private getVisibleViewIds(setting: string): number[] { const configured = this.settingsService.get(setting) - return Array.isArray(configured) ? configured : null + return Array.isArray(configured) ? configured : [] } private withUserVisibility(view: SavedView): SavedView { @@ -84,14 +84,14 @@ export class SavedViewService extends AbstractPaperlessService { const visibleIds = this.getVisibleViewIds( SETTINGS_KEYS.DASHBOARD_VIEWS_VISIBLE_IDS ) - return visibleIds ? visibleIds.includes(view.id) : !!view.show_on_dashboard + return visibleIds.includes(view.id) } private isSidebarVisible(view: SavedView): boolean { const visibleIds = this.getVisibleViewIds( SETTINGS_KEYS.SIDEBAR_VIEWS_VISIBLE_IDS ) - return visibleIds ? visibleIds.includes(view.id) : !!view.show_in_sidebar + return visibleIds.includes(view.id) } get sidebarViews(): SavedView[] {