Merge pull request #74 from sartography/bug/delete-primary-warning

Don't show delete button for primary file
This commit is contained in:
jasquat 2022-12-16 13:15:28 -05:00 committed by GitHub
commit 04fed0c004
3 changed files with 25 additions and 20 deletions

View File

@ -70,6 +70,7 @@ type OwnProps = {
completedProcessInstanceTasks?: ProcessInstanceTask[] | null;
saveDiagram?: (..._args: any[]) => any;
onDeleteFile?: (..._args: any[]) => any;
isPrimaryFile?: boolean;
onSetPrimaryFile?: (..._args: any[]) => any;
diagramXML?: string | null;
fileName?: string;
@ -94,6 +95,7 @@ export default function ReactDiagramEditor({
completedProcessInstanceTasks,
saveDiagram,
onDeleteFile,
isPrimaryFile,
onSetPrimaryFile,
diagramXML,
fileName,
@ -573,7 +575,7 @@ export default function ReactDiagramEditor({
a={targetUris.processModelFileShowPath}
ability={ability}
>
{fileName && (
{fileName && !isPrimaryFile && (
<ButtonWithConfirmation
description={`Delete file ${fileName}?`}
onConfirmation={handleDelete}

View File

@ -823,6 +823,7 @@ export default function ProcessModelEditDiagram() {
processModelId={params.process_model_id || ''}
saveDiagram={saveDiagram}
onDeleteFile={onDeleteFile}
isPrimaryFile={params.file_name === processModel?.primary_file_name}
onSetPrimaryFile={onSetPrimaryFileCallback}
diagramXML={bpmnXmlForDiagramRendering}
fileName={params.file_name}

View File

@ -264,25 +264,27 @@ export default function ProcessModelShow() {
</Can>
);
elements.push(
<Can
I="DELETE"
a={targetUris.processModelFileCreatePath}
ability={ability}
>
<ButtonWithConfirmation
kind="ghost"
renderIcon={TrashCan}
iconDescription="Delete File"
hasIconOnly
description={`Delete file: ${processModelFile.name}`}
onConfirmation={() => {
onDeleteFile(processModelFile.name);
}}
confirmButtonLabel="Delete"
/>
</Can>
);
if (!isPrimaryBpmnFile) {
elements.push(
<Can
I="DELETE"
a={targetUris.processModelFileCreatePath}
ability={ability}
>
<ButtonWithConfirmation
kind="ghost"
renderIcon={TrashCan}
iconDescription="Delete File"
hasIconOnly
description={`Delete file: ${processModelFile.name}`}
onConfirmation={() => {
onDeleteFile(processModelFile.name);
}}
confirmButtonLabel="Delete"
/>
</Can>
);
}
if (processModelFile.name.match(/\.bpmn$/) && !isPrimaryBpmnFile) {
elements.push(
<Can I="PUT" a={targetUris.processModelShowPath} ability={ability}>