feat: disable publish button when no flow or permissions
This commit is contained in:
@@ -14,6 +14,7 @@ import { EditorProvider } from 'contexts/Editor';
|
|||||||
import EditableTypography from 'components/EditableTypography';
|
import EditableTypography from 'components/EditableTypography';
|
||||||
import Container from 'components/Container';
|
import Container from 'components/Container';
|
||||||
import Editor from 'components/Editor';
|
import Editor from 'components/Editor';
|
||||||
|
import Can from 'components/Can';
|
||||||
import useFormatMessage from 'hooks/useFormatMessage';
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
import { UPDATE_FLOW_STATUS } from 'graphql/mutations/update-flow-status';
|
import { UPDATE_FLOW_STATUS } from 'graphql/mutations/update-flow-status';
|
||||||
import { UPDATE_FLOW } from 'graphql/mutations/update-flow';
|
import { UPDATE_FLOW } from 'graphql/mutations/update-flow';
|
||||||
@@ -111,18 +112,23 @@ export default function EditorLayout() {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box pr={1}>
|
<Box pr={1}>
|
||||||
<Button
|
<Can I="publish" a="Flow" passThrough>
|
||||||
variant="contained"
|
{(allowed) => (
|
||||||
size="small"
|
<Button
|
||||||
onClick={() => onFlowStatusUpdate(flow ? !flow.active : false)}
|
disabled={!allowed || !flow}
|
||||||
data-test={
|
variant="contained"
|
||||||
flow?.active ? 'unpublish-flow-button' : 'publish-flow-button'
|
size="small"
|
||||||
}
|
onClick={() => onFlowStatusUpdate(!flow.active)}
|
||||||
>
|
data-test={
|
||||||
{flow?.active
|
flow?.active ? 'unpublish-flow-button' : 'publish-flow-button'
|
||||||
? formatMessage('flowEditor.unpublish')
|
}
|
||||||
: formatMessage('flowEditor.publish')}
|
>
|
||||||
</Button>
|
{flow?.active
|
||||||
|
? formatMessage('flowEditor.unpublish')
|
||||||
|
: formatMessage('flowEditor.publish')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Can>
|
||||||
</Box>
|
</Box>
|
||||||
</TopBar>
|
</TopBar>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user