- Implement cloning of workflow
- Entity change will now only clear the assignees instead of the whole workflow - Fix bug where side panel was showing all workflow assignees instead of just selected step assignees
This commit is contained in:
@@ -140,9 +140,16 @@ export default function Home({ user, userEntitiesWithLabel, userEntitiesTeachers
|
||||
}
|
||||
};
|
||||
|
||||
const handleResetWorkflow = (id: string) => {
|
||||
setWorkflows(prev => prev.filter(wf => wf.id !== id));
|
||||
handleAddNewWorkflow();
|
||||
const handleEntityChange = (wf: EditableApprovalWorkflow, entityId: string) => {
|
||||
const updatedWorkflow = {
|
||||
...wf,
|
||||
entityId: entityId,
|
||||
steps: wf.steps.map(step => ({
|
||||
...step,
|
||||
assignees: step.assignees.map(() => null)
|
||||
}))
|
||||
}
|
||||
onWorkflowChange(updatedWorkflow);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -207,11 +214,11 @@ export default function Home({ user, userEntitiesWithLabel, userEntitiesTeachers
|
||||
<form onSubmit={handleSubmit}>
|
||||
{currentWorkflow && (
|
||||
<>
|
||||
<div className="mb-8 flex flex-row gap-6">
|
||||
<div className="mb-8 flex flex-row gap-6 items-end">
|
||||
<Input
|
||||
label="Name:"
|
||||
type="text"
|
||||
name={currentWorkflow.name}
|
||||
required={true}
|
||||
placeholder="Enter workflow name"
|
||||
value={currentWorkflow.name}
|
||||
onChange={(updatedName) => {
|
||||
@@ -223,6 +230,7 @@ export default function Home({ user, userEntitiesWithLabel, userEntitiesTeachers
|
||||
}}
|
||||
/>
|
||||
<Select
|
||||
label="Entity:"
|
||||
options={ENTITY_OPTIONS}
|
||||
value={
|
||||
currentWorkflow.entityId === ""
|
||||
@@ -230,27 +238,23 @@ export default function Home({ user, userEntitiesWithLabel, userEntitiesTeachers
|
||||
: ENTITY_OPTIONS.find(option => option.value === currentWorkflow.entityId)
|
||||
}
|
||||
onChange={(selectedEntity) => {
|
||||
if (!currentWorkflow.entityId && selectedEntity?.value) {
|
||||
if (currentWorkflow.entityId) {
|
||||
if (!confirm("Clearing or changing entity will clear all the assignees for all steps in this workflow. Are you sure you want to proceed?")) return;
|
||||
}
|
||||
if (selectedEntity?.value) {
|
||||
setEntityId(selectedEntity.value);
|
||||
const updatedWorkflow = {
|
||||
...currentWorkflow,
|
||||
entityId: selectedEntity.value,
|
||||
};
|
||||
onWorkflowChange(updatedWorkflow);
|
||||
} else {
|
||||
if (!confirm("Clearing or changing entity will reset this workflow. Are you sure you want to proceed?")) return;
|
||||
handleResetWorkflow(currentWorkflow.id);
|
||||
handleEntityChange(currentWorkflow, selectedEntity.value);
|
||||
}
|
||||
}}
|
||||
isClearable
|
||||
placeholder="Entity..."
|
||||
placeholder="Enter workflow entity"
|
||||
/>
|
||||
<Button
|
||||
color="red"
|
||||
variant="solid"
|
||||
onClick={() => handleDeleteWorkflow(currentWorkflow.id)}
|
||||
type="button"
|
||||
className="min-w-fit text-lg font-medium flex items-center gap-2 text-left"
|
||||
className="min-w-fit h-[72px] text-lg font-medium flex items-center gap-2 text-left"
|
||||
>
|
||||
Delete Workflow
|
||||
<BsTrash className="size-6" />
|
||||
|
||||
Reference in New Issue
Block a user