Skip to content

Commit

Permalink
added isVisible to page props
Browse files Browse the repository at this point in the history
  • Loading branch information
Adama Camara authored and Adama Camara committed Sep 28, 2022
1 parent 94ff387 commit df2a541
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 156 deletions.
7 changes: 6 additions & 1 deletion src/adminjs-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TransformOptions as BabelConfig } from 'babel-core'

import BaseResource from './backend/adapters/resource/base-resource'
import BaseDatabase from './backend/adapters/database/base-database'
import { PageContext } from './backend/actions/action.interface'
import { IsFunction, PageContext } from './backend/actions/action.interface'
import { ResourceOptions } from './backend/decorators/resource/resource-options.interface'
import { Locale } from './locale/config'
import { CurrentAdmin } from './current-admin.interface'
Expand Down Expand Up @@ -389,6 +389,11 @@ export type AdminPage = {
* Page icon
*/
icon?: string;

/**
* Page visibility
*/
isVisible?: boolean | IsFunction
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/frontend/components/actions/action.props.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dispatch, SetStateAction } from 'react'
import { ActionJSON, RecordJSON, ResourceJSON, PageJSON } from '../../interfaces'
import { ActionJSON, RecordJSON, ResourceJSON } from '../../interfaces'

/**
* Props which are passed to all action components
Expand All @@ -10,23 +10,23 @@ export type ActionProps = {
/**
* Action object describing the action
*/
action: ActionJSON
action: ActionJSON;
/**
* Object of type: {@link ResourceJSON}
*/
resource: ResourceJSON
resource: ResourceJSON;
/**
* Selected record. Passed for actions with "record" actionType
*/
record?: RecordJSON
record?: RecordJSON;

/**
* Selected records. Passed for actions with "bulk" actionType
*/
records?: Array<RecordJSON>
records?: Array<RecordJSON>;

/**
* Sets tag in a header of an action. It is a function taking tag as an argument
*/
setTag?: Dispatch<SetStateAction<string>>
}
setTag?: Dispatch<SetStateAction<string>>;
}
8 changes: 8 additions & 0 deletions src/frontend/interfaces/page-json.interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { IsFunction } from 'src/backend'
import { ActionJSON } from './action'

/**
* Representing the page in the sidebar
* @subcategory Frontend
Expand All @@ -16,4 +19,9 @@ export interface PageJSON {
* Page icon
*/
icon?: string;

/**
* Page visibility
*/
isVisible: boolean | IsFunction;
}
5 changes: 3 additions & 2 deletions src/frontend/store/pages-to-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { AdminJSOptions } from '../../adminjs-options.interface'

import { PageJSON } from '../interfaces'

const pagesToStore = (pages: AdminJSOptions['pages'] = {}): Array<PageJSON> => Object.entries(pages)
.map(([key, adminPage]) => ({
const pagesToStore = (pages: AdminJSOptions['pages'] = {}): Array<PageJSON> =>
Object.entries(pages).map(([key, adminPage]) => ({
name: key,
component: adminPage.component,
icon: adminPage.icon,
isVisible: adminPage.isVisible,
}))

export default pagesToStore
Loading

0 comments on commit df2a541

Please sign in to comment.