Merge pull request #1950 from automatisch/AUT-1074
fix: fix error for only Create role when publishing flow
This commit is contained in:
@@ -14,6 +14,7 @@ import { EditorProvider } from 'contexts/Editor';
|
||||
import EditableTypography from 'components/EditableTypography';
|
||||
import Container from 'components/Container';
|
||||
import Editor from 'components/Editor';
|
||||
import Can from 'components/Can';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
import { UPDATE_FLOW_STATUS } from 'graphql/mutations/update-flow-status';
|
||||
import { UPDATE_FLOW } from 'graphql/mutations/update-flow';
|
||||
@@ -36,23 +37,18 @@ export default function EditorLayout() {
|
||||
|
||||
const onFlowNameUpdate = React.useCallback(
|
||||
async (name) => {
|
||||
await updateFlow({
|
||||
variables: {
|
||||
input: {
|
||||
id: flowId,
|
||||
name,
|
||||
try {
|
||||
await updateFlow({
|
||||
variables: {
|
||||
input: {
|
||||
id: flowId,
|
||||
name,
|
||||
},
|
||||
},
|
||||
},
|
||||
optimisticResponse: {
|
||||
updateFlow: {
|
||||
__typename: 'Flow',
|
||||
id: flowId,
|
||||
name,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
await queryClient.invalidateQueries({ queryKey: ['flows', flowId] });
|
||||
await queryClient.invalidateQueries({ queryKey: ['flows', flowId] });
|
||||
} catch (e) {}
|
||||
},
|
||||
[flowId, queryClient],
|
||||
);
|
||||
@@ -67,13 +63,6 @@ export default function EditorLayout() {
|
||||
active,
|
||||
},
|
||||
},
|
||||
optimisticResponse: {
|
||||
updateFlowStatus: {
|
||||
__typename: 'Flow',
|
||||
id: flowId,
|
||||
active,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await queryClient.invalidateQueries({ queryKey: ['flows', flowId] });
|
||||
@@ -123,18 +112,23 @@ export default function EditorLayout() {
|
||||
</Box>
|
||||
|
||||
<Box pr={1}>
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={() => onFlowStatusUpdate(!flow.active)}
|
||||
data-test={
|
||||
flow?.active ? 'unpublish-flow-button' : 'publish-flow-button'
|
||||
}
|
||||
>
|
||||
{flow?.active
|
||||
? formatMessage('flowEditor.unpublish')
|
||||
: formatMessage('flowEditor.publish')}
|
||||
</Button>
|
||||
<Can I="publish" a="Flow" passThrough>
|
||||
{(allowed) => (
|
||||
<Button
|
||||
disabled={!allowed || !flow}
|
||||
variant="contained"
|
||||
size="small"
|
||||
onClick={() => onFlowStatusUpdate(!flow.active)}
|
||||
data-test={
|
||||
flow?.active ? 'unpublish-flow-button' : 'publish-flow-button'
|
||||
}
|
||||
>
|
||||
{flow?.active
|
||||
? formatMessage('flowEditor.unpublish')
|
||||
: formatMessage('flowEditor.publish')}
|
||||
</Button>
|
||||
)}
|
||||
</Can>
|
||||
</Box>
|
||||
</TopBar>
|
||||
|
||||
|
Reference in New Issue
Block a user