Skip to content

Commit df2a541

Browse files
Adama CamaraAdama Camara
Adama Camara
authored and
Adama Camara
committed
added isVisible to page props
1 parent 94ff387 commit df2a541

File tree

5 files changed

+145
-156
lines changed

5 files changed

+145
-156
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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Dispatch, SetStateAction } from 'react'
2-
import { ActionJSON, RecordJSON, ResourceJSON, PageJSON } from '../../interfaces'
2+
import { ActionJSON, RecordJSON, ResourceJSON } from '../../interfaces'
33

44
/**
55
* Props which are passed to all action components
@@ -10,23 +10,23 @@ export type ActionProps = {
1010
/**
1111
* Action object describing the action
1212
*/
13-
action: ActionJSON
13+
action: ActionJSON;
1414
/**
1515
* Object of type: {@link ResourceJSON}
1616
*/
17-
resource: ResourceJSON
17+
resource: ResourceJSON;
1818
/**
1919
* Selected record. Passed for actions with "record" actionType
2020
*/
21-
record?: RecordJSON
21+
record?: RecordJSON;
2222

2323
/**
2424
* Selected records. Passed for actions with "bulk" actionType
2525
*/
26-
records?: Array<RecordJSON>
26+
records?: Array<RecordJSON>;
2727

2828
/**
2929
* Sets tag in a header of an action. It is a function taking tag as an argument
3030
*/
31-
setTag?: Dispatch<SetStateAction<string>>
32-
}
31+
setTag?: Dispatch<SetStateAction<string>>;
32+
}

src/frontend/interfaces/page-json.interface.ts

Lines changed: 8 additions & 0 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
@@ -16,4 +19,9 @@ export interface PageJSON {
1619
* Page icon
1720
*/
1821
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)