Skip to content

Commit

Permalink
Merge pull request #12 from sanity-io/fix/issues
Browse files Browse the repository at this point in the history
fixes missing 'compose' button in Pane
  • Loading branch information
SimeonGriggs committed Jan 5, 2022
2 parents 4dbb170 + f7a2a42 commit 7236fd3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sanity/orderable-document-list",
"version": "0.0.3",
"version": "0.0.4",
"description": "Drag-and-drop Document Ordering without leaving the Editing surface",
"main": "lib/index.js",
"scripts": {
Expand Down
36 changes: 18 additions & 18 deletions src/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ export default function Document({doc, increment, entities, handleSelect, index,
<DragHandleIcon />
</Text>
</Box>
{showIncrements && (
<Flex style={{flexShrink: 0}} align="center" gap={1} paddingRight={1}>
<Button
padding={2}
mode="ghost"
onClick={() => increment(index, index + -1, doc._id, entities)}
disabled={isFirst}
icon={ChevronUpIcon}
/>
<Button
padding={2}
mode="ghost"
disabled={isLast}
onClick={() => increment(index, index + 1, doc._id, entities)}
icon={ChevronDownIcon}
/>
</Flex>
)}
<Button
style={{width: `100%`}}
padding={2}
mode="bleed"
onClick={(e) => handleSelect(doc._id, index, e.nativeEvent)}
>
<Flex flex={1} align="center">
{showIncrements && (
<Flex style={{flexShrink: 0}} align="center" gap={1} paddingRight={2}>
<Button
padding={2}
mode="ghost"
onClick={() => increment(index, index + -1, doc._id, entities)}
disabled={isFirst}
icon={ChevronUpIcon}
/>
<Button
padding={2}
mode="ghost"
disabled={isLast}
onClick={() => increment(index, index + 1, doc._id, entities)}
icon={ChevronDownIcon}
/>
</Flex>
)}
<Box flex={1}>
<Preview value={doc} type={schema.get(doc._type)} />
</Box>
Expand Down
2 changes: 0 additions & 2 deletions src/DocumentListQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'
import React, {useEffect, useState, useMemo} from 'react'
import sanityClient from 'part:@sanity/base/client'
import {Stack, Box, Flex, Spinner} from '@sanity/ui'
import {usePaneRouter} from '@sanity/desk-tool'

import DraggableList from './DraggableList'
import {ORDER_FIELD_NAME} from './helpers/constants'
Expand All @@ -16,7 +15,6 @@ export default function DocumentListQuery({type}) {
const [isLoading, setIsLoading] = useState(true)
const [isUpdating, setIsUpdating] = useState(false)
const [data, setData] = useState([])
const router = usePaneRouter()

useEffect(() => {
const query = `*[_type == $type]|order(@[$order] asc)`
Expand Down
8 changes: 7 additions & 1 deletion src/desk-structure/orderableDocumentListDeskItem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import S from '@sanity/desk-tool/structure-builder'
import {SortIcon, GenerateIcon} from '@sanity/icons'
import schema from 'part:@sanity/base/schema'

import OrderableDocumentList from '../OrderableDocumentList'

export function orderableDocumentListDeskItem(config = {}) {
Expand All @@ -16,6 +18,7 @@ export function orderableDocumentListDeskItem(config = {}) {
const listTitle = title ?? `Orderable ${type}`
const listId = `orderable-${type}`
const listIcon = icon ?? SortIcon
const typeTitle = schema.get(type)?.title ?? type

return S.listItem(type)
.title(listTitle)
Expand All @@ -28,7 +31,10 @@ export function orderableDocumentListDeskItem(config = {}) {
component: OrderableDocumentList,
options: {type},
menuItems: [
...S.documentTypeList(type).menuItems().serialize().menuItems,
S.menuItem()
.title(`Create new ${typeTitle}`)
.intent({type: 'create', params: {type}})
.serialize(),
S.menuItem().title(`Reset Order`).icon(GenerateIcon).action(`resetOrder`).serialize(),
S.menuItem().title(`Show Increments`).icon(SortIcon).action(`showIncrements`).serialize(),
],
Expand Down

0 comments on commit 7236fd3

Please sign in to comment.