shortcut to view diagram from instance show (#1082)

* shortcut to view diagram from instance show

* no need for file contents

* handle no primary filename before attempting navigation

---------

Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
Kevin Burnett 2024-02-22 06:00:02 -08:00 committed by GitHub
parent 802d80883c
commit ea108c6392
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 0 deletions

View File

@ -64,6 +64,7 @@ import {
PermissionsToCheck,
ProcessData,
ProcessInstance,
ProcessModel,
Task,
TaskDefinitionPropertiesJson,
User,
@ -157,6 +158,7 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
[targetUris.processInstanceSendEventPath]: ['POST'],
[targetUris.processInstanceCompleteTaskPath]: ['POST'],
[targetUris.processModelShowPath]: ['PUT'],
[targetUris.processModelFileCreatePath]: ['GET'],
[taskListPath]: ['GET'],
};
const { ability, permissionsLoaded } = usePermissionFetcher(
@ -195,11 +197,36 @@ export default function ProcessInstanceShow({ variant }: OwnProps) {
}
};
const shortcutLoadPrimaryFile = () => {
if (ability.can('GET', targetUris.processInstanceActionPath)) {
const processResult = (result: ProcessModel) => {
const primaryFileName = result.primary_file_name;
if (!primaryFileName) {
// this should be very unlikely, since we are in the context of an instance,
// but it's techically possible for the file to have been subsequently deleted or something.
console.error('Primary file name not found for the process model.');
return;
}
navigate(
`/editor/process-models/${modifiedProcessModelId}/files/${primaryFileName}`
);
};
HttpService.makeCallToBackend({
path: `/process-models/${modifiedProcessModelId}`,
successCallback: processResult,
});
}
};
const keyboardShortcuts: KeyboardShortcuts = {
'f,r,enter': {
function: forceRunProcessInstance,
label: 'Force run process instance',
},
'd,enter': {
function: shortcutLoadPrimaryFile,
label: 'View diagram',
},
};
const keyboardShortcutArea = useKeyboardShortcut(keyboardShortcuts);