Skip to content

Commit ad6b8f0

Browse files
Adama CamaraAdama Camara
authored andcommitted
added isVisible to page props
1 parent 94ff387 commit ad6b8f0

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/adminjs-options.interface.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TransformOptions as BabelConfig } from 'babel-core'
33

44
import BaseResource from './backend/adapters/resource/base-resource'
55
import BaseDatabase from './backend/adapters/database/base-database'
6-
import { PageContext } from './backend/actions/action.interface'
6+
import { IsFunction, PageContext } from './backend/actions/action.interface'
77
import { ResourceOptions } from './backend/decorators/resource/resource-options.interface'
88
import { Locale } from './locale/config'
99
import { CurrentAdmin } from './current-admin.interface'
@@ -389,6 +389,11 @@ export type AdminPage = {
389389
* Page icon
390390
*/
391391
icon?: string;
392+
393+
/**
394+
* Page visibility
395+
*/
396+
isVisible?: boolean | IsFunction
392397
}
393398

394399
/**
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { IsFunction } from 'src/backend'
2+
import { ActionJSON } from './action'
3+
14
/**
25
* Representing the page in the sidebar
36
* @subcategory Frontend
@@ -6,14 +9,19 @@ export interface PageJSON {
69
/**
710
* Page name
811
*/
9-
name: string;
12+
name: string
1013
/**
1114
* Page component. Bundled with {@link AdminJS.bundle}
1215
*/
13-
component: string;
16+
component: string
1417

1518
/**
1619
* Page icon
1720
*/
18-
icon?: string;
21+
icon?: string
22+
23+
/**
24+
* Page visibility
25+
*/
26+
isVisible: boolean | IsFunction
1927
}

src/frontend/store/pages-to-store.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { AdminJSOptions } from '../../adminjs-options.interface'
22

33
import { PageJSON } from '../interfaces'
44

5-
const pagesToStore = (pages: AdminJSOptions['pages'] = {}): Array<PageJSON> => Object.entries(pages)
6-
.map(([key, adminPage]) => ({
5+
const pagesToStore = (pages: AdminJSOptions['pages'] = {}): Array<PageJSON> =>
6+
Object.entries(pages).map(([key, adminPage]) => ({
77
name: key,
88
component: adminPage.component,
99
icon: adminPage.icon,
10+
isVisible: adminPage.isVisible,
1011
}))
1112

1213
export default pagesToStore

0 commit comments

Comments
 (0)