# @keystonejs/app-admin-ui

> KeystoneJS Admin UI App.

Latest version **7.5.2** (published 2021-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @keystonejs/app-admin-ui
pnpm add @keystonejs/app-admin-ui
yarn add @keystonejs/app-admin-ui
bun add @keystonejs/app-admin-ui
```

## Health

**Score 28/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 7.5.2 |
| Published | 2021-05-26 |
| First published | 2019-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/keystonejs__app-admin-ui) |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 72 |
| Unpacked size | 372.6 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 68 |
| Author | The KeystoneJS Development Team |
| Maintainers | bladey, jedwatson, molomby, jesstelford, mitchellhamilton, timl, madebymike |

## Links

- npm: https://www.npmjs.com/package/@keystonejs/app-admin-ui
- Repository: https://github.com/keystonejs/keystone-5/tree/main/packages/app-admin-ui
- npm.io page: https://npm.io/package/@keystonejs/app-admin-ui

## Dependencies (72)

- [react](https://npm.io/package/react.md) ^17.0.2
- [falsey](https://npm.io/package/falsey.md) ^1.0.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [graphql](https://npm.io/package/graphql.md) ^15.5.0
- [webpack](https://npm.io/package/webpack.md) 4.46.0
- [raf-schd](https://npm.io/package/raf-schd.md) ^4.0.3
- [apply-ref](https://npm.io/package/apply-ref.md) ^1.0.0
- [react-dom](https://npm.io/package/react-dom.md) ^17.0.2
- [react-uid](https://npm.io/package/react-uid.md) ^2.3.1
- [css-loader](https://npm.io/package/css-loader.md) ^5.2.6
- [lodash.set](https://npm.io/package/lodash.set.md) ^4.3.2
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.14.3
- [compression](https://npm.io/package/compression.md) ^1.7.4
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.1.4
- [file-loader](https://npm.io/package/file-loader.md) ^6.2.0
- [memoize-one](https://npm.io/package/memoize-one.md) ^5.2.1
- [@types/react](https://npm.io/package/@types/react.md) ^17.0.6
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.2.2
- [react-select](https://npm.io/package/react-select.md) ^3.2.0
- [style-loader](https://npm.io/package/style-loader.md) ^1.3.0
- [@arch-ui/card](https://npm.io/package/@arch-ui/card.md) ^0.0.18
- [@arch-ui/pill](https://npm.io/package/@arch-ui/pill.md) ^0.1.21
- [@emotion/core](https://npm.io/package/@emotion/core.md) ^10.1.1
- [@apollo/client](https://npm.io/package/@apollo/client.md) ^3.3.19
- [@arch-ui/alert](https://npm.io/package/@arch-ui/alert.md) ^0.0.21
- [@arch-ui/badge](https://npm.io/package/@arch-ui/badge.md) ^0.0.20
- [@arch-ui/hooks](https://npm.io/package/@arch-ui/hooks.md) ^0.0.14
- [@arch-ui/input](https://npm.io/package/@arch-ui/input.md) ^0.1.14
- [@arch-ui/theme](https://npm.io/package/@arch-ui/theme.md) ^0.0.14
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.14.0
- [clipboard-copy](https://npm.io/package/clipboard-copy.md) ^4.0.1
- [@arch-ui/button](https://npm.io/package/@arch-ui/button.md) ^0.0.25
- [@arch-ui/common](https://npm.io/package/@arch-ui/common.md) ^0.0.15
- [@arch-ui/dialog](https://npm.io/package/@arch-ui/dialog.md) ^0.0.28
- [@arch-ui/drawer](https://npm.io/package/@arch-ui/drawer.md) ^0.0.28
- [@arch-ui/fields](https://npm.io/package/@arch-ui/fields.md) ^3.0.8
- [@arch-ui/layout](https://npm.io/package/@arch-ui/layout.md) ^0.2.17
- [@arch-ui/navbar](https://npm.io/package/@arch-ui/navbar.md) ^0.1.15
- [@arch-ui/popout](https://npm.io/package/@arch-ui/popout.md) ^0.0.26
- [@arch-ui/select](https://npm.io/package/@arch-ui/select.md) ^0.1.12
- [lodash.debounce](https://npm.io/package/lodash.debounce.md) ^4.0.8
- [lodash.throttle](https://npm.io/package/lodash.throttle.md) ^4.1.1
- [@arch-ui/confirm](https://npm.io/package/@arch-ui/confirm.md) ^0.0.26
- [@arch-ui/loading](https://npm.io/package/@arch-ui/loading.md) ^0.0.21
- [@arch-ui/lozenge](https://npm.io/package/@arch-ui/lozenge.md) ^0.0.20
- [@arch-ui/options](https://npm.io/package/@arch-ui/options.md) ^0.0.27
- [@arch-ui/tooltip](https://npm.io/package/@arch-ui/tooltip.md) ^0.1.17
- [react-router-dom](https://npm.io/package/react-router-dom.md) 5.2.0
- [@arch-ui/controls](https://npm.io/package/@arch-ui/controls.md) ^0.1.12
- [@arch-ui/dropdown](https://npm.io/package/@arch-ui/dropdown.md) ^0.0.25
- [@keystonejs/utils](https://npm.io/package/@keystonejs/utils.md) ^6.1.2
- [react-prop-toggle](https://npm.io/package/react-prop-toggle.md) ^1.0.2
- [@keystonejs/fields](https://npm.io/package/@keystonejs/fields.md) ^22.1.3
- [react-pseudo-state](https://npm.io/package/react-pseudo-state.md) ^2.2.2
- [@arch-ui/pagination](https://npm.io/package/@arch-ui/pagination.md) ^0.0.29
- [@arch-ui/typography](https://npm.io/package/@arch-ui/typography.md) ^0.0.21
- [@keystonejs/session](https://npm.io/package/@keystonejs/session.md) ^8.3.2
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^4.5.2
- [use-resize-observer](https://npm.io/package/use-resize-observer.md) ^6.1.0
- [@arch-ui/color-utils](https://npm.io/package/@arch-ui/color-utils.md) ^0.0.5
- [apollo-upload-client](https://npm.io/package/apollo-upload-client.md) ^14.1.3
- [babel-plugin-emotion](https://npm.io/package/babel-plugin-emotion.md) ^10.2.2
- [@primer/octicons-react](https://npm.io/package/@primer/octicons-react.md) ^11.3.0
- [babel-preset-react-app](https://npm.io/package/babel-preset-react-app.md) ^10.0.0
- [react-transition-group](https://npm.io/package/react-transition-group.md) ^4.4.1
- [webpack-dev-middleware](https://npm.io/package/webpack-dev-middleware.md) ^3.7.3
- [webpack-hot-middleware](https://npm.io/package/webpack-hot-middleware.md) ^2.25.0
- [resize-observer-polyfill](https://npm.io/package/resize-observer-polyfill.md) ^1.5.1
- [react-toast-notifications](https://npm.io/package/react-toast-notifications.md) ^2.4.4
- [express-history-api-fallback](https://npm.io/package/express-history-api-fallback.md) ^2.2.1
- [@keystonejs/field-views-loader](https://npm.io/package/@keystonejs/field-views-loader.md) ^6.1.2

## Recent versions

- 7.5.2 (latest) — 2021-05-26
- 7.3.13 (rotunda) — 2021-01-17
- 7.3.12 (oculus) — 2020-12-11
- 7.3.11 (minaret) — 2020-11-29
- 7.3.10 (lintel) — 2020-11-22
- 7.3.9 (ionic) — 2020-11-03
- 7.3.8 (hyphen) — 2020-10-05
- 7.3.7 (dormer) — 2020-09-27
- 7.3.6 (cornice) — 2020-09-21
- 7.3.5 (buttress) — 2020-09-13
- 7.5.1 — 2021-04-14
- 7.5.0 — 2021-02-24
- 7.4.1 — 2021-02-22
- 7.4.0 — 2021-02-14
- 7.3.4 — 2020-09-06
- … 44 more at https://npm.io/package/@keystonejs/app-admin-ui/versions

## README

<!--[meta]
section: api
subSection: apps
title: Admin UI app
[meta]-->

# Admin UI app

> This is the last active development release of this package as **Keystone 5** is now in a 6 to 12 month active maintenance phase. For more information please read our [Keystone 5 and beyond](https://github.com/keystonejs/keystone-5/issues/21) post.

[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/app-admin-ui)

A KeystoneJS app which provides an Admin UI for content management.

## Usage

```js
const { Keystone } = require('@keystonejs/keystone');
const { GraphQLApp } = require('@keystonejs/app-graphql');
const { AdminUIApp } = require('@keystonejs/app-admin-ui');

const keystone = new Keystone({...});

const authStrategy = keystone.createAuthStrategy({...});

module.exports = {
  keystone,
  apps: [
    new GraphQLApp(),
    new AdminUIApp({
      adminPath: '/admin',
      authStrategy,
    }),
  ],
};
```

## Config

| Option               | Type       | Default       | Description                                                                |
| -------------------- | ---------- | ------------- | -------------------------------------------------------------------------- |
| `name`               | `String`   | `undefined`   | The name of the project.                                                   |
| `adminPath`          | `String`   | `/admin`      | The path of the Admin UI.                                                  |
| `apiPath`            | `String`   | `/admin/api`  | The path of the API provided to the Admin UI.                              |
| `graphiqlPath`       | `String`   | `/admin/api`  | The path of the GraphQL Playground, an in-browser GraphQL IDE.             |
| `authStrategy`       | `Object`   | `null`        | See [Authentication Guides](https://keystonejs.com/guides/authentication)  |
| `hooks`              | `String`   | `./admin-ui/` | Path to customization hooks. See below for more information.               |
| `enableDefaultRoute` | `Bool`     | `false`       | If enabled, the path of the Admin UI app will be set to `/`.               |
| `schemaName`         | `String`   | `public`      |                                                                            |
| `isAccessAllowed`    | `Function` | `true`        | Controls which users have access to the Admin UI.                          |
| `adminMeta`          | `Object`   | `{}`          | Provides additional `adminMeta`. Useful for Hooks and other customizations |
| `defaultPageSize`    | `Integer`  | 50            | The default number of list items to show at once.                          |
| `maximumPageSize`    | `Integer`  | 1000          | The maximum number of list items to show at once.                          |

### `hooks`

Customization hooks allow you to modify various areas of the Admin UI to better suit your development needs. The `index.js` file at the given path should export a single config object containing your chosen hooks. All are optional. See [Customization](#customization) for available hooks.

If omitted, Keystone will look under `./admin-ui/` for a hooks config export.

#### Usage

```javascript title=index.js
new AdminUIApp({ hooks: require.resolve('./custom-hooks-path') });
```

### `isAccessAllowed`

This function takes the same arguments as a [shorthand imperative boolean](https://www.keystonejs.com/api/access-control#shorthand-imperative-boolean) access control. It must return either true or false.

> **Important:** If omitted, all users _with accounts_ will be able to access the Admin UI. The example below would restrict access to users with the `isAdmin` permission.

#### Usage

```js
new AdminUIApp({
  /*...config */
  isAccessAllowed: ({ authentication: { item: user, listKey: list } }) => !!user && !!user.isAdmin,
}),
```

## Customization

The following customization hooks are available. Each is a function that takes no arguments.

```javascript title=/custom-hooks-path/index.js
export default {
  customToast,
  itemHeaderActions,
  listHeaderActions,
  listManageActions,
  logo,
  pages,
};
```

### `logo`

The logo to display on the signin screen.

> This must return a React component.

```javascript
export default {
  logo: () => <MyAwesomeLogo />,
};
```

### `itemHeaderActions`

Header components on the Item Details page can be replaced using this hook. Ths replaces the components for item Details page for all Lists.

> This must return a React component.

```javascript title=/admin-ui/index.js
import { ItemId, AddNewItem } from '@keystonejs/app-admin-ui/components';
export default {
  // re-implement the default AddNewItem and ItemId button + custom text
  itemHeaderActions: () => (
    <div>
      <ItemId />
      <AddNewItem />
      <p>Hello world</p>
    </div>
  ),
};
```

### `listHeaderActions`

Header components on the List page can be replaced using this hook. This replaces components on list page for all Lists.

> This must return a React component.

```javascript title=/admin-ui/index.js
import { CreateItem } from '@keystonejs/app-admin-ui/components';
export default {
  // re-implement the default create item button + custom text
  listHeaderActions: () => (
    <div>
      <CreateItem />
      <p>Hello world</p>
    </div>
  ),
};
```

### `listManageActions`

Custom Actions component for multiple items in the list can be replaced with this hook. This replaces the list management toolbar Items for all lists.

> This must return a React component.

```javascript title=/admin-ui/index.js
import { UpdateItems, DeleteItems } from '@keystonejs/app-admin-ui/components';
export default {
  // re-implement the default delete many and update many items buttons + custom text
  listManageActions: () => (
    <div>
      <UpdateItems />
      <DeleteItems />
      <p>Hello world</p>
    </div>
  ),
};
```

### `pages`

Allows grouping list pages in the sidebar or defining completely new pages.

Should return an array of objects, which may contain the following properties:

| Name        | Type                | Description                                                                             |
| ----------- | ------------------- | --------------------------------------------------------------------------------------- |
| `label`     | `String`            | The page name to display in the sidebar.                                                |
| `path`      | `String`            | The page path.                                                                          |
| `component` | `Function \| Class` | A React component which will be used to render this page.                               |
| `children`  | `Array`             | An array of either Keystone list keys or objects with `listKey` and `label` properties. |

```javascript
export default {
  pages: () => [
    // Custom pages
    {
      label: 'A new dashboard',
      path: '',
      component: Dashboard,
    },
    {
      label: 'About this project',
      path: 'about',
      component: About,
    },
    // Ordering existing list pages
    {
      label: 'Blog',
      children: [
        { listKey: 'Post' },
        { listKey: 'PostCategory', label: 'Categories' },
        { listKey: 'Comment' },
      ],
    },
    {
      label: 'People',
      children: ['User'],
    },
  ],
};
```

### `customToast`

Allows customising the content of toast notification when an item is updated or deleted.

The hook function receives a context variable containing an `item` key with the original item data, a `list` key that can be used to limit the scope of the hook, the original `message` as well as a `toastAction` that will be either 'update' or 'delete'. The function should return a React component.

```javascript
export default {
  customToast: ({ item, list, message }) => {
    // custom Toast for MyList
    if (list.key === 'MyList') {
      return (
        <div>
          <strong>My custom toast notification!</strong>
          {item && item._label_ ? <strong>{item._label_}</strong> : null}
        </div>
      );
    }
    // Default toast
    return (
      <div>
        {item && item._label_ ? <strong>{item._label_}</strong> : null}
        <div>{message}</div>
      </div>
    );
  },
};
```

---
_Source: https://npm.io/package/@keystonejs/app-admin-ui · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
