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; completedProcessInstanceTasks?: ProcessInstanceTask[] | 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;
@ -94,6 +95,7 @@ export default function ReactDiagramEditor({
completedProcessInstanceTasks, completedProcessInstanceTasks,
saveDiagram, saveDiagram,
onDeleteFile, onDeleteFile,
isPrimaryFile,
onSetPrimaryFile, onSetPrimaryFile,
diagramXML, diagramXML,
fileName, fileName,
@ -573,7 +575,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

@ -823,6 +823,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}>