Skip to content

Commit

Permalink
[form-builder] Hide delete button from dialog when array is read only (
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge authored Mar 6, 2018
1 parent 118417c commit e230a93
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions packages/@sanity/form-builder/src/inputs/ArrayInput/ItemValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,18 @@ const DragHandle = createDragHandle(() => (
</span>
))

const DIALOG_ACTIONS = [
{
index: '1',
name: 'close',
title: 'Close'
},
{
index: '2',
name: 'delete',
kind: 'simple',
title: 'Delete',
color: 'danger',
secondary: true
}
]
const CLOSE_ACTION = {
name: 'close',
title: 'Close'
}

const DELETE_ACTION = {
name: 'delete',
kind: 'simple',
title: 'Delete',
color: 'danger',
secondary: true
}

type Props = {
type: ArrayType,
Expand Down Expand Up @@ -207,7 +204,6 @@ export default class RenderItemValue extends React.Component<Props> {
</div>
)
}
return (
<div className={styles.popupAnchor}>
<DefaultDialog
Expand All @@ -217,7 +213,10 @@ export default class RenderItemValue extends React.Component<Props> {
title="Edit"
onAction={this.handleDialogAction}
showCloseButton={false}
actions={DIALOG_ACTIONS}
actions={[
CLOSE_ACTION,
!readOnly && DELETE_ACTION
].filter(Boolean)}
>
<div className={styles.defaultDialogContent}>{content}</div>
</DefaultDialog>
Expand Down

0 comments on commit e230a93

Please sign in to comment.