Merge remote-tracking branch 'origin/unit_test_404' into feature/bpmn_user_permissions
This commit is contained in:
commit
6de91d2230
|
@ -9,7 +9,7 @@ set -o errtrace -o errexit -o nounset -o pipefail
|
|||
|
||||
if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then
|
||||
script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
export BPMN_SPEC_ABSOLUTE_DIR="$script_dir/../../sample-process-models"
|
||||
export BPMN_SPEC_ABSOLUTE_DIR="$script_dir/../../../sample-process-models"
|
||||
fi
|
||||
|
||||
if [[ -z "${SPIFFWORKFLOW_BACKEND_DOCKER_COMPOSE_PROFILE:-}" ]]; then
|
||||
|
|
|
@ -68,7 +68,7 @@ services:
|
|||
- "7000:7000"
|
||||
network_mode: host
|
||||
volumes:
|
||||
- ${BPMN_SPEC_ABSOLUTE_DIR:-./../sample-process-models}:/app/process_models
|
||||
- ${BPMN_SPEC_ABSOLUTE_DIR:-../../sample-process-models}:/app/process_models
|
||||
- ./log:/app/log
|
||||
healthcheck:
|
||||
test: curl localhost:7000/v1.0/status --fail
|
||||
|
@ -82,7 +82,7 @@ services:
|
|||
profiles:
|
||||
- debug
|
||||
volumes:
|
||||
- ${BPMN_SPEC_ABSOLUTE_DIR:-./../sample-process-models}:/app/process_models
|
||||
- ${BPMN_SPEC_ABSOLUTE_DIR:-../../sample-process-models}:/app/process_models
|
||||
- ./:/app
|
||||
command: /app/bin/boot_in_docker_debug_mode
|
||||
|
||||
|
|
|
@ -610,15 +610,9 @@ paths:
|
|||
items:
|
||||
$ref: "#/components/schemas/Workflow"
|
||||
|
||||
/process-models/{process_group_id}/{process_model_id}/script-unit-tests:
|
||||
/process-models/{modified_process_model_identifier}/script-unit-tests:
|
||||
parameters:
|
||||
- name: process_group_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process group
|
||||
schema:
|
||||
type: string
|
||||
- name: process_model_id
|
||||
- name: modified_process_model_identifier
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process model.
|
||||
|
@ -637,15 +631,9 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/Workflow"
|
||||
|
||||
/process-models/{process_group_id}/{process_model_id}/script-unit-tests/run:
|
||||
/process-models/{modified_process_model_identifier}/script-unit-tests/run:
|
||||
parameters:
|
||||
- name: process_group_id
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process group
|
||||
schema:
|
||||
type: string
|
||||
- name: process_model_id
|
||||
- name: modified_process_model_identifier
|
||||
in: path
|
||||
required: true
|
||||
description: The unique id of an existing process model.
|
||||
|
@ -699,6 +687,12 @@ paths:
|
|||
description: The unique id of an existing process instance.
|
||||
schema:
|
||||
type: integer
|
||||
- name: process_identifier
|
||||
in: query
|
||||
required: false
|
||||
description: The identifier of the process to use for the diagram. Useful for displaying the diagram for a call activity.
|
||||
schema:
|
||||
type: string
|
||||
get:
|
||||
tags:
|
||||
- Process Instances
|
||||
|
|
|
@ -17,7 +17,6 @@ groups:
|
|||
dan,
|
||||
mike,
|
||||
jason,
|
||||
j,
|
||||
jarrad,
|
||||
elizabeth,
|
||||
jon,
|
||||
|
@ -32,7 +31,6 @@ groups:
|
|||
dan,
|
||||
mike,
|
||||
jason,
|
||||
j,
|
||||
amir,
|
||||
jarrad,
|
||||
elizabeth,
|
||||
|
@ -62,16 +60,29 @@ groups:
|
|||
core,
|
||||
harmeet,
|
||||
]
|
||||
admin-ro:
|
||||
users:
|
||||
[
|
||||
j,
|
||||
]
|
||||
|
||||
# permission "admin"
|
||||
permissions:
|
||||
admin:
|
||||
groups: [admin]
|
||||
users: []
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /*
|
||||
admin-readonly:
|
||||
groups: [admin-ro]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /*
|
||||
admin-process-instances-for-readonly:
|
||||
groups: [admin-ro]
|
||||
users: []
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/process-instances/*
|
||||
|
||||
# permission: "basic"
|
||||
tasks-crud:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
default_group: everybody
|
||||
|
||||
groups:
|
||||
admin:
|
||||
users:
|
||||
[
|
||||
admin,
|
||||
jakub,
|
||||
kb,
|
||||
alex,
|
||||
dan,
|
||||
mike,
|
||||
jason,
|
||||
j,
|
||||
jarrad,
|
||||
elizabeth,
|
||||
jon,
|
||||
natalia,
|
||||
]
|
||||
|
||||
Finance Team:
|
||||
users:
|
||||
[
|
||||
jakub,
|
||||
alex,
|
||||
dan,
|
||||
mike,
|
||||
jason,
|
||||
j,
|
||||
amir,
|
||||
jarrad,
|
||||
elizabeth,
|
||||
jon,
|
||||
natalia,
|
||||
sasha,
|
||||
fin,
|
||||
fin1,
|
||||
]
|
||||
|
||||
demo:
|
||||
users:
|
||||
[
|
||||
core,
|
||||
fin,
|
||||
fin1,
|
||||
harmeet,
|
||||
sasha,
|
||||
manuchehr,
|
||||
lead,
|
||||
lead1
|
||||
]
|
||||
|
||||
core-contributor:
|
||||
users:
|
||||
[
|
||||
core,
|
||||
harmeet,
|
||||
]
|
||||
|
||||
permissions:
|
||||
admin:
|
||||
groups: [admin]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /*
|
||||
admin-process-instances:
|
||||
groups: [admin]
|
||||
users: []
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/process-instances/*
|
||||
|
||||
tasks-crud:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/tasks/*
|
||||
|
||||
service-tasks:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/service-tasks
|
||||
|
||||
|
||||
# read all for everybody
|
||||
read-all-process-groups:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/process-groups/*
|
||||
read-all-process-models:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/process-models/*
|
||||
read-all-process-instance:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/process-instances/*
|
||||
read-process-instance-reports:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/process-instances/reports/*
|
||||
processes-read:
|
||||
groups: [everybody]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/processes
|
||||
|
||||
|
||||
manage-procurement-admin-instances:
|
||||
groups: ["Project Lead"]
|
||||
users: []
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/process-instances/manage-procurement:*
|
||||
manage-procurement-admin-instances-slash:
|
||||
groups: ["Project Lead"]
|
||||
users: []
|
||||
allowed_permissions: [create, read, update, delete]
|
||||
uri: /v1.0/process-instances/manage-procurement/*
|
||||
manage-procurement-admin-instance-logs:
|
||||
groups: ["Project Lead"]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/logs/manage-procurement:*
|
||||
manage-procurement-admin-instance-logs-slash:
|
||||
groups: ["Project Lead"]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/logs/manage-procurement/*
|
||||
|
||||
manage-revenue-streams-instances:
|
||||
groups: ["core-contributor", "demo"]
|
||||
users: []
|
||||
allowed_permissions: [create, read]
|
||||
uri: /v1.0/process-instances/manage-revenue-streams:product-revenue-streams:customer-contracts-trade-terms/*
|
||||
manage-revenue-streams-instance-logs:
|
||||
groups: ["core-contributor", "demo"]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/logs/manage-revenue-streams:product-revenue-streams:customer-contracts-trade-terms/*
|
||||
|
||||
manage-procurement-invoice-instances:
|
||||
groups: ["core-contributor", "demo"]
|
||||
users: []
|
||||
allowed_permissions: [create, read]
|
||||
uri: /v1.0/process-instances/manage-procurement:procurement:core-contributor-invoice-management:*
|
||||
manage-procurement-invoice-instance-logs:
|
||||
groups: ["core-contributor", "demo"]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/logs/manage-procurement:procurement:core-contributor-invoice-management:*
|
||||
|
||||
manage-procurement-instances:
|
||||
groups: ["core-contributor", "demo"]
|
||||
users: []
|
||||
allowed_permissions: [create, read]
|
||||
uri: /v1.0/process-instances/manage-procurement:vendor-lifecycle-management:*
|
||||
manage-procurement-instance-logs:
|
||||
groups: ["core-contributor", "demo"]
|
||||
users: []
|
||||
allowed_permissions: [read]
|
||||
uri: /v1.0/logs/manage-procurement:vendor-lifecycle-management:*
|
|
@ -4,3 +4,4 @@ from os import environ
|
|||
GIT_BRANCH = environ.get("GIT_BRANCH_TO_PUBLISH_TO", default="staging")
|
||||
GIT_BRANCH_TO_PUBLISH_TO = environ.get("GIT_BRANCH_TO_PUBLISH_TO", default="main")
|
||||
GIT_COMMIT_ON_SAVE = False
|
||||
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME = "staging.yml"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
"""Spiff_step_details."""
|
||||
"""Process_instance_metadata."""
|
||||
from dataclasses import dataclass
|
||||
|
||||
from flask_bpmn.models.db import db
|
||||
|
|
|
@ -8,6 +8,10 @@ from marshmallow import INCLUDE
|
|||
from sqlalchemy import UniqueConstraint
|
||||
|
||||
|
||||
class SpecReferenceNotFoundError(Exception):
|
||||
"""SpecReferenceNotFoundError."""
|
||||
|
||||
|
||||
@dataclass()
|
||||
class SpecReference:
|
||||
"""File Reference Information.
|
||||
|
|
|
@ -21,7 +21,7 @@ class SpiffStepDetailsModel(SpiffworkflowBaseDBModel):
|
|||
ForeignKey(ProcessInstanceModel.id), nullable=False # type: ignore
|
||||
)
|
||||
spiff_step: int = db.Column(db.Integer, nullable=False)
|
||||
task_json: str = deferred(db.Column(db.JSON, nullable=False)) # type: ignore
|
||||
task_json: dict = deferred(db.Column(db.JSON, nullable=False)) # type: ignore
|
||||
timestamp: float = db.Column(db.DECIMAL(17, 6), nullable=False)
|
||||
completed_by_user_id: int = db.Column(db.Integer, nullable=True)
|
||||
lane_assignment_id: Optional[int] = db.Column(
|
||||
|
|
|
@ -108,7 +108,7 @@ class Task:
|
|||
multi_instance_type: Union[MultiInstanceType, None] = None,
|
||||
multi_instance_count: str = "",
|
||||
multi_instance_index: str = "",
|
||||
process_name: str = "",
|
||||
process_identifier: str = "",
|
||||
properties: Union[dict, None] = None,
|
||||
process_instance_id: Union[int, None] = None,
|
||||
process_instance_status: Union[str, None] = None,
|
||||
|
@ -118,6 +118,7 @@ class Task:
|
|||
form_schema: Union[str, None] = None,
|
||||
form_ui_schema: Union[str, None] = None,
|
||||
parent: Optional[str] = None,
|
||||
call_activity_process_identifier: Optional[str] = None,
|
||||
):
|
||||
"""__init__."""
|
||||
self.id = id
|
||||
|
@ -129,6 +130,7 @@ class Task:
|
|||
self.documentation = documentation
|
||||
self.lane = lane
|
||||
self.parent = parent
|
||||
self.call_activity_process_identifier = call_activity_process_identifier
|
||||
|
||||
self.data = data
|
||||
if self.data is None:
|
||||
|
@ -151,7 +153,7 @@ class Task:
|
|||
self.multi_instance_index = (
|
||||
multi_instance_index # And the index of the currently repeating task.
|
||||
)
|
||||
self.process_name = process_name
|
||||
self.process_identifier = process_identifier
|
||||
|
||||
self.properties = properties # Arbitrary extension properties from BPMN editor.
|
||||
if self.properties is None:
|
||||
|
@ -177,7 +179,7 @@ class Task:
|
|||
"multi_instance_type": multi_instance_type,
|
||||
"multi_instance_count": self.multi_instance_count,
|
||||
"multi_instance_index": self.multi_instance_index,
|
||||
"process_name": self.process_name,
|
||||
"process_identifier": self.process_identifier,
|
||||
"properties": self.properties,
|
||||
"process_instance_id": self.process_instance_id,
|
||||
"process_instance_status": self.process_instance_status,
|
||||
|
@ -187,6 +189,7 @@ class Task:
|
|||
"form_schema": self.form_schema,
|
||||
"form_ui_schema": self.form_ui_schema,
|
||||
"parent": self.parent,
|
||||
"call_activity_process_identifier": self.call_activity_process_identifier,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
@ -282,7 +285,7 @@ class TaskSchema(Schema):
|
|||
"multi_instance_type",
|
||||
"multi_instance_count",
|
||||
"multi_instance_index",
|
||||
"process_name",
|
||||
"process_identifier",
|
||||
"properties",
|
||||
"process_instance_id",
|
||||
"form_schema",
|
||||
|
@ -293,7 +296,7 @@ class TaskSchema(Schema):
|
|||
documentation = marshmallow.fields.String(required=False, allow_none=True)
|
||||
# form = marshmallow.fields.Nested(FormSchema, required=False, allow_none=True)
|
||||
title = marshmallow.fields.String(required=False, allow_none=True)
|
||||
process_name = marshmallow.fields.String(required=False, allow_none=True)
|
||||
process_identifier = marshmallow.fields.String(required=False, allow_none=True)
|
||||
lane = marshmallow.fields.String(required=False, allow_none=True)
|
||||
|
||||
@marshmallow.post_load
|
||||
|
|
|
@ -66,6 +66,7 @@ from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema
|
|||
from spiffworkflow_backend.models.secret_model import SecretModel
|
||||
from spiffworkflow_backend.models.secret_model import SecretModelSchema
|
||||
from spiffworkflow_backend.models.spec_reference import SpecReferenceCache
|
||||
from spiffworkflow_backend.models.spec_reference import SpecReferenceNotFoundError
|
||||
from spiffworkflow_backend.models.spec_reference import SpecReferenceSchema
|
||||
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
|
||||
from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel
|
||||
|
@ -1024,11 +1025,11 @@ def process_instance_list(
|
|||
elif attribute in instance_metadata_aliases:
|
||||
if order_by_option.startswith("-"):
|
||||
order_by_query_array.append(
|
||||
instance_metadata_aliases[attribute].value.desc()
|
||||
func.max(instance_metadata_aliases[attribute].value).desc()
|
||||
)
|
||||
else:
|
||||
order_by_query_array.append(
|
||||
instance_metadata_aliases[attribute].value.asc()
|
||||
func.max(instance_metadata_aliases[attribute].value).asc()
|
||||
)
|
||||
|
||||
process_instances = (
|
||||
|
@ -1073,25 +1074,48 @@ def process_instance_report_column_list() -> flask.wrappers.Response:
|
|||
|
||||
|
||||
def process_instance_show(
|
||||
modified_process_model_identifier: str, process_instance_id: int
|
||||
modified_process_model_identifier: str,
|
||||
process_instance_id: int,
|
||||
process_identifier: Optional[str] = None,
|
||||
) -> flask.wrappers.Response:
|
||||
"""Create_process_instance."""
|
||||
process_model_identifier = modified_process_model_identifier.replace(":", "/")
|
||||
process_instance = find_process_instance_by_id_or_raise(process_instance_id)
|
||||
current_version_control_revision = GitService.get_current_revision()
|
||||
process_model = get_process_model(process_model_identifier)
|
||||
|
||||
if process_model.primary_file_name:
|
||||
process_model_with_diagram = None
|
||||
name_of_file_with_diagram = None
|
||||
if process_identifier:
|
||||
spec_reference = SpecReferenceCache.query.filter_by(
|
||||
identifier=process_identifier
|
||||
).first()
|
||||
if spec_reference is None:
|
||||
raise SpecReferenceNotFoundError(
|
||||
f"Could not find given process identifier in the cache: {process_identifier}"
|
||||
)
|
||||
|
||||
process_model_with_diagram = ProcessModelService.get_process_model(
|
||||
spec_reference.process_model_id
|
||||
)
|
||||
name_of_file_with_diagram = spec_reference.file_name
|
||||
else:
|
||||
process_model_with_diagram = get_process_model(process_model_identifier)
|
||||
if process_model_with_diagram.primary_file_name:
|
||||
name_of_file_with_diagram = process_model_with_diagram.primary_file_name
|
||||
|
||||
if process_model_with_diagram and name_of_file_with_diagram:
|
||||
if (
|
||||
process_instance.bpmn_version_control_identifier
|
||||
== current_version_control_revision
|
||||
):
|
||||
bpmn_xml_file_contents = SpecFileService.get_data(
|
||||
process_model, process_model.primary_file_name
|
||||
process_model_with_diagram, name_of_file_with_diagram
|
||||
).decode("utf-8")
|
||||
else:
|
||||
bpmn_xml_file_contents = GitService.get_instance_file_contents_for_revision(
|
||||
process_model, process_instance.bpmn_version_control_identifier
|
||||
process_model_with_diagram,
|
||||
process_instance.bpmn_version_control_identifier,
|
||||
file_name=name_of_file_with_diagram,
|
||||
)
|
||||
process_instance.bpmn_xml_file_contents = bpmn_xml_file_contents
|
||||
|
||||
|
@ -1409,7 +1433,8 @@ def process_instance_task_list(
|
|||
)
|
||||
if step_detail is not None and process_instance.bpmn_json is not None:
|
||||
bpmn_json = json.loads(process_instance.bpmn_json)
|
||||
bpmn_json["tasks"] = step_detail.task_json
|
||||
bpmn_json["tasks"] = step_detail.task_json["tasks"]
|
||||
bpmn_json["subprocesses"] = step_detail.task_json["subprocesses"]
|
||||
process_instance.bpmn_json = json.dumps(bpmn_json)
|
||||
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
|
@ -1588,7 +1613,7 @@ def task_submit(
|
|||
|
||||
|
||||
def script_unit_test_create(
|
||||
process_group_id: str, process_model_id: str, body: Dict[str, Union[str, bool, int]]
|
||||
modified_process_model_identifier: str, body: Dict[str, Union[str, bool, int]]
|
||||
) -> flask.wrappers.Response:
|
||||
"""Script_unit_test_create."""
|
||||
bpmn_task_identifier = _get_required_parameter_or_raise(
|
||||
|
@ -1599,7 +1624,7 @@ def script_unit_test_create(
|
|||
"expected_output_json", body
|
||||
)
|
||||
|
||||
process_model_identifier = f"{process_group_id}/{process_model_id}"
|
||||
process_model_identifier = modified_process_model_identifier.replace(":", "/")
|
||||
process_model = get_process_model(process_model_identifier)
|
||||
file = SpecFileService.get_files(process_model, process_model.primary_file_name)[0]
|
||||
if file is None:
|
||||
|
@ -1677,7 +1702,7 @@ def script_unit_test_create(
|
|||
|
||||
|
||||
def script_unit_test_run(
|
||||
process_group_id: str, process_model_id: str, body: Dict[str, Union[str, bool, int]]
|
||||
modified_process_model_identifier: str, body: Dict[str, Union[str, bool, int]]
|
||||
) -> flask.wrappers.Response:
|
||||
"""Script_unit_test_run."""
|
||||
# FIXME: We should probably clear this somewhere else but this works
|
||||
|
@ -1873,7 +1898,6 @@ def secret_list(
|
|||
def add_secret(body: Dict) -> Response:
|
||||
"""Add secret."""
|
||||
secret_model = SecretService().add_secret(body["key"], body["value"], g.user.id)
|
||||
assert secret_model # noqa: S101
|
||||
return Response(
|
||||
json.dumps(SecretModelSchema().dump(secret_model)),
|
||||
status=201,
|
||||
|
|
|
@ -16,8 +16,9 @@ from flask_bpmn.api.api_error import ApiError
|
|||
from werkzeug.wrappers import Response
|
||||
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
from spiffworkflow_backend.services.authentication_service import AuthenticationService
|
||||
from spiffworkflow_backend.services.authentication_service import (
|
||||
AuthenticationService,
|
||||
MissingAccessTokenError,
|
||||
)
|
||||
from spiffworkflow_backend.services.authorization_service import AuthorizationService
|
||||
from spiffworkflow_backend.services.user_service import UserService
|
||||
|
@ -268,10 +269,10 @@ def login_api_return(code: str, state: str, session_state: str) -> str:
|
|||
code, "/v1.0/login_api_return"
|
||||
)
|
||||
access_token: str = auth_token_object["access_token"]
|
||||
assert access_token # noqa: S101
|
||||
if access_token is None:
|
||||
raise MissingAccessTokenError("Cannot find the access token for the request")
|
||||
|
||||
return access_token
|
||||
# return redirect("localhost:7000/v1.0/ui")
|
||||
# return {'uid': 'user_1'}
|
||||
|
||||
|
||||
def logout(id_token: str, redirect_url: Optional[str]) -> Response:
|
||||
|
|
|
@ -16,6 +16,10 @@ from werkzeug.wrappers import Response
|
|||
from spiffworkflow_backend.models.refresh_token import RefreshTokenModel
|
||||
|
||||
|
||||
class MissingAccessTokenError(Exception):
|
||||
"""MissingAccessTokenError."""
|
||||
|
||||
|
||||
class AuthenticationProviderTypes(enum.Enum):
|
||||
"""AuthenticationServiceProviders."""
|
||||
|
||||
|
|
|
@ -46,18 +46,24 @@ class GitService:
|
|||
|
||||
@classmethod
|
||||
def get_instance_file_contents_for_revision(
|
||||
cls, process_model: ProcessModelInfo, revision: str
|
||||
cls,
|
||||
process_model: ProcessModelInfo,
|
||||
revision: str,
|
||||
file_name: Optional[str] = None,
|
||||
) -> str:
|
||||
"""Get_instance_file_contents_for_revision."""
|
||||
bpmn_spec_absolute_dir = current_app.config["BPMN_SPEC_ABSOLUTE_DIR"]
|
||||
process_model_relative_path = FileSystemService.process_model_relative_path(
|
||||
process_model
|
||||
)
|
||||
file_name_to_use = file_name
|
||||
if file_name_to_use is None:
|
||||
file_name_to_use = process_model.primary_file_name
|
||||
with FileSystemService.cd(bpmn_spec_absolute_dir):
|
||||
shell_command = [
|
||||
"git",
|
||||
"show",
|
||||
f"{revision}:{process_model_relative_path}/{process_model.primary_file_name}",
|
||||
f"{revision}:{process_model_relative_path}/{file_name_to_use}",
|
||||
]
|
||||
return cls.run_shell_command_to_get_stdout(shell_command)
|
||||
|
||||
|
|
|
@ -551,7 +551,7 @@ class ProcessInstanceProcessor:
|
|||
"""SaveSpiffStepDetails."""
|
||||
bpmn_json = self.serialize()
|
||||
wf_json = json.loads(bpmn_json)
|
||||
task_json = wf_json["tasks"]
|
||||
task_json = {"tasks": wf_json["tasks"], "subprocesses": wf_json["subprocesses"]}
|
||||
|
||||
return {
|
||||
"process_instance_id": self.process_instance_model.id,
|
||||
|
|
|
@ -302,6 +302,11 @@ class ProcessInstanceService:
|
|||
else:
|
||||
lane = None
|
||||
|
||||
if hasattr(spiff_task.task_spec, "spec"):
|
||||
call_activity_process_identifier = spiff_task.task_spec.spec
|
||||
else:
|
||||
call_activity_process_identifier = None
|
||||
|
||||
parent_id = None
|
||||
if spiff_task.parent:
|
||||
parent_id = spiff_task.parent.id
|
||||
|
@ -316,9 +321,10 @@ class ProcessInstanceService:
|
|||
multi_instance_type=mi_type,
|
||||
multi_instance_count=info["mi_count"],
|
||||
multi_instance_index=info["mi_index"],
|
||||
process_name=spiff_task.task_spec._wf_spec.description,
|
||||
process_identifier=spiff_task.task_spec._wf_spec.name,
|
||||
properties=props,
|
||||
parent=parent_id,
|
||||
call_activity_process_identifier=call_activity_process_identifier,
|
||||
)
|
||||
|
||||
return task
|
||||
|
|
|
@ -223,7 +223,7 @@ class ProcessModelService(FileSystemService):
|
|||
user = UserService.current_user()
|
||||
new_process_model_list = []
|
||||
for process_model in process_models:
|
||||
uri = f"/v1.0/process-models/{process_model.id.replace('/', ':')}/process-instances"
|
||||
uri = f"/v1.0/process-instances/{process_model.id.replace('/', ':')}"
|
||||
result = AuthorizationService.user_has_permission(
|
||||
user=user, permission="create", target_uri=uri
|
||||
)
|
||||
|
|
|
@ -31,7 +31,6 @@ class ServiceTaskDelegate:
|
|||
if value.startswith(secret_prefix):
|
||||
key = value.removeprefix(secret_prefix)
|
||||
secret = SecretService().get_secret(key)
|
||||
assert secret # noqa: S101
|
||||
return secret.value
|
||||
|
||||
file_prefix = "file:"
|
||||
|
|
|
@ -171,13 +171,18 @@ class SpecFileService(FileSystemService):
|
|||
ref.is_primary = True
|
||||
|
||||
if ref.is_primary:
|
||||
ProcessModelService.update_process_model(
|
||||
process_model_info,
|
||||
{
|
||||
"primary_process_id": ref.identifier,
|
||||
"primary_file_name": file_name,
|
||||
},
|
||||
)
|
||||
update_hash = {}
|
||||
if not process_model_info.primary_file_name:
|
||||
update_hash["primary_process_id"] = ref.identifier
|
||||
update_hash["primary_file_name"] = file_name
|
||||
elif file_name == process_model_info.primary_file_name:
|
||||
update_hash["primary_process_id"] = ref.identifier
|
||||
|
||||
if len(update_hash) > 0:
|
||||
ProcessModelService.update_process_model(
|
||||
process_model_info,
|
||||
update_hash,
|
||||
)
|
||||
SpecFileService.update_caches(ref)
|
||||
return file
|
||||
|
||||
|
|
|
@ -1167,6 +1167,60 @@ class TestProcessApi(BaseTest):
|
|||
xml_file_contents = f_open.read()
|
||||
assert show_response.json["bpmn_xml_file_contents"] == xml_file_contents
|
||||
|
||||
def test_process_instance_show_with_specified_process_identifier(
|
||||
self,
|
||||
app: Flask,
|
||||
client: FlaskClient,
|
||||
with_db_and_bpmn_file_cleanup: None,
|
||||
with_super_admin_user: UserModel,
|
||||
) -> None:
|
||||
"""Test_process_instance_show_with_specified_process_identifier."""
|
||||
process_model_id = "call_activity_nested"
|
||||
process_model_identifier = self.create_group_and_model_with_bpmn(
|
||||
client=client,
|
||||
user=with_super_admin_user,
|
||||
process_group_id="test_group_two",
|
||||
process_model_id=process_model_id,
|
||||
bpmn_file_location="call_activity_nested",
|
||||
)
|
||||
spec_reference = SpecReferenceCache.query.filter_by(
|
||||
identifier="Level2b"
|
||||
).first()
|
||||
assert spec_reference
|
||||
modified_process_model_identifier = (
|
||||
self.modify_process_identifier_for_path_param(process_model_identifier)
|
||||
)
|
||||
headers = self.logged_in_headers(with_super_admin_user)
|
||||
create_response = self.create_process_instance_from_process_model_id(
|
||||
client, process_model_identifier, headers
|
||||
)
|
||||
assert create_response.json is not None
|
||||
assert create_response.status_code == 201
|
||||
process_instance_id = create_response.json["id"]
|
||||
client.post(
|
||||
f"/v1.0/process-instances/{modified_process_model_identifier}/{process_instance_id}/run",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
show_response = client.get(
|
||||
f"/v1.0/process-instances/{modified_process_model_identifier}/{process_instance_id}?process_identifier={spec_reference.identifier}",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
)
|
||||
assert show_response.json is not None
|
||||
assert show_response.status_code == 200
|
||||
file_system_root = FileSystemService.root_path()
|
||||
process_instance_file_path = (
|
||||
f"{file_system_root}/{process_model_identifier}/{process_model_id}.bpmn"
|
||||
)
|
||||
with open(process_instance_file_path) as f_open:
|
||||
xml_file_contents = f_open.read()
|
||||
assert show_response.json["bpmn_xml_file_contents"] != xml_file_contents
|
||||
spec_reference_file_path = os.path.join(
|
||||
file_system_root, spec_reference.relative_path
|
||||
)
|
||||
with open(spec_reference_file_path) as f_open:
|
||||
xml_file_contents = f_open.read()
|
||||
assert show_response.json["bpmn_xml_file_contents"] == xml_file_contents
|
||||
|
||||
def test_message_start_when_starting_process_instance(
|
||||
self,
|
||||
app: Flask,
|
||||
|
|
|
@ -7,6 +7,7 @@ from spiffworkflow_backend.services.git_service import GitService
|
|||
|
||||
|
||||
class TestGitService(BaseTest):
|
||||
"""TestGitService."""
|
||||
|
||||
def test_strips_output_of_stdout_from_command(
|
||||
self,
|
||||
|
@ -14,5 +15,8 @@ class TestGitService(BaseTest):
|
|||
client: FlaskClient,
|
||||
with_db_and_bpmn_file_cleanup: None,
|
||||
) -> None:
|
||||
output = GitService.run_shell_command_to_get_stdout(["echo", ' This output should not end in space or newline \n'])
|
||||
assert output == 'This output should not end in space or newline'
|
||||
"""Test_strips_output_of_stdout_from_command."""
|
||||
output = GitService.run_shell_command_to_get_stdout(
|
||||
["echo", " This output should not end in space or newline \n"]
|
||||
)
|
||||
assert output == "This output should not end in space or newline"
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
# testing
|
||||
/coverage
|
||||
|
||||
# in case we accidentally run backend tests in frontend. :D
|
||||
/.coverage.*
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { modifyProcessIdentifierForPathParam } from '../../src/helpers';
|
||||
import { miscDisplayName } from '../support/helpers';
|
||||
|
||||
describe('process-models', () => {
|
||||
beforeEach(() => {
|
||||
|
@ -16,7 +17,7 @@ describe('process-models', () => {
|
|||
const modelDisplayName = `Test Model 2 ${id}`;
|
||||
const modelId = `test-model-2-${id}`;
|
||||
const newModelDisplayName = `${modelDisplayName} edited`;
|
||||
cy.contains('99-Shared Resources').click();
|
||||
cy.contains(miscDisplayName).click();
|
||||
cy.wait(500);
|
||||
cy.contains(groupDisplayName).click();
|
||||
cy.createModel(groupId, modelId, modelDisplayName);
|
||||
|
@ -34,7 +35,7 @@ describe('process-models', () => {
|
|||
cy.contains(`Process Model: ${newModelDisplayName}`);
|
||||
|
||||
// go back to process model show by clicking on the breadcrumb
|
||||
cy.contains(modelId).click();
|
||||
cy.contains(modelDisplayName).click();
|
||||
|
||||
cy.getBySel('delete-process-model-button').click();
|
||||
cy.contains('Are you sure');
|
||||
|
@ -46,6 +47,7 @@ describe('process-models', () => {
|
|||
`process-groups/${modifyProcessIdentifierForPathParam(groupId)}`
|
||||
);
|
||||
cy.contains(modelId).should('not.exist');
|
||||
cy.contains(modelDisplayName).should('not.exist');
|
||||
});
|
||||
|
||||
it('can create new bpmn, dmn, and json files', () => {
|
||||
|
@ -61,11 +63,11 @@ describe('process-models', () => {
|
|||
const dmnFileName = `dmn_test_file_${id}`;
|
||||
const jsonFileName = `json_test_file_${id}`;
|
||||
|
||||
cy.contains('99-Shared Resources').click();
|
||||
cy.contains(miscDisplayName).click();
|
||||
cy.wait(500);
|
||||
cy.contains(groupDisplayName).click();
|
||||
cy.createModel(groupId, modelId, modelDisplayName);
|
||||
cy.contains(directParentGroupId).click();
|
||||
cy.contains(groupDisplayName).click();
|
||||
cy.contains(modelDisplayName).click();
|
||||
cy.url().should(
|
||||
'include',
|
||||
|
@ -90,7 +92,7 @@ describe('process-models', () => {
|
|||
cy.get('input[name=file_name]').type(bpmnFileName);
|
||||
cy.contains('Save Changes').click();
|
||||
cy.contains(`Process Model File: ${bpmnFileName}`);
|
||||
cy.contains(modelId).click();
|
||||
cy.contains(modelDisplayName).click();
|
||||
cy.contains(`Process Model: ${modelDisplayName}`);
|
||||
// cy.getBySel('files-accordion').click();
|
||||
cy.contains(`${bpmnFileName}.bpmn`).should('exist');
|
||||
|
@ -108,7 +110,7 @@ describe('process-models', () => {
|
|||
cy.get('input[name=file_name]').type(dmnFileName);
|
||||
cy.contains('Save Changes').click();
|
||||
cy.contains(`Process Model File: ${dmnFileName}`);
|
||||
cy.contains(modelId).click();
|
||||
cy.contains(modelDisplayName).click();
|
||||
cy.contains(`Process Model: ${modelDisplayName}`);
|
||||
// cy.getBySel('files-accordion').click();
|
||||
cy.contains(`${dmnFileName}.dmn`).should('exist');
|
||||
|
@ -124,7 +126,7 @@ describe('process-models', () => {
|
|||
cy.contains(`Process Model File: ${jsonFileName}`);
|
||||
// wait for json to load before clicking away to avoid network errors
|
||||
cy.wait(500);
|
||||
cy.contains(modelId).click();
|
||||
cy.contains(modelDisplayName).click();
|
||||
cy.contains(`Process Model: ${modelDisplayName}`);
|
||||
// cy.getBySel('files-accordion').click();
|
||||
cy.contains(`${jsonFileName}.json`).should('exist');
|
||||
|
@ -151,12 +153,12 @@ describe('process-models', () => {
|
|||
const modelDisplayName = `Test Model 2 ${id}`;
|
||||
const modelId = `test-model-2-${id}`;
|
||||
cy.contains('Add a process group');
|
||||
cy.contains('99-Shared Resources').click();
|
||||
cy.contains(miscDisplayName).click();
|
||||
cy.wait(500);
|
||||
cy.contains(groupDisplayName).click();
|
||||
cy.createModel(groupId, modelId, modelDisplayName);
|
||||
|
||||
cy.contains(`${directParentGroupId}`).click();
|
||||
cy.contains(`${groupDisplayName}`).click();
|
||||
cy.contains('Add a process model');
|
||||
cy.contains(modelDisplayName).click();
|
||||
cy.url().should(
|
||||
|
@ -186,7 +188,7 @@ describe('process-models', () => {
|
|||
.click();
|
||||
|
||||
// in breadcrumb
|
||||
cy.contains(modelId).click();
|
||||
cy.contains(modelDisplayName).click();
|
||||
|
||||
cy.getBySel('delete-process-model-button').click();
|
||||
cy.contains('Are you sure');
|
||||
|
@ -203,7 +205,7 @@ describe('process-models', () => {
|
|||
|
||||
// process models no longer has pagination post-tiles
|
||||
// it.only('can paginate items', () => {
|
||||
// cy.contains('99-Shared Resources').click();
|
||||
// cy.contains(miscDisplayName).click();
|
||||
// cy.wait(500);
|
||||
// cy.contains('Acceptance Tests Group One').click();
|
||||
// cy.basicPaginationTest();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { string } from 'prop-types';
|
||||
import { modifyProcessIdentifierForPathParam } from '../../src/helpers';
|
||||
import { miscDisplayName } from './helpers';
|
||||
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
|
@ -86,15 +87,15 @@ Cypress.Commands.add('createModel', (groupId, modelId, modelDisplayName) => {
|
|||
Cypress.Commands.add(
|
||||
'runPrimaryBpmnFile',
|
||||
(expectAutoRedirectToHumanTask = false) => {
|
||||
cy.contains('Run').click();
|
||||
cy.contains('Start').click();
|
||||
if (expectAutoRedirectToHumanTask) {
|
||||
// the url changes immediately, so also make sure we get some content from the next page, "Task:", or else when we try to interact with the page, it'll re-render and we'll get an error with cypress.
|
||||
cy.url().should('include', `/tasks/`);
|
||||
cy.contains('Task: ');
|
||||
} else {
|
||||
cy.contains(/Process Instance.*kicked off/);
|
||||
cy.contains(/Process Instance.*[kK]icked [oO]ff/);
|
||||
cy.reload(true);
|
||||
cy.contains(/Process Instance.*kicked off/).should('not.exist');
|
||||
cy.contains(/Process Instance.*[kK]icked [oO]ff/).should('not.exist');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -103,8 +104,8 @@ Cypress.Commands.add(
|
|||
'navigateToProcessModel',
|
||||
(groupDisplayName, modelDisplayName, modelIdentifier) => {
|
||||
cy.navigateToAdmin();
|
||||
cy.contains('99-Shared Resources').click();
|
||||
cy.contains(`Process Group: 99-Shared Resources`, { timeout: 10000 });
|
||||
cy.contains(miscDisplayName).click();
|
||||
cy.contains(`Process Group: ${miscDisplayName}`, { timeout: 10000 });
|
||||
cy.contains(groupDisplayName).click();
|
||||
cy.contains(`Process Group: ${groupDisplayName}`);
|
||||
// https://stackoverflow.com/q/51254946/6090676
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export const miscDisplayName = 'Shared Resources';
|
|
@ -68,7 +68,7 @@
|
|||
"@cypress/grep": "^3.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
||||
"@typescript-eslint/parser": "^5.30.6",
|
||||
"cypress": "^10.8.0",
|
||||
"cypress": "^12",
|
||||
"eslint": "^8.19.0",
|
||||
"eslint_d": "^12.2.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
|
@ -9850,9 +9850,9 @@
|
|||
"integrity": "sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A=="
|
||||
},
|
||||
"node_modules/cypress": {
|
||||
"version": "10.11.0",
|
||||
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.11.0.tgz",
|
||||
"integrity": "sha512-lsaE7dprw5DoXM00skni6W5ElVVLGAdRUUdZjX2dYsGjbY/QnpzWZ95Zom1mkGg0hAaO/QVTZoFVS7Jgr/GUPA==",
|
||||
"version": "12.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cypress/-/cypress-12.1.0.tgz",
|
||||
"integrity": "sha512-7fz8N84uhN1+ePNDsfQvoWEl4P3/VGKKmAg+bJQFY4onhA37Ys+6oBkGbNdwGeC7n2QqibNVPhk8x3YuQLwzfw==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
|
@ -9903,7 +9903,7 @@
|
|||
"cypress": "bin/cypress"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": "^14.0.0 || ^16.0.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/cypress/node_modules/@types/node": {
|
||||
|
@ -38586,9 +38586,9 @@
|
|||
"integrity": "sha512-NJGVKPS81XejHcLhaLJS7plab0fK3slPh11mESeeDq2W4ZI5kUKK/LRRdVDvjJseojbPB7ZwjnyOybg3Igea/A=="
|
||||
},
|
||||
"cypress": {
|
||||
"version": "10.11.0",
|
||||
"resolved": "https://registry.npmjs.org/cypress/-/cypress-10.11.0.tgz",
|
||||
"integrity": "sha512-lsaE7dprw5DoXM00skni6W5ElVVLGAdRUUdZjX2dYsGjbY/QnpzWZ95Zom1mkGg0hAaO/QVTZoFVS7Jgr/GUPA==",
|
||||
"version": "12.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cypress/-/cypress-12.1.0.tgz",
|
||||
"integrity": "sha512-7fz8N84uhN1+ePNDsfQvoWEl4P3/VGKKmAg+bJQFY4onhA37Ys+6oBkGbNdwGeC7n2QqibNVPhk8x3YuQLwzfw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cypress/request": "^2.88.10",
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
"@cypress/grep": "^3.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
||||
"@typescript-eslint/parser": "^5.30.6",
|
||||
"cypress": "^10.8.0",
|
||||
"cypress": "^12",
|
||||
"eslint": "^8.19.0",
|
||||
"eslint_d": "^12.2.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
|
|
|
@ -13,6 +13,7 @@ import AdminRoutes from './routes/AdminRoutes';
|
|||
import { ErrorForDisplay } from './interfaces';
|
||||
|
||||
import { AbilityContext } from './contexts/Can';
|
||||
import UserService from './services/UserService';
|
||||
|
||||
export default function App() {
|
||||
const [errorMessage, setErrorMessage] = useState<ErrorForDisplay | null>(
|
||||
|
@ -24,6 +25,11 @@ export default function App() {
|
|||
[errorMessage]
|
||||
);
|
||||
|
||||
if (!UserService.isLoggedIn()) {
|
||||
UserService.doLogin();
|
||||
return null;
|
||||
}
|
||||
|
||||
const ability = defineAbility(() => {});
|
||||
|
||||
let errorTag = null;
|
||||
|
|
|
@ -24,6 +24,7 @@ import UserService from '../services/UserService';
|
|||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||
import { PermissionsToCheck } from '../interfaces';
|
||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||
import { UnauthenticatedError } from '../services/HttpService';
|
||||
|
||||
// for ref: https://react-bootstrap.github.io/components/navbar/
|
||||
export default function NavigationBar() {
|
||||
|
@ -39,6 +40,11 @@ export default function NavigationBar() {
|
|||
const [activeKey, setActiveKey] = useState<string>('');
|
||||
|
||||
const { targetUris } = useUriListForPermissions();
|
||||
|
||||
// App.jsx forces login (which redirects to keycloak) so we should never get here if we're not logged in.
|
||||
if (!UserService.isLoggedIn()) {
|
||||
throw new UnauthenticatedError('You must be authenticated to do this.');
|
||||
}
|
||||
const permissionRequestData: PermissionsToCheck = {
|
||||
[targetUris.authenticationListPath]: ['GET'],
|
||||
[targetUris.messageInstanceListPath]: ['GET'],
|
||||
|
@ -135,6 +141,9 @@ export default function NavigationBar() {
|
|||
};
|
||||
|
||||
const headerMenuItems = () => {
|
||||
if (!UserService.isLoggedIn()) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<HeaderMenuItem href="/" isCurrentPage={isActivePage('/')}>
|
||||
|
|
|
@ -300,8 +300,13 @@ export default function ProcessInstanceListTable({
|
|||
|
||||
checkFiltersAndRun();
|
||||
if (autoReload) {
|
||||
refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, checkFiltersAndRun);
|
||||
return refreshAtInterval(
|
||||
REFRESH_INTERVAL,
|
||||
REFRESH_TIMEOUT,
|
||||
checkFiltersAndRun
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}, [
|
||||
autoReload,
|
||||
searchParams,
|
||||
|
|
|
@ -58,14 +58,14 @@ import HttpService from '../services/HttpService';
|
|||
import ButtonWithConfirmation from './ButtonWithConfirmation';
|
||||
import { makeid } from '../helpers';
|
||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||
import { PermissionsToCheck } from '../interfaces';
|
||||
import { PermissionsToCheck, ProcessInstanceTask } from '../interfaces';
|
||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||
|
||||
type OwnProps = {
|
||||
processModelId: string;
|
||||
diagramType: string;
|
||||
readyOrWaitingBpmnTaskIds?: string[] | null;
|
||||
completedTasksBpmnIds?: string[] | null;
|
||||
readyOrWaitingProcessInstanceTasks?: ProcessInstanceTask[] | null;
|
||||
completedProcessInstanceTasks?: ProcessInstanceTask[] | null;
|
||||
saveDiagram?: (..._args: any[]) => any;
|
||||
onDeleteFile?: (..._args: any[]) => any;
|
||||
onSetPrimaryFile?: (..._args: any[]) => any;
|
||||
|
@ -88,8 +88,8 @@ type OwnProps = {
|
|||
export default function ReactDiagramEditor({
|
||||
processModelId,
|
||||
diagramType,
|
||||
readyOrWaitingBpmnTaskIds,
|
||||
completedTasksBpmnIds,
|
||||
readyOrWaitingProcessInstanceTasks,
|
||||
completedProcessInstanceTasks,
|
||||
saveDiagram,
|
||||
onDeleteFile,
|
||||
onSetPrimaryFile,
|
||||
|
@ -227,7 +227,9 @@ export default function ReactDiagramEditor({
|
|||
|
||||
function handleElementClick(event: any) {
|
||||
if (onElementClick) {
|
||||
onElementClick(event.element);
|
||||
const canvas = diagramModeler.get('canvas');
|
||||
const rootElement = canvas.getRootElement();
|
||||
onElementClick(event.element, rootElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,12 +352,15 @@ export default function ReactDiagramEditor({
|
|||
|
||||
function highlightBpmnIoElement(
|
||||
canvas: any,
|
||||
taskBpmnId: string,
|
||||
bpmnIoClassName: string
|
||||
processInstanceTask: ProcessInstanceTask,
|
||||
bpmnIoClassName: string,
|
||||
bpmnRootElementId: string
|
||||
) {
|
||||
if (checkTaskCanBeHighlighted(taskBpmnId)) {
|
||||
if (checkTaskCanBeHighlighted(processInstanceTask.name)) {
|
||||
try {
|
||||
canvas.addMarker(taskBpmnId, bpmnIoClassName);
|
||||
if (bpmnRootElementId === processInstanceTask.process_identifier) {
|
||||
canvas.addMarker(processInstanceTask.name, bpmnIoClassName);
|
||||
}
|
||||
} catch (bpmnIoError: any) {
|
||||
// the task list also contains task for processes called from call activities which will
|
||||
// not exist in this diagram so just ignore them for now.
|
||||
|
@ -394,21 +399,25 @@ export default function ReactDiagramEditor({
|
|||
// highlighting a field
|
||||
// Option 3 at:
|
||||
// https://github.com/bpmn-io/bpmn-js-examples/tree/master/colors
|
||||
if (readyOrWaitingBpmnTaskIds) {
|
||||
readyOrWaitingBpmnTaskIds.forEach((readyOrWaitingBpmnTaskId) => {
|
||||
if (readyOrWaitingProcessInstanceTasks) {
|
||||
const rootElement = canvas.getRootElement();
|
||||
readyOrWaitingProcessInstanceTasks.forEach((readyOrWaitingBpmnTask) => {
|
||||
highlightBpmnIoElement(
|
||||
canvas,
|
||||
readyOrWaitingBpmnTaskId,
|
||||
'active-task-highlight'
|
||||
readyOrWaitingBpmnTask,
|
||||
'active-task-highlight',
|
||||
rootElement.id
|
||||
);
|
||||
});
|
||||
}
|
||||
if (completedTasksBpmnIds) {
|
||||
completedTasksBpmnIds.forEach((completedTaskBpmnId) => {
|
||||
if (completedProcessInstanceTasks) {
|
||||
const rootElement = canvas.getRootElement();
|
||||
completedProcessInstanceTasks.forEach((completedTask) => {
|
||||
highlightBpmnIoElement(
|
||||
canvas,
|
||||
completedTaskBpmnId,
|
||||
'completed-task-highlight'
|
||||
completedTask,
|
||||
'completed-task-highlight',
|
||||
rootElement.id
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -484,8 +493,8 @@ export default function ReactDiagramEditor({
|
|||
diagramType,
|
||||
diagramXML,
|
||||
diagramXMLString,
|
||||
readyOrWaitingBpmnTaskIds,
|
||||
completedTasksBpmnIds,
|
||||
readyOrWaitingProcessInstanceTasks,
|
||||
completedProcessInstanceTasks,
|
||||
fileName,
|
||||
performingXmlUpdates,
|
||||
processModelId,
|
||||
|
|
|
@ -41,7 +41,7 @@ export default function MyOpenProcesses() {
|
|||
});
|
||||
};
|
||||
getTasks();
|
||||
refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
|
||||
return refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
|
||||
}, [searchParams]);
|
||||
|
||||
const buildTable = () => {
|
||||
|
|
|
@ -41,7 +41,7 @@ export default function TasksWaitingForMyGroups() {
|
|||
});
|
||||
};
|
||||
getTasks();
|
||||
refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
|
||||
return refreshAtInterval(REFRESH_INTERVAL, REFRESH_TIMEOUT, getTasks);
|
||||
}, [searchParams]);
|
||||
|
||||
const buildTable = () => {
|
||||
|
|
|
@ -208,5 +208,8 @@ export const refreshAtInterval = (
|
|||
() => clearInterval(intervalRef),
|
||||
timeout * 1000
|
||||
);
|
||||
return [intervalRef, timeoutRef];
|
||||
return () => {
|
||||
clearInterval(intervalRef);
|
||||
clearTimeout(timeoutRef);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -11,6 +11,13 @@ export interface RecentProcessModel {
|
|||
processModelDisplayName: string;
|
||||
}
|
||||
|
||||
export interface ProcessInstanceTask {
|
||||
id: string;
|
||||
state: string;
|
||||
process_identifier: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ProcessReference {
|
||||
name: string; // The process or decision Display name.
|
||||
identifier: string; // The unique id of the process
|
||||
|
@ -39,6 +46,7 @@ export interface ProcessInstance {
|
|||
id: number;
|
||||
process_model_identifier: string;
|
||||
process_model_display_name: string;
|
||||
spiff_step?: number;
|
||||
}
|
||||
|
||||
export interface MessageCorrelationProperties {
|
||||
|
|
|
@ -21,10 +21,11 @@ export default function ProcessInstanceList() {
|
|||
<ProcessBreadcrumb
|
||||
hotCrumbs={[
|
||||
['Process Groups', '/admin'],
|
||||
[
|
||||
`Process Model: ${processModelFullIdentifier}`,
|
||||
`process_model:${processModelFullIdentifier}:link`,
|
||||
],
|
||||
{
|
||||
entityToExplode: processModelFullIdentifier,
|
||||
entityType: 'process-model-id',
|
||||
linkLastItem: true,
|
||||
},
|
||||
['Process Instances'],
|
||||
]}
|
||||
/>
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import { useContext, useEffect, useState } from 'react';
|
||||
import Editor from '@monaco-editor/react';
|
||||
import { useParams, useNavigate, Link } from 'react-router-dom';
|
||||
import {
|
||||
useParams,
|
||||
useNavigate,
|
||||
Link,
|
||||
useSearchParams,
|
||||
} from 'react-router-dom';
|
||||
import {
|
||||
TrashCan,
|
||||
StopOutline,
|
||||
|
@ -34,15 +39,21 @@ import {
|
|||
import ButtonWithConfirmation from '../components/ButtonWithConfirmation';
|
||||
import ErrorContext from '../contexts/ErrorContext';
|
||||
import { useUriListForPermissions } from '../hooks/UriListForPermissions';
|
||||
import { PermissionsToCheck } from '../interfaces';
|
||||
import {
|
||||
PermissionsToCheck,
|
||||
ProcessInstance,
|
||||
ProcessInstanceTask,
|
||||
} from '../interfaces';
|
||||
import { usePermissionFetcher } from '../hooks/PermissionService';
|
||||
|
||||
export default function ProcessInstanceShow() {
|
||||
const navigate = useNavigate();
|
||||
const params = useParams();
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const [processInstance, setProcessInstance] = useState(null);
|
||||
const [tasks, setTasks] = useState<Array<object> | null>(null);
|
||||
const [processInstance, setProcessInstance] =
|
||||
useState<ProcessInstance | null>(null);
|
||||
const [tasks, setTasks] = useState<ProcessInstanceTask[] | null>(null);
|
||||
const [tasksCallHadError, setTasksCallHadError] = useState<boolean>(false);
|
||||
const [taskToDisplay, setTaskToDisplay] = useState<object | null>(null);
|
||||
const [taskDataToDisplay, setTaskDataToDisplay] = useState<string>('');
|
||||
|
@ -80,8 +91,13 @@ export default function ProcessInstanceShow() {
|
|||
const processTaskFailure = () => {
|
||||
setTasksCallHadError(true);
|
||||
};
|
||||
let queryParams = '';
|
||||
const processIdentifier = searchParams.get('process_identifier');
|
||||
if (processIdentifier) {
|
||||
queryParams = `?process_identifier=${processIdentifier}`;
|
||||
}
|
||||
HttpService.makeCallToBackend({
|
||||
path: `/process-instances/${modifiedProcessModelId}/${params.process_instance_id}`,
|
||||
path: `/process-instances/${modifiedProcessModelId}/${params.process_instance_id}${queryParams}`,
|
||||
successCallback: setProcessInstance,
|
||||
});
|
||||
let taskParams = '?all_tasks=true';
|
||||
|
@ -98,7 +114,14 @@ export default function ProcessInstanceShow() {
|
|||
setTasksCallHadError(true);
|
||||
}
|
||||
}
|
||||
}, [params, modifiedProcessModelId, permissionsLoaded, ability, targetUris]);
|
||||
}, [
|
||||
params,
|
||||
modifiedProcessModelId,
|
||||
permissionsLoaded,
|
||||
ability,
|
||||
targetUris,
|
||||
searchParams,
|
||||
]);
|
||||
|
||||
const deleteProcessInstance = () => {
|
||||
HttpService.makeCallToBackend({
|
||||
|
@ -140,12 +163,12 @@ export default function ProcessInstanceShow() {
|
|||
const getTaskIds = () => {
|
||||
const taskIds = { completed: [], readyOrWaiting: [] };
|
||||
if (tasks) {
|
||||
tasks.forEach(function getUserTasksElement(task: any) {
|
||||
tasks.forEach(function getUserTasksElement(task: ProcessInstanceTask) {
|
||||
if (task.state === 'COMPLETED') {
|
||||
(taskIds.completed as any).push(task.name);
|
||||
(taskIds.completed as any).push(task);
|
||||
}
|
||||
if (task.state === 'READY' || task.state === 'WAITING') {
|
||||
(taskIds.readyOrWaiting as any).push(task.name);
|
||||
(taskIds.readyOrWaiting as any).push(task);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -175,15 +198,18 @@ export default function ProcessInstanceShow() {
|
|||
label: any,
|
||||
distance: number
|
||||
) => {
|
||||
const processIdentifier = searchParams.get('process_identifier');
|
||||
let queryParams = '';
|
||||
if (processIdentifier) {
|
||||
queryParams = `?process_identifier=${processIdentifier}`;
|
||||
}
|
||||
return (
|
||||
<Link
|
||||
reloadDocument
|
||||
data-qa="process-instance-step-link"
|
||||
to={`/admin/process-instances/${
|
||||
params.process_model_id
|
||||
}/process-instances/${params.process_instance_id}/${
|
||||
currentSpiffStep(processInstanceToUse) + distance
|
||||
}`}
|
||||
to={`/admin/process-instances/${params.process_model_id}/${
|
||||
params.process_instance_id
|
||||
}/${currentSpiffStep(processInstanceToUse) + distance}${queryParams}`}
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
|
@ -364,10 +390,15 @@ export default function ProcessInstanceShow() {
|
|||
}
|
||||
};
|
||||
|
||||
const handleClickedDiagramTask = (shapeElement: any) => {
|
||||
const handleClickedDiagramTask = (
|
||||
shapeElement: any,
|
||||
bpmnRootElement: any
|
||||
) => {
|
||||
if (tasks) {
|
||||
const matchingTask: any = tasks.find(
|
||||
(task: any) => task.name === shapeElement.id
|
||||
(task: any) =>
|
||||
task.name === shapeElement.id &&
|
||||
task.process_identifier === bpmnRootElement.id
|
||||
);
|
||||
if (matchingTask) {
|
||||
setTaskToDisplay(matchingTask);
|
||||
|
@ -471,19 +502,28 @@ export default function ProcessInstanceShow() {
|
|||
);
|
||||
}
|
||||
|
||||
if (task.type === 'Call Activity') {
|
||||
buttons.push(
|
||||
<Link
|
||||
data-qa="go-to-call-activity-result"
|
||||
to={`${window.location.pathname}?process_identifier=${task.call_activity_process_identifier}`}
|
||||
target="_blank"
|
||||
>
|
||||
View Call Activity Diagram
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
if (canEditTaskData(task)) {
|
||||
if (editingTaskData) {
|
||||
buttons.push(
|
||||
<Button
|
||||
data-qa="create-script-unit-test-button"
|
||||
onClick={saveTaskData}
|
||||
>
|
||||
<Button data-qa="save-task-data-button" onClick={saveTaskData}>
|
||||
Save
|
||||
</Button>
|
||||
);
|
||||
buttons.push(
|
||||
<Button
|
||||
data-qa="create-script-unit-test-button"
|
||||
data-qa="cancel-task-data-edit-button"
|
||||
onClick={cancelEditingTaskData}
|
||||
>
|
||||
Cancel
|
||||
|
@ -492,7 +532,7 @@ export default function ProcessInstanceShow() {
|
|||
} else {
|
||||
buttons.push(
|
||||
<Button
|
||||
data-qa="create-script-unit-test-button"
|
||||
data-qa="edit-task-data-button"
|
||||
onClick={() => setEditingTaskData(true)}
|
||||
>
|
||||
Edit
|
||||
|
@ -622,8 +662,8 @@ export default function ProcessInstanceShow() {
|
|||
processModelId={processModelId || ''}
|
||||
diagramXML={processInstanceToUse.bpmn_xml_file_contents || ''}
|
||||
fileName={processInstanceToUse.bpmn_xml_file_contents || ''}
|
||||
readyOrWaitingBpmnTaskIds={taskIds.readyOrWaiting}
|
||||
completedTasksBpmnIds={taskIds.completed}
|
||||
readyOrWaitingProcessInstanceTasks={taskIds.readyOrWaiting}
|
||||
completedProcessInstanceTasks={taskIds.completed}
|
||||
diagramType="readonly"
|
||||
onElementClick={handleClickedDiagramTask}
|
||||
/>
|
||||
|
|
|
@ -26,7 +26,7 @@ type backendCallProps = {
|
|||
postBody?: any;
|
||||
};
|
||||
|
||||
class UnauthenticatedError extends Error {
|
||||
export class UnauthenticatedError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'UnauthenticatedError';
|
||||
|
|
|
@ -27,8 +27,8 @@ const doLogout = () => {
|
|||
const idToken = getIdToken();
|
||||
localStorage.removeItem('jwtAccessToken');
|
||||
localStorage.removeItem('jwtIdToken');
|
||||
const redirctUrl = `${window.location.origin}/`;
|
||||
const url = `${BACKEND_BASE_URL}/logout?redirect_url=${redirctUrl}&id_token=${idToken}`;
|
||||
const redirectUrl = `${window.location.origin}`;
|
||||
const url = `${BACKEND_BASE_URL}/logout?redirect_url=${redirectUrl}&id_token=${idToken}`;
|
||||
window.location.href = url;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue