Skip to content

Commit

Permalink
Merge branch 'master' into silence-document-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Jul 28, 2021
2 parents 4f41fb1 + e0b9e8d commit d68c478
Show file tree
Hide file tree
Showing 65 changed files with 734 additions and 171 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-cycles-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/example-custom-admin-ui-pages': major
---

Initial version of the custom-admin-ui-pages example.
8 changes: 8 additions & 0 deletions .changeset/wise-pianos-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@keystone-next/keystone': major
'@keystone-next/types': major
---

The delete mutations now accept `where` unique inputs instead of only an `id`.

If you have a list called `Item`, `deleteItem` now looks like `deleteItem(where: ItemWhereUniqueInput!): Item` and `deleteItems` now looks like `deleteItems(where: [ItemWhereUniqueInput!]!): [Item]`
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ jobs:
'with-auth.test.ts',
'custom-field-view.test.ts',
'custom-field.test.ts',
'custom-admin-ui-pages.test.ts',
'custom-admin-ui-logo.test.ts',
]
fail-fast: false
Expand Down
8 changes: 8 additions & 0 deletions docs/components/docs/ExamplesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ export function Examples() {
Adds a custom field type based on the <InlineCode>integer</InlineCode> field type which lets
users rate items on a 5-star scale. Builds on the Blog starter project.
</Well>
<Well
heading="Custom Admin UI Pages"
href="https://github.com/keystonejs/keystone/blob/master/examples/custom-admin-ui-pages"
target="_blank"
rel="noopener noreferrer"
>
Adds a custom page in the Admin UI. Builds on the Task Manager starter project.
</Well>
<Well
grad="grad3"
heading="Custom Admin UI Logo"
Expand Down
3 changes: 3 additions & 0 deletions docs/components/docs/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export function DocsNavigation() {
<NavItem href="/docs/guides/custom-admin-ui-logo">
Custom Admin UI Logo <Badge look="success">New</Badge>
</NavItem>
<NavItem href="/docs/guides/custom-admin-ui-pages">
Custom Admin UI Pages <Badge look="success">New</Badge>
</NavItem>
<NavItem href="/docs/guides/access-control" isPlaceholder>
Access Control
</NavItem>
Expand Down
45 changes: 45 additions & 0 deletions docs/pages/docs/guides/custom-admin-ui-pages.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ComingSoon } from '../../../components/docs/ComingSoon';
import { Markdown } from '../../../components/Markdown';
import { Alert } from '../../../components/primitives/Alert';

# Custom Admin UI Pages

In this guide we'll show you how to add custom pages to the Keystone Admin UI.
As the Admin UI is built on top of Next.js, it exposes the same pages directory for adding custom pages.

To create a custom page, ensure that the `admin/pages` directory exists in the root of your Keystone Project.
Much like with Next.js, all files in this directory will be added as routes to the Admin UI.
The default export of every file in this directory is expected to be a valid React Component rendered out as the contents of the route.

```tsx
// admin/pages/MyCustomPage.tsx
export default function () {
return (
<h1>This is a custom Admin UI Page</h1>
<p>It can be accessed via the route '/MyCustomPage'</p>
)
}
```

If you have styling constraints, we recommend using the jsx export from the `@keystone-ui/core` package, as this will ensure that the version of emotion you're using conforms with the version of emotion used internally within Keystone.

```tsx
// admin/pages/MyCustomPage.tsx
/** @jsxRuntime classic */
/** @jsx jsx */
import { jsx } from '@keystone-ui/core';
export default function () {
return (
<h1 css={{
fontSize: '3rem'
}}>This is a custom Admin UI Page</h1>
<p>It can be accessed via the route '/MyCustomPage'</p>
)
}
```

Of course this is purely a recommendation, if you would prefer to roll your own css-in-js solution in with your custom component please feel free to! Although this may require additional configuration outside of the scope of this guide.

x> **Not all Next.js exports are available:** Keystone **only** supports the page component as a default export in the pages directory. This means that unlike with Next, auxillary exports such as `getStaticProps` and `getServerProps` are not supported.

export default ({ children }) => <Markdown>{children}</Markdown>;
8 changes: 4 additions & 4 deletions examples-staging/assets-cloud/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ type Mutation {
createPosts(data: [PostsCreateInput]): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(id: ID!): Post
deletePosts(ids: [ID!]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createAuthor(data: AuthorCreateInput): Author
createAuthors(data: [AuthorsCreateInput]): [Author]
updateAuthor(id: ID!, data: AuthorUpdateInput): Author
updateAuthors(data: [AuthorUpdateArgs]): [Author]
deleteAuthor(id: ID!): Author
deleteAuthors(ids: [ID!]): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author]
}

type Query {
Expand Down
8 changes: 4 additions & 4 deletions examples-staging/assets-local/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ type Mutation {
createPosts(data: [PostsCreateInput]): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(id: ID!): Post
deletePosts(ids: [ID!]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createAuthor(data: AuthorCreateInput): Author
createAuthors(data: [AuthorsCreateInput]): [Author]
updateAuthor(id: ID!, data: AuthorUpdateInput): Author
updateAuthors(data: [AuthorUpdateArgs]): [Author]
deleteAuthor(id: ID!): Author
deleteAuthors(ids: [ID!]): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author]
}

type Query {
Expand Down
4 changes: 2 additions & 2 deletions examples-staging/auth/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ type Mutation {
createUsers(data: [UsersCreateInput]): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(id: ID!): User
deleteUsers(ids: [ID!]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
authenticateUserWithPassword(
email: String!
password: String!
Expand Down
12 changes: 6 additions & 6 deletions examples-staging/basic/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -355,20 +355,20 @@ type Mutation {
createUsers(data: [UsersCreateInput]): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(id: ID!): User
deleteUsers(ids: [ID!]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
createPhoneNumber(data: PhoneNumberCreateInput): PhoneNumber
createPhoneNumbers(data: [PhoneNumbersCreateInput]): [PhoneNumber]
updatePhoneNumber(id: ID!, data: PhoneNumberUpdateInput): PhoneNumber
updatePhoneNumbers(data: [PhoneNumberUpdateArgs]): [PhoneNumber]
deletePhoneNumber(id: ID!): PhoneNumber
deletePhoneNumbers(ids: [ID!]): [PhoneNumber]
deletePhoneNumber(where: PhoneNumberWhereUniqueInput!): PhoneNumber
deletePhoneNumbers(where: [PhoneNumberWhereUniqueInput!]!): [PhoneNumber]
createPost(data: PostCreateInput): Post
createPosts(data: [PostsCreateInput]): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(id: ID!): Post
deletePosts(ids: [ID!]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
authenticateUserWithPassword(
email: String!
password: String!
Expand Down
2 changes: 1 addition & 1 deletion examples-staging/ecommerce/mutations/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function checkout(root: any, { token }: Arguments, context: KeystoneContex
const cartItemIds = user.cart.map((cartItem: any) => cartItem.id);
console.log('gonna create delete cartItems');
await context.lists.CartItem.deleteMany({
ids: cartItemIds,
where: cartItemIds.map((id: string) => ({ id })),
});
return order;
}
Expand Down
28 changes: 14 additions & 14 deletions examples-staging/ecommerce/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -764,44 +764,44 @@ type Mutation {
createUsers(data: [UsersCreateInput]): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(id: ID!): User
deleteUsers(ids: [ID!]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
createProduct(data: ProductCreateInput): Product
createProducts(data: [ProductsCreateInput]): [Product]
updateProduct(id: ID!, data: ProductUpdateInput): Product
updateProducts(data: [ProductUpdateArgs]): [Product]
deleteProduct(id: ID!): Product
deleteProducts(ids: [ID!]): [Product]
deleteProduct(where: ProductWhereUniqueInput!): Product
deleteProducts(where: [ProductWhereUniqueInput!]!): [Product]
createProductImage(data: ProductImageCreateInput): ProductImage
createProductImages(data: [ProductImagesCreateInput]): [ProductImage]
updateProductImage(id: ID!, data: ProductImageUpdateInput): ProductImage
updateProductImages(data: [ProductImageUpdateArgs]): [ProductImage]
deleteProductImage(id: ID!): ProductImage
deleteProductImages(ids: [ID!]): [ProductImage]
deleteProductImage(where: ProductImageWhereUniqueInput!): ProductImage
deleteProductImages(where: [ProductImageWhereUniqueInput!]!): [ProductImage]
createCartItem(data: CartItemCreateInput): CartItem
createCartItems(data: [CartItemsCreateInput]): [CartItem]
updateCartItem(id: ID!, data: CartItemUpdateInput): CartItem
updateCartItems(data: [CartItemUpdateArgs]): [CartItem]
deleteCartItem(id: ID!): CartItem
deleteCartItems(ids: [ID!]): [CartItem]
deleteCartItem(where: CartItemWhereUniqueInput!): CartItem
deleteCartItems(where: [CartItemWhereUniqueInput!]!): [CartItem]
createOrderItem(data: OrderItemCreateInput): OrderItem
createOrderItems(data: [OrderItemsCreateInput]): [OrderItem]
updateOrderItem(id: ID!, data: OrderItemUpdateInput): OrderItem
updateOrderItems(data: [OrderItemUpdateArgs]): [OrderItem]
deleteOrderItem(id: ID!): OrderItem
deleteOrderItems(ids: [ID!]): [OrderItem]
deleteOrderItem(where: OrderItemWhereUniqueInput!): OrderItem
deleteOrderItems(where: [OrderItemWhereUniqueInput!]!): [OrderItem]
createOrder(data: OrderCreateInput): Order
createOrders(data: [OrdersCreateInput]): [Order]
updateOrder(id: ID!, data: OrderUpdateInput): Order
updateOrders(data: [OrderUpdateArgs]): [Order]
deleteOrder(id: ID!): Order
deleteOrders(ids: [ID!]): [Order]
deleteOrder(where: OrderWhereUniqueInput!): Order
deleteOrders(where: [OrderWhereUniqueInput!]!): [Order]
createRole(data: RoleCreateInput): Role
createRoles(data: [RolesCreateInput]): [Role]
updateRole(id: ID!, data: RoleUpdateInput): Role
updateRoles(data: [RoleUpdateArgs]): [Role]
deleteRole(id: ID!): Role
deleteRoles(ids: [ID!]): [Role]
deleteRole(where: RoleWhereUniqueInput!): Role
deleteRoles(where: [RoleWhereUniqueInput!]!): [Role]
authenticateUserWithPassword(
email: String!
password: String!
Expand Down
4 changes: 2 additions & 2 deletions examples-staging/embedded-nextjs/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ type Mutation {
createPosts(data: [PostsCreateInput]): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(id: ID!): Post
deletePosts(ids: [ID!]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
}

type Query {
Expand Down
12 changes: 6 additions & 6 deletions examples-staging/graphql-api-endpoint/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,20 @@ type Mutation {
createUsers(data: [UsersCreateInput]): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(id: ID!): User
deleteUsers(ids: [ID!]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
createPost(data: PostCreateInput): Post
createPosts(data: [PostsCreateInput]): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(id: ID!): Post
deletePosts(ids: [ID!]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createTag(data: TagCreateInput): Tag
createTags(data: [TagsCreateInput]): [Tag]
updateTag(id: ID!, data: TagUpdateInput): Tag
updateTags(data: [TagUpdateArgs]): [Tag]
deleteTag(id: ID!): Tag
deleteTags(ids: [ID!]): [Tag]
deleteTag(where: TagWhereUniqueInput!): Tag
deleteTags(where: [TagWhereUniqueInput!]!): [Tag]
authenticateUserWithPassword(
email: String!
password: String!
Expand Down
4 changes: 2 additions & 2 deletions examples-staging/playground/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ type Mutation {
createNotes(data: [NotesCreateInput]): [Note]
updateNote(id: ID!, data: NoteUpdateInput): Note
updateNotes(data: [NoteUpdateArgs]): [Note]
deleteNote(id: ID!): Note
deleteNotes(ids: [ID!]): [Note]
deleteNote(where: NoteWhereUniqueInput!): Note
deleteNotes(where: [NoteWhereUniqueInput!]!): [Note]
}

type Query {
Expand Down
12 changes: 6 additions & 6 deletions examples-staging/roles/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,20 @@ type Mutation {
createTodos(data: [TodosCreateInput]): [Todo]
updateTodo(id: ID!, data: TodoUpdateInput): Todo
updateTodos(data: [TodoUpdateArgs]): [Todo]
deleteTodo(id: ID!): Todo
deleteTodos(ids: [ID!]): [Todo]
deleteTodo(where: TodoWhereUniqueInput!): Todo
deleteTodos(where: [TodoWhereUniqueInput!]!): [Todo]
createPerson(data: PersonCreateInput): Person
createPeople(data: [PeopleCreateInput]): [Person]
updatePerson(id: ID!, data: PersonUpdateInput): Person
updatePeople(data: [PersonUpdateArgs]): [Person]
deletePerson(id: ID!): Person
deletePeople(ids: [ID!]): [Person]
deletePerson(where: PersonWhereUniqueInput!): Person
deletePeople(where: [PersonWhereUniqueInput!]!): [Person]
createRole(data: RoleCreateInput): Role
createRoles(data: [RolesCreateInput]): [Role]
updateRole(id: ID!, data: RoleUpdateInput): Role
updateRoles(data: [RoleUpdateArgs]): [Role]
deleteRole(id: ID!): Role
deleteRoles(ids: [ID!]): [Role]
deleteRole(where: RoleWhereUniqueInput!): Role
deleteRoles(where: [RoleWhereUniqueInput!]!): [Role]
authenticatePersonWithPassword(
email: String!
password: String!
Expand Down
8 changes: 4 additions & 4 deletions examples-staging/sandbox/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ type Mutation {
createTodos(data: [TodosCreateInput]): [Todo]
updateTodo(id: ID!, data: TodoUpdateInput): Todo
updateTodos(data: [TodoUpdateArgs]): [Todo]
deleteTodo(id: ID!): Todo
deleteTodos(ids: [ID!]): [Todo]
deleteTodo(where: TodoWhereUniqueInput!): Todo
deleteTodos(where: [TodoWhereUniqueInput!]!): [Todo]
createUser(data: UserCreateInput): User
createUsers(data: [UsersCreateInput]): [User]
updateUser(id: ID!, data: UserUpdateInput): User
updateUsers(data: [UserUpdateArgs]): [User]
deleteUser(id: ID!): User
deleteUsers(ids: [ID!]): [User]
deleteUser(where: UserWhereUniqueInput!): User
deleteUsers(where: [UserWhereUniqueInput!]!): [User]
}

type Query {
Expand Down
3 changes: 2 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Each project below demonstrates a Keystone feature you can learn about and exper
- [Testing](./testing): Adds tests with `@keystone-next/testing` to the `withAuth()` example.
- [Custom field](./custom-field): Adds a custom `stars` field to the Blog base.
- [Custom field view](./custom-field-view): Adds a custom Admin UI view to a `json` field to the Task Manager base.
- [Custom Admin UI components](./custom-admin-ui-logo): Adds a custom logo in the Admin UI to the Task Manager base.
- [Custom Admin UI logo](./custom-admin-ui-logo): Adds a custom logo in the Admin UI to the Task Manager base.
- [Custom Admin UI pages](./custom-admin-ui-pages): Adds a custom page in the Admin UI to the Task Manager base.

## Running examples

Expand Down
8 changes: 4 additions & 4 deletions examples/blog/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ type Mutation {
createPosts(data: [PostsCreateInput]): [Post]
updatePost(id: ID!, data: PostUpdateInput): Post
updatePosts(data: [PostUpdateArgs]): [Post]
deletePost(id: ID!): Post
deletePosts(ids: [ID!]): [Post]
deletePost(where: PostWhereUniqueInput!): Post
deletePosts(where: [PostWhereUniqueInput!]!): [Post]
createAuthor(data: AuthorCreateInput): Author
createAuthors(data: [AuthorsCreateInput]): [Author]
updateAuthor(id: ID!, data: AuthorUpdateInput): Author
updateAuthors(data: [AuthorUpdateArgs]): [Author]
deleteAuthor(id: ID!): Author
deleteAuthors(ids: [ID!]): [Author]
deleteAuthor(where: AuthorWhereUniqueInput!): Author
deleteAuthors(where: [AuthorWhereUniqueInput!]!): [Author]
}

type Query {
Expand Down
8 changes: 4 additions & 4 deletions examples/custom-admin-ui-logo/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ type Mutation {
createTasks(data: [TasksCreateInput]): [Task]
updateTask(id: ID!, data: TaskUpdateInput): Task
updateTasks(data: [TaskUpdateArgs]): [Task]
deleteTask(id: ID!): Task
deleteTasks(ids: [ID!]): [Task]
deleteTask(where: TaskWhereUniqueInput!): Task
deleteTasks(where: [TaskWhereUniqueInput!]!): [Task]
createPerson(data: PersonCreateInput): Person
createPeople(data: [PeopleCreateInput]): [Person]
updatePerson(id: ID!, data: PersonUpdateInput): Person
updatePeople(data: [PersonUpdateArgs]): [Person]
deletePerson(id: ID!): Person
deletePeople(ids: [ID!]): [Person]
deletePerson(where: PersonWhereUniqueInput!): Person
deletePeople(where: [PersonWhereUniqueInput!]!): [Person]
}

type Query {
Expand Down
1 change: 1 addition & 0 deletions examples/custom-admin-ui-pages/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @keystone-next/example-custom-admin-ui-pages
Loading

0 comments on commit d68c478

Please sign in to comment.