Don't show delete button for primary file

This commit is contained in:
mike cullerton 2022-12-13 08:52:02 -05:00
parent 2c25e626e1
commit 088826e433
3 changed files with 25 additions and 20 deletions

View File

@ -68,6 +68,7 @@ type OwnProps = {
completedTasksBpmnIds?: string[] | null; completedTasksBpmnIds?: string[] | null;
saveDiagram?: (..._args: any[]) => any; saveDiagram?: (..._args: any[]) => any;
onDeleteFile?: (..._args: any[]) => any; onDeleteFile?: (..._args: any[]) => any;
isPrimaryFile?: boolean;
onSetPrimaryFile?: (..._args: any[]) => any; onSetPrimaryFile?: (..._args: any[]) => any;
diagramXML?: string | null; diagramXML?: string | null;
fileName?: string; fileName?: string;
@ -92,6 +93,7 @@ export default function ReactDiagramEditor({
completedTasksBpmnIds, completedTasksBpmnIds,
saveDiagram, saveDiagram,
onDeleteFile, onDeleteFile,
isPrimaryFile,
onSetPrimaryFile, onSetPrimaryFile,
diagramXML, diagramXML,
fileName, fileName,
@ -549,7 +551,7 @@ export default function ReactDiagramEditor({
a={targetUris.processModelFileShowPath} a={targetUris.processModelFileShowPath}
ability={ability} ability={ability}
> >
{fileName && ( {fileName && !isPrimaryFile && (
<ButtonWithConfirmation <ButtonWithConfirmation
description={`Delete file ${fileName}?`} description={`Delete file ${fileName}?`}
onConfirmation={handleDelete} onConfirmation={handleDelete}

View File

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

View File

@ -264,6 +264,7 @@ export default function ProcessModelShow() {
</Can> </Can>
); );
if (!isPrimaryBpmnFile) {
elements.push( elements.push(
<Can <Can
I="DELETE" I="DELETE"
@ -283,6 +284,7 @@ export default function ProcessModelShow() {
/> />
</Can> </Can>
); );
}
if (processModelFile.name.match(/\.bpmn$/) && !isPrimaryBpmnFile) { if (processModelFile.name.match(/\.bpmn$/) && !isPrimaryBpmnFile) {
elements.push( elements.push(
<Can I="PUT" a={targetUris.processModelShowPath} ability={ability}> <Can I="PUT" a={targetUris.processModelShowPath} ability={ability}>