merged in main and resolved conflicts w/ burnettk
This commit is contained in:
commit
bade105e7f
|
@ -14,21 +14,39 @@ git_commit_message="$2"
|
|||
git_branch="$3"
|
||||
git_commit_username="$4"
|
||||
git_commit_email="$5"
|
||||
git_commit_password="$6"
|
||||
|
||||
if [[ -z "${5:-}" ]]; then
|
||||
if [[ -z "${6:-}" ]]; then
|
||||
>&2 echo "usage: $(basename "$0") [bpmn_models_absolute_dir] [git_commit_message] [git_branch] [git_commit_username] [git_commit_email]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$bpmn_models_absolute_dir"
|
||||
git add .
|
||||
function failed_to_get_lock() {
|
||||
>&2 echo "ERROR: Failed to get lock."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# https://unix.stackexchange.com/a/155077/456630
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
git config --local user.name "$git_commit_username"
|
||||
git config --local user.email "$git_commit_email"
|
||||
git commit -m "$git_commit_message"
|
||||
git push --set-upstream origin "$git_branch"
|
||||
fi
|
||||
function run() {
|
||||
cd "$bpmn_models_absolute_dir"
|
||||
git add .
|
||||
|
||||
# https://unix.stackexchange.com/a/155077/456630
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
echo "No changes to commit"
|
||||
else
|
||||
PAT="${git_commit_username}:${git_commit_password}"
|
||||
AUTH=$(echo -n "$PAT" | openssl base64 | tr -d '\n')
|
||||
|
||||
git config --local user.name "$git_commit_username"
|
||||
git config --local user.email "$git_commit_email"
|
||||
git config --local http.extraHeader "Authorization: Basic $AUTH"
|
||||
git commit -m "$git_commit_message"
|
||||
git push --set-upstream origin "$git_branch"
|
||||
git config --unset --local http.extraHeader
|
||||
fi
|
||||
}
|
||||
|
||||
exec {lock_fd}>/var/lock/mylockfile || failed_to_get_lock
|
||||
flock --timeout 60 "$lock_fd" || failed_to_get_lock
|
||||
run
|
||||
flock -u "$lock_fd"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import with_statement
|
||||
|
||||
import logging
|
||||
from logging.config import fileConfig
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 90dcaa99faa7
|
||||
Revision ID: 9538a3575b63
|
||||
Revises:
|
||||
Create Date: 2022-12-16 16:40:22.246123
|
||||
Create Date: 2022-12-19 14:51:21.949731
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '90dcaa99faa7'
|
||||
revision = '9538a3575b63'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
@ -77,6 +77,8 @@ def upgrade():
|
|||
sa.Column('service_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('name', sa.String(length=255), nullable=True),
|
||||
sa.Column('email', sa.String(length=255), nullable=True),
|
||||
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('service', 'service_id', name='service_key'),
|
||||
sa.UniqueConstraint('uid')
|
|
@ -804,7 +804,7 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/Workflow"
|
||||
|
||||
/process-instances/{modified_process_model_identifier}/{process_instance_id}/terminate:
|
||||
/process-instance-terminate/{modified_process_model_identifier}/{process_instance_id}:
|
||||
parameters:
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
|
@ -825,7 +825,7 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/OkTrue"
|
||||
|
||||
/process-instances/{modified_process_model_identifier}/{process_instance_id}/suspend:
|
||||
/process-instance-suspend/{modified_process_model_identifier}/{process_instance_id}:
|
||||
parameters:
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
|
@ -846,7 +846,7 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/OkTrue"
|
||||
|
||||
/process-instances/{modified_process_model_identifier}/{process_instance_id}/resume:
|
||||
/process-instance-resume/{modified_process_model_identifier}/{process_instance_id}:
|
||||
parameters:
|
||||
- name: process_instance_id
|
||||
in: path
|
||||
|
|
|
@ -123,7 +123,7 @@ permissions:
|
|||
read-process-instance-reports:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/process-instances/reports/*
|
||||
processes-read:
|
||||
groups: [everybody]
|
||||
|
|
|
@ -103,10 +103,10 @@ permissions:
|
|||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/process-instances/*
|
||||
read-process-instance-reports:
|
||||
manage-process-instance-reports:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/process-instances/reports/*
|
||||
processes-read:
|
||||
groups: [everybody]
|
||||
|
|
|
@ -101,7 +101,7 @@ permissions:
|
|||
read-process-instance-reports:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/process-instances/reports/*
|
||||
processes-read:
|
||||
groups: [everybody]
|
||||
|
|
|
@ -26,34 +26,12 @@ class ProcessInstanceNotFoundError(Exception):
|
|||
"""ProcessInstanceNotFoundError."""
|
||||
|
||||
|
||||
class NavigationItemSchema(Schema):
|
||||
"""NavigationItemSchema."""
|
||||
class ProcessInstanceTaskDataCannotBeUpdatedError(Exception):
|
||||
"""ProcessInstanceTaskDataCannotBeUpdatedError."""
|
||||
|
||||
class Meta:
|
||||
"""Meta."""
|
||||
|
||||
fields = [
|
||||
"spec_id",
|
||||
"name",
|
||||
"spec_type",
|
||||
"task_id",
|
||||
"description",
|
||||
"backtracks",
|
||||
"indent",
|
||||
"lane",
|
||||
"state",
|
||||
"children",
|
||||
]
|
||||
unknown = INCLUDE
|
||||
|
||||
state = marshmallow.fields.String(required=False, allow_none=True)
|
||||
description = marshmallow.fields.String(required=False, allow_none=True)
|
||||
backtracks = marshmallow.fields.String(required=False, allow_none=True)
|
||||
lane = marshmallow.fields.String(required=False, allow_none=True)
|
||||
task_id = marshmallow.fields.String(required=False, allow_none=True)
|
||||
children = marshmallow.fields.List(
|
||||
marshmallow.fields.Nested(lambda: NavigationItemSchema())
|
||||
)
|
||||
class ProcessInstanceCannotBeDeletedError(Exception):
|
||||
"""ProcessInstanceCannotBeDeletedError."""
|
||||
|
||||
|
||||
class ProcessInstanceStatus(SpiffEnum):
|
||||
|
@ -135,6 +113,19 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
|||
"""Validate_status."""
|
||||
return self.validate_enum_field(key, value, ProcessInstanceStatus)
|
||||
|
||||
def can_submit_task(self) -> bool:
|
||||
"""Can_submit_task."""
|
||||
return not self.has_terminal_status() and self.status != "suspended"
|
||||
|
||||
def has_terminal_status(self) -> bool:
|
||||
"""Has_terminal_status."""
|
||||
return self.status in self.terminal_statuses()
|
||||
|
||||
@classmethod
|
||||
def terminal_statuses(cls) -> list[str]:
|
||||
"""Terminal_statuses."""
|
||||
return ["complete", "error", "terminated"]
|
||||
|
||||
|
||||
class ProcessInstanceModelSchema(Schema):
|
||||
"""ProcessInstanceModelSchema."""
|
||||
|
|
|
@ -37,6 +37,8 @@ class UserModel(SpiffworkflowBaseDBModel):
|
|||
service_id = db.Column(db.String(255), nullable=False, unique=False)
|
||||
name = db.Column(db.String(255))
|
||||
email = db.Column(db.String(255))
|
||||
updated_at_in_seconds: int = db.Column(db.Integer)
|
||||
created_at_in_seconds: int = db.Column(db.Integer)
|
||||
|
||||
user_group_assignments = relationship("UserGroupAssignmentModel", cascade="delete") # type: ignore
|
||||
groups = relationship( # type: ignore
|
||||
|
|
|
@ -54,9 +54,15 @@ from spiffworkflow_backend.models.principal import PrincipalModel
|
|||
from spiffworkflow_backend.models.process_group import ProcessGroup
|
||||
from spiffworkflow_backend.models.process_group import ProcessGroupSchema
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceApiSchema
|
||||
from spiffworkflow_backend.models.process_instance import (
|
||||
ProcessInstanceCannotBeDeletedError,
|
||||
)
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModelSchema
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceStatus
|
||||
from spiffworkflow_backend.models.process_instance import (
|
||||
ProcessInstanceTaskDataCannotBeUpdatedError,
|
||||
)
|
||||
from spiffworkflow_backend.models.process_instance_metadata import (
|
||||
ProcessInstanceMetadataModel,
|
||||
)
|
||||
|
@ -578,6 +584,13 @@ def process_instance_run(
|
|||
process_instance = ProcessInstanceService().get_process_instance(
|
||||
process_instance_id
|
||||
)
|
||||
if process_instance.status != "not_started":
|
||||
raise ApiError(
|
||||
error_code="process_instance_not_runnable",
|
||||
message=f"Process Instance ({process_instance.id}) is currently running or has already run.",
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
|
||||
if do_engine_steps:
|
||||
|
@ -958,7 +971,7 @@ def process_instance_list(
|
|||
|
||||
if report_filter.initiated_by_me is True:
|
||||
process_instance_query = process_instance_query.filter(
|
||||
ProcessInstanceModel.status.in_(["complete", "error", "terminated"]) # type: ignore
|
||||
ProcessInstanceModel.status.in_(ProcessInstanceModel.terminal_statuses()) # type: ignore
|
||||
)
|
||||
process_instance_query = process_instance_query.filter_by(
|
||||
process_initiator=g.user
|
||||
|
@ -967,7 +980,7 @@ def process_instance_list(
|
|||
# TODO: not sure if this is exactly what is wanted
|
||||
if report_filter.with_tasks_completed_by_me is True:
|
||||
process_instance_query = process_instance_query.filter(
|
||||
ProcessInstanceModel.status.in_(["complete", "error", "terminated"]) # type: ignore
|
||||
ProcessInstanceModel.status.in_(ProcessInstanceModel.terminal_statuses()) # type: ignore
|
||||
)
|
||||
# process_instance_query = process_instance_query.join(UserModel, UserModel.id == ProcessInstanceModel.process_initiator_id)
|
||||
# process_instance_query = process_instance_query.add_columns(UserModel.username)
|
||||
|
@ -996,7 +1009,7 @@ def process_instance_list(
|
|||
|
||||
if report_filter.with_tasks_completed_by_my_group is True:
|
||||
process_instance_query = process_instance_query.filter(
|
||||
ProcessInstanceModel.status.in_(["complete", "error", "terminated"]) # type: ignore
|
||||
ProcessInstanceModel.status.in_(ProcessInstanceModel.terminal_statuses()) # type: ignore
|
||||
)
|
||||
process_instance_query = process_instance_query.join(
|
||||
SpiffStepDetailsModel,
|
||||
|
@ -1185,6 +1198,12 @@ def process_instance_delete(
|
|||
"""Create_process_instance."""
|
||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||
|
||||
if not process_instance.has_terminal_status():
|
||||
raise ProcessInstanceCannotBeDeletedError(
|
||||
f"Process instance ({process_instance.id}) cannot be deleted since it does not have a terminal status. "
|
||||
f"Current status is {process_instance.status}."
|
||||
)
|
||||
|
||||
# (Pdb) db.session.delete
|
||||
# <bound method delete of <sqlalchemy.orm.scoping.scoped_session object at 0x103eaab30>>
|
||||
db.session.query(SpiffLoggingModel).filter_by(
|
||||
|
@ -1680,6 +1699,13 @@ def task_submit(
|
|||
"""Task_submit_user_data."""
|
||||
principal = find_principal_or_raise()
|
||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||
if not process_instance.can_submit_task():
|
||||
raise ApiError(
|
||||
error_code="process_instance_not_runnable",
|
||||
message=f"Process Instance ({process_instance.id}) has status "
|
||||
f"{process_instance.status} which does not allow tasks to be submitted.",
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
spiff_task = get_spiff_task_from_process_instance(
|
||||
|
@ -2141,6 +2167,11 @@ def update_task_data(
|
|||
ProcessInstanceModel.id == int(process_instance_id)
|
||||
).first()
|
||||
if process_instance:
|
||||
if process_instance.status != "suspended":
|
||||
raise ProcessInstanceTaskDataCannotBeUpdatedError(
|
||||
f"The process instance needs to be suspended to udpate the task-data. It is currently: {process_instance.status}"
|
||||
)
|
||||
|
||||
process_instance_bpmn_json_dict = json.loads(process_instance.bpmn_json)
|
||||
if "new_task_data" in body:
|
||||
new_task_data_str: str = body["new_task_data"]
|
||||
|
|
|
@ -100,6 +100,7 @@ class GitService:
|
|||
branch_name_to_use,
|
||||
git_username,
|
||||
git_email,
|
||||
current_app.config["GIT_USER_PASSWORD"],
|
||||
]
|
||||
return cls.run_shell_command_to_get_stdout(shell_command)
|
||||
|
||||
|
|
|
@ -1375,7 +1375,7 @@ class TestProcessApi(BaseTest):
|
|||
assert response.json is not None
|
||||
|
||||
response = client.post(
|
||||
f"/v1.0/process-instances/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}/terminate",
|
||||
f"/v1.0/process-instance-terminate/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
@ -1396,15 +1396,13 @@ class TestProcessApi(BaseTest):
|
|||
) -> None:
|
||||
"""Test_process_instance_delete."""
|
||||
process_group_id = "my_process_group"
|
||||
process_model_id = "user_task"
|
||||
bpmn_file_name = "user_task.bpmn"
|
||||
bpmn_file_location = "user_task"
|
||||
process_model_id = "sample"
|
||||
bpmn_file_location = "sample"
|
||||
process_model_identifier = self.create_group_and_model_with_bpmn(
|
||||
client,
|
||||
with_super_admin_user,
|
||||
process_group_id=process_group_id,
|
||||
process_model_id=process_model_id,
|
||||
bpmn_file_name=bpmn_file_name,
|
||||
bpmn_file_location=bpmn_file_location,
|
||||
)
|
||||
|
||||
|
@ -1420,11 +1418,13 @@ class TestProcessApi(BaseTest):
|
|||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
assert response.json is not None
|
||||
assert response.status_code == 200
|
||||
|
||||
delete_response = client.delete(
|
||||
f"/v1.0/process-instances/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
assert delete_response.json["ok"] is True
|
||||
assert delete_response.status_code == 200
|
||||
|
||||
def test_task_show(
|
||||
|
@ -2421,7 +2421,7 @@ class TestProcessApi(BaseTest):
|
|||
assert process_instance.status == "user_input_required"
|
||||
|
||||
client.post(
|
||||
f"/v1.0/process-instances/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}/suspend",
|
||||
f"/v1.0/process-instance-suspend/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
process_instance = ProcessInstanceService().get_process_instance(
|
||||
|
@ -2429,15 +2429,25 @@ class TestProcessApi(BaseTest):
|
|||
)
|
||||
assert process_instance.status == "suspended"
|
||||
|
||||
# TODO: Why can I run a suspended process instance?
|
||||
response = client.post(
|
||||
f"/v1.0/process-instances/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}/run",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
process_instance = ProcessInstanceService().get_process_instance(
|
||||
process_instance_id
|
||||
)
|
||||
assert process_instance.status == "suspended"
|
||||
assert response.status_code == 400
|
||||
|
||||
# task = response.json['next_task']
|
||||
|
||||
print("test_process_instance_suspend")
|
||||
response = client.post(
|
||||
f"/v1.0/process-instance-resume/{self.modify_process_identifier_for_path_param(process_model_identifier)}/{process_instance_id}",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
assert response.status_code == 200
|
||||
process_instance = ProcessInstanceService().get_process_instance(
|
||||
process_instance_id
|
||||
)
|
||||
assert process_instance.status == "waiting"
|
||||
|
||||
def test_script_unit_test_run(
|
||||
self,
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
export default class ProcessInstanceClass {
|
||||
static terminalStatuses() {
|
||||
return ['complete', 'error', 'terminated'];
|
||||
}
|
||||
}
|
|
@ -11,6 +11,9 @@ export const useUriListForPermissions = () => {
|
|||
processGroupShowPath: `/v1.0/process-groups/${params.process_group_id}`,
|
||||
processInstanceCreatePath: `/v1.0/process-instances/${params.process_model_id}`,
|
||||
processInstanceActionPath: `/v1.0/process-instances/${params.process_model_id}/${params.process_instance_id}`,
|
||||
processInstanceResumePath: `/v1.0/process-instance-resume/${params.process_model_id}/${params.process_instance_id}`,
|
||||
processInstanceSuspendPath: `/v1.0/process-instance-suspend/${params.process_model_id}/${params.process_instance_id}`,
|
||||
processInstanceTerminatePath: `/v1.0/process-instance-terminate/${params.process_model_id}/${params.process_instance_id}`,
|
||||
processInstanceListPath: '/v1.0/process-instances',
|
||||
processInstanceLogListPath: `/v1.0/logs/${params.process_model_id}/${params.process_instance_id}`,
|
||||
processInstanceReportListPath: '/v1.0/process-instances/reports',
|
||||
|
|
|
@ -52,6 +52,10 @@ export interface ProcessInstance {
|
|||
id: number;
|
||||
process_model_identifier: string;
|
||||
process_model_display_name: string;
|
||||
status: string;
|
||||
start_in_seconds: number | null;
|
||||
end_in_seconds: number | null;
|
||||
bpmn_xml_file_contents?: string;
|
||||
spiff_step?: number;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import {
|
|||
ProcessInstanceTask,
|
||||
} from '../interfaces';
|
||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||
import ProcessInstanceClass from '../classes/ProcessInstanceClass';
|
||||
|
||||
export default function ProcessInstanceShow() {
|
||||
const navigate = useNavigate();
|
||||
|
@ -74,9 +75,9 @@ export default function ProcessInstanceShow() {
|
|||
[targetUris.processInstanceActionPath]: ['DELETE'],
|
||||
[targetUris.processInstanceLogListPath]: ['GET'],
|
||||
[targetUris.processModelShowPath]: ['PUT'],
|
||||
[`${targetUris.processInstanceActionPath}/suspend`]: ['POST'],
|
||||
[`${targetUris.processInstanceActionPath}/terminate`]: ['POST'],
|
||||
[`${targetUris.processInstanceActionPath}/resume`]: ['POST'],
|
||||
[`${targetUris.processInstanceResumePath}`]: ['POST'],
|
||||
[`${targetUris.processInstanceSuspendPath}`]: ['POST'],
|
||||
[`${targetUris.processInstanceTerminatePath}`]: ['POST'],
|
||||
};
|
||||
const { ability, permissionsLoaded } = usePermissionFetcher(
|
||||
permissionRequestData
|
||||
|
@ -146,7 +147,7 @@ export default function ProcessInstanceShow() {
|
|||
|
||||
const terminateProcessInstance = () => {
|
||||
HttpService.makeCallToBackend({
|
||||
path: `${targetUris.processInstanceActionPath}/terminate`,
|
||||
path: `${targetUris.processInstanceTerminatePath}`,
|
||||
successCallback: refreshPage,
|
||||
httpMethod: 'POST',
|
||||
});
|
||||
|
@ -154,7 +155,7 @@ export default function ProcessInstanceShow() {
|
|||
|
||||
const suspendProcessInstance = () => {
|
||||
HttpService.makeCallToBackend({
|
||||
path: `${targetUris.processInstanceActionPath}/suspend`,
|
||||
path: `${targetUris.processInstanceSuspendPath}`,
|
||||
successCallback: refreshPage,
|
||||
httpMethod: 'POST',
|
||||
});
|
||||
|
@ -162,7 +163,7 @@ export default function ProcessInstanceShow() {
|
|||
|
||||
const resumeProcessInstance = () => {
|
||||
HttpService.makeCallToBackend({
|
||||
path: `${targetUris.processInstanceActionPath}/resume`,
|
||||
path: `${targetUris.processInstanceResumePath}`,
|
||||
successCallback: refreshPage,
|
||||
httpMethod: 'POST',
|
||||
});
|
||||
|
@ -183,29 +184,23 @@ export default function ProcessInstanceShow() {
|
|||
return taskIds;
|
||||
};
|
||||
|
||||
const currentSpiffStep = (processInstanceToUse: any) => {
|
||||
if (typeof params.spiff_step === 'undefined') {
|
||||
return processInstanceToUse.spiff_step;
|
||||
const currentSpiffStep = () => {
|
||||
if (processInstance && typeof params.spiff_step === 'undefined') {
|
||||
return processInstance.spiff_step || 0;
|
||||
}
|
||||
|
||||
return Number(params.spiff_step);
|
||||
};
|
||||
|
||||
const showingFirstSpiffStep = (processInstanceToUse: any) => {
|
||||
return currentSpiffStep(processInstanceToUse) === 1;
|
||||
const showingFirstSpiffStep = () => {
|
||||
return currentSpiffStep() === 1;
|
||||
};
|
||||
|
||||
const showingLastSpiffStep = (processInstanceToUse: any) => {
|
||||
return (
|
||||
currentSpiffStep(processInstanceToUse) === processInstanceToUse.spiff_step
|
||||
);
|
||||
const showingLastSpiffStep = () => {
|
||||
return processInstance && currentSpiffStep() === processInstance.spiff_step;
|
||||
};
|
||||
|
||||
const spiffStepLink = (
|
||||
processInstanceToUse: any,
|
||||
label: any,
|
||||
distance: number
|
||||
) => {
|
||||
const spiffStepLink = (label: any, distance: number) => {
|
||||
const processIdentifier = searchParams.get('process_identifier');
|
||||
let queryParams = '';
|
||||
if (processIdentifier) {
|
||||
|
@ -217,32 +212,35 @@ export default function ProcessInstanceShow() {
|
|||
data-qa="process-instance-step-link"
|
||||
to={`/admin/process-instances/${params.process_model_id}/${
|
||||
params.process_instance_id
|
||||
}/${currentSpiffStep(processInstanceToUse) + distance}${queryParams}`}
|
||||
}/${currentSpiffStep() + distance}${queryParams}`}
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
const previousStepLink = (processInstanceToUse: any) => {
|
||||
if (showingFirstSpiffStep(processInstanceToUse)) {
|
||||
const previousStepLink = () => {
|
||||
if (showingFirstSpiffStep()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return spiffStepLink(processInstanceToUse, <CaretLeft />, -1);
|
||||
return spiffStepLink(<CaretLeft />, -1);
|
||||
};
|
||||
|
||||
const nextStepLink = (processInstanceToUse: any) => {
|
||||
if (showingLastSpiffStep(processInstanceToUse)) {
|
||||
const nextStepLink = () => {
|
||||
if (showingLastSpiffStep()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return spiffStepLink(processInstanceToUse, <CaretRight />, 1);
|
||||
return spiffStepLink(<CaretRight />, 1);
|
||||
};
|
||||
|
||||
const getInfoTag = (processInstanceToUse: any) => {
|
||||
const getInfoTag = () => {
|
||||
if (!processInstance) {
|
||||
return null;
|
||||
}
|
||||
const currentEndDate = convertSecondsToFormattedDateTime(
|
||||
processInstanceToUse.end_in_seconds
|
||||
processInstance.end_in_seconds || 0
|
||||
);
|
||||
let currentEndDateTag;
|
||||
if (currentEndDate) {
|
||||
|
@ -253,7 +251,7 @@ export default function ProcessInstanceShow() {
|
|||
</Column>
|
||||
<Column sm={3} md={3} lg={3} className="grid-date">
|
||||
{convertSecondsToFormattedDateTime(
|
||||
processInstanceToUse.end_in_seconds
|
||||
processInstance.end_in_seconds || 0
|
||||
) || 'N/A'}
|
||||
</Column>
|
||||
</Grid>
|
||||
|
@ -261,13 +259,13 @@ export default function ProcessInstanceShow() {
|
|||
}
|
||||
|
||||
let statusIcon = <InProgress />;
|
||||
if (processInstanceToUse.status === 'suspended') {
|
||||
if (processInstance.status === 'suspended') {
|
||||
statusIcon = <PauseOutline />;
|
||||
} else if (processInstanceToUse.status === 'complete') {
|
||||
} else if (processInstance.status === 'complete') {
|
||||
statusIcon = <Checkmark />;
|
||||
} else if (processInstanceToUse.status === 'terminated') {
|
||||
} else if (processInstance.status === 'terminated') {
|
||||
statusIcon = <StopOutline />;
|
||||
} else if (processInstanceToUse.status === 'error') {
|
||||
} else if (processInstance.status === 'error') {
|
||||
statusIcon = <Warning />;
|
||||
}
|
||||
|
||||
|
@ -279,7 +277,7 @@ export default function ProcessInstanceShow() {
|
|||
</Column>
|
||||
<Column sm={3} md={3} lg={3} className="grid-date">
|
||||
{convertSecondsToFormattedDateTime(
|
||||
processInstanceToUse.start_in_seconds
|
||||
processInstance.start_in_seconds || 0
|
||||
)}
|
||||
</Column>
|
||||
</Grid>
|
||||
|
@ -290,7 +288,7 @@ export default function ProcessInstanceShow() {
|
|||
</Column>
|
||||
<Column sm={3} md={3} lg={3}>
|
||||
<Tag type="gray" size="sm" className="span-tag">
|
||||
{processInstanceToUse.status} {statusIcon}
|
||||
{processInstance.status} {statusIcon}
|
||||
</Tag>
|
||||
</Column>
|
||||
</Grid>
|
||||
|
@ -333,11 +331,10 @@ export default function ProcessInstanceShow() {
|
|||
);
|
||||
};
|
||||
|
||||
const terminateButton = (processInstanceToUse: any) => {
|
||||
const terminateButton = () => {
|
||||
if (
|
||||
['complete', 'terminated', 'error'].indexOf(
|
||||
processInstanceToUse.status
|
||||
) === -1
|
||||
processInstance &&
|
||||
!ProcessInstanceClass.terminalStatuses().includes(processInstance.status)
|
||||
) {
|
||||
return (
|
||||
<ButtonWithConfirmation
|
||||
|
@ -345,7 +342,7 @@ export default function ProcessInstanceShow() {
|
|||
renderIcon={StopOutline}
|
||||
iconDescription="Terminate"
|
||||
hasIconOnly
|
||||
description={`Terminate Process Instance: ${processInstanceToUse.id}`}
|
||||
description={`Terminate Process Instance: ${processInstance.id}`}
|
||||
onConfirmation={terminateProcessInstance}
|
||||
confirmButtonLabel="Terminate"
|
||||
/>
|
||||
|
@ -354,11 +351,12 @@ export default function ProcessInstanceShow() {
|
|||
return <div />;
|
||||
};
|
||||
|
||||
const suspendButton = (processInstanceToUse: any) => {
|
||||
const suspendButton = () => {
|
||||
if (
|
||||
['complete', 'terminated', 'error', 'suspended'].indexOf(
|
||||
processInstanceToUse.status
|
||||
) === -1
|
||||
processInstance &&
|
||||
!ProcessInstanceClass.terminalStatuses()
|
||||
.concat(['suspended'])
|
||||
.includes(processInstance.status)
|
||||
) {
|
||||
return (
|
||||
<Button
|
||||
|
@ -374,8 +372,8 @@ export default function ProcessInstanceShow() {
|
|||
return <div />;
|
||||
};
|
||||
|
||||
const resumeButton = (processInstanceToUse: any) => {
|
||||
if (processInstanceToUse.status === 'suspended') {
|
||||
const resumeButton = () => {
|
||||
if (processInstance && processInstance.status === 'suspended') {
|
||||
return (
|
||||
<Button
|
||||
onClick={resumeProcessInstance}
|
||||
|
@ -450,9 +448,11 @@ export default function ProcessInstanceShow() {
|
|||
|
||||
const canEditTaskData = (task: any) => {
|
||||
return (
|
||||
processInstance &&
|
||||
ability.can('PUT', targetUris.processInstanceTaskListDataPath) &&
|
||||
task.state === 'READY' &&
|
||||
showingLastSpiffStep(processInstance as any)
|
||||
processInstance.status === 'suspended' &&
|
||||
showingLastSpiffStep()
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -475,7 +475,7 @@ export default function ProcessInstanceShow() {
|
|||
};
|
||||
|
||||
const saveTaskDataFailure = (result: any) => {
|
||||
setErrorMessage({ message: result.toString() });
|
||||
setErrorMessage({ message: result.message });
|
||||
};
|
||||
|
||||
const saveTaskData = () => {
|
||||
|
@ -591,37 +591,41 @@ export default function ProcessInstanceShow() {
|
|||
return null;
|
||||
};
|
||||
|
||||
const stepsElement = (processInstanceToUse: any) => {
|
||||
const stepsElement = () => {
|
||||
if (!processInstance) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Grid condensed fullWidth>
|
||||
<Column sm={3} md={3} lg={3}>
|
||||
<Stack orientation="horizontal" gap={3} className="smaller-text">
|
||||
{previousStepLink(processInstanceToUse)}
|
||||
Step {currentSpiffStep(processInstanceToUse)} of{' '}
|
||||
{processInstanceToUse.spiff_step}
|
||||
{nextStepLink(processInstanceToUse)}
|
||||
{previousStepLink()}
|
||||
Step {currentSpiffStep()} of {processInstance.spiff_step}
|
||||
{nextStepLink()}
|
||||
</Stack>
|
||||
</Column>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
const buttonIcons = (processInstanceToUse: any) => {
|
||||
const buttonIcons = () => {
|
||||
if (!processInstance) {
|
||||
return null;
|
||||
}
|
||||
const elements = [];
|
||||
if (
|
||||
ability.can('POST', `${targetUris.processInstanceActionPath}/terminate`)
|
||||
) {
|
||||
elements.push(terminateButton(processInstanceToUse));
|
||||
if (ability.can('POST', `${targetUris.processInstanceTerminatePath}`)) {
|
||||
elements.push(terminateButton());
|
||||
}
|
||||
if (ability.can('POST', `${targetUris.processInstanceSuspendPath}`)) {
|
||||
elements.push(suspendButton());
|
||||
}
|
||||
if (ability.can('POST', `${targetUris.processInstanceResumePath}`)) {
|
||||
elements.push(resumeButton());
|
||||
}
|
||||
if (
|
||||
ability.can('POST', `${targetUris.processInstanceActionPath}/suspend`)
|
||||
ability.can('DELETE', targetUris.processInstanceActionPath) &&
|
||||
ProcessInstanceClass.terminalStatuses().includes(processInstance.status)
|
||||
) {
|
||||
elements.push(suspendButton(processInstanceToUse));
|
||||
}
|
||||
if (ability.can('POST', `${targetUris.processInstanceActionPath}/resume`)) {
|
||||
elements.push(resumeButton(processInstanceToUse));
|
||||
}
|
||||
if (ability.can('DELETE', targetUris.processInstanceActionPath)) {
|
||||
elements.push(
|
||||
<ButtonWithConfirmation
|
||||
data-qa="process-instance-delete"
|
||||
|
@ -629,7 +633,7 @@ export default function ProcessInstanceShow() {
|
|||
renderIcon={TrashCan}
|
||||
iconDescription="Delete"
|
||||
hasIconOnly
|
||||
description={`Delete Process Instance: ${processInstanceToUse.id}`}
|
||||
description={`Delete Process Instance: ${processInstance.id}`}
|
||||
onConfirmation={deleteProcessInstance}
|
||||
confirmButtonLabel="Delete"
|
||||
/>
|
||||
|
@ -639,7 +643,6 @@ export default function ProcessInstanceShow() {
|
|||
};
|
||||
|
||||
if (processInstance && (tasks || tasksCallHadError)) {
|
||||
const processInstanceToUse = processInstance as any;
|
||||
const taskIds = getTaskIds();
|
||||
const processModelId = unModifyProcessIdentifierForPathParam(
|
||||
params.process_model_id ? params.process_model_id : ''
|
||||
|
@ -655,26 +658,26 @@ export default function ProcessInstanceShow() {
|
|||
entityType: 'process-model-id',
|
||||
linkLastItem: true,
|
||||
},
|
||||
[`Process Instance Id: ${processInstanceToUse.id}`],
|
||||
[`Process Instance Id: ${processInstance.id}`],
|
||||
]}
|
||||
/>
|
||||
<Stack orientation="horizontal" gap={1}>
|
||||
<h1 className="with-icons">
|
||||
Process Instance Id: {processInstanceToUse.id}
|
||||
Process Instance Id: {processInstance.id}
|
||||
</h1>
|
||||
{buttonIcons(processInstanceToUse)}
|
||||
{buttonIcons()}
|
||||
</Stack>
|
||||
<br />
|
||||
<br />
|
||||
{getInfoTag(processInstanceToUse)}
|
||||
{getInfoTag()}
|
||||
<br />
|
||||
{taskDataDisplayArea()}
|
||||
{stepsElement(processInstanceToUse)}
|
||||
{stepsElement()}
|
||||
<br />
|
||||
<ReactDiagramEditor
|
||||
processModelId={processModelId || ''}
|
||||
diagramXML={processInstanceToUse.bpmn_xml_file_contents || ''}
|
||||
fileName={processInstanceToUse.bpmn_xml_file_contents || ''}
|
||||
diagramXML={processInstance.bpmn_xml_file_contents || ''}
|
||||
fileName={processInstance.bpmn_xml_file_contents || ''}
|
||||
readyOrWaitingProcessInstanceTasks={taskIds.readyOrWaiting}
|
||||
completedProcessInstanceTasks={taskIds.completed}
|
||||
diagramType="readonly"
|
||||
|
|
|
@ -417,13 +417,15 @@ export default function ProcessModelShow() {
|
|||
};
|
||||
|
||||
const checkDuplicateFile = (event: any) => {
|
||||
if (processModel && processModel.files.length > 0) {
|
||||
if (processModel) {
|
||||
let foundExistingFile = false;
|
||||
processModel.files.forEach((file) => {
|
||||
if (file.name === filesToUpload[0].name) {
|
||||
foundExistingFile = true;
|
||||
}
|
||||
});
|
||||
if (processModel.files.length > 0) {
|
||||
processModel.files.forEach((file) => {
|
||||
if (file.name === filesToUpload[0].name) {
|
||||
foundExistingFile = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (foundExistingFile) {
|
||||
displayOverwriteConfirmation(filesToUpload[0].name);
|
||||
setFileUploadEvent(event);
|
||||
|
@ -431,12 +433,11 @@ export default function ProcessModelShow() {
|
|||
doFileUpload(event);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleFileUpload = (event: any) => {
|
||||
if (processModel) {
|
||||
checkDuplicateFile(event);
|
||||
}
|
||||
checkDuplicateFile(event);
|
||||
setShowFileUploadModal(false);
|
||||
};
|
||||
|
||||
|
@ -473,9 +474,6 @@ export default function ProcessModelShow() {
|
|||
};
|
||||
|
||||
const processModelFilesSection = () => {
|
||||
if (!processModel) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Grid
|
||||
condensed
|
||||
|
|
Loading…
Reference in New Issue