Create new component for displaying Task Names in a unified mannor throughout the application
This commit is contained in:
parent
2478d81ee4
commit
b9af3e482b
@ -9,6 +9,7 @@ import { SelectableList } from "../../../../components/common/SelectableList";
|
|||||||
import { sortTasksTopologically } from "./workflowGraphUtils";
|
import { sortTasksTopologically } from "./workflowGraphUtils";
|
||||||
import { useCapabilityDefaults, validateTask } from "./useCapabilityDefaults";
|
import { useCapabilityDefaults, validateTask } from "./useCapabilityDefaults";
|
||||||
import ValidationErrorIcon from "../../../../components/validationErrorIcon";
|
import ValidationErrorIcon from "../../../../components/validationErrorIcon";
|
||||||
|
import TaskNameDisplayPanel from "./TaskNameDisplayPanel";
|
||||||
|
|
||||||
interface TaskListProps {
|
interface TaskListProps {
|
||||||
tasks: TaskDefinition[];
|
tasks: TaskDefinition[];
|
||||||
@ -104,20 +105,13 @@ const TaskList: React.FC<TaskListProps> = ({
|
|||||||
selectedValue={selectedTask}
|
selectedValue={selectedTask}
|
||||||
renderLabel={(x) => {
|
renderLabel={(x) => {
|
||||||
if (x) {
|
if (x) {
|
||||||
const meta = taskMetadataByType.get(x.type);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<TaskNameDisplayPanel
|
||||||
<FontAwesomeStringIcon icon={meta?.icon} />
|
task={x}
|
||||||
{x.config.name as string}
|
showValidationErrorIcon={
|
||||||
{
|
|
||||||
<ValidationErrorIcon
|
|
||||||
visible={
|
|
||||||
validTasksList[x.config.guid as string] === false
|
validTasksList[x.config.guid as string] === false
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
} else return <></>;
|
} else return <></>;
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -0,0 +1,49 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import templateVersionsService, {
|
||||||
|
TaskMetadata,
|
||||||
|
TaskDefinition,
|
||||||
|
} from "../services/WorkflowTemplateService";
|
||||||
|
import React from "react";
|
||||||
|
import FontAwesomeStringIcon from "../../../../components/common/FontAwesomeStringIcon";
|
||||||
|
import ValidationErrorIcon from "../../../../components/validationErrorIcon";
|
||||||
|
|
||||||
|
export interface TaskNameDisplayPanel {
|
||||||
|
task: TaskDefinition;
|
||||||
|
showValidationErrorIcon: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TaskNameDisplayPanel: React.FC<TaskNameDisplayPanel> = ({
|
||||||
|
task,
|
||||||
|
showValidationErrorIcon = false,
|
||||||
|
}) => {
|
||||||
|
const [tasksMetadata, setTasksMetadata] = React.useState<TaskMetadata[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchTaskMetadata = async () => {
|
||||||
|
const meta = await templateVersionsService.getTaskMetadata("GeneralTask");
|
||||||
|
setTasksMetadata(meta);
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchTaskMetadata();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const taskMetadataByType = React.useMemo(() => {
|
||||||
|
const map = new Map<string, TaskMetadata>();
|
||||||
|
tasksMetadata.forEach((meta) => {
|
||||||
|
map.set(meta.taskType, meta);
|
||||||
|
});
|
||||||
|
return map;
|
||||||
|
}, [tasksMetadata]);
|
||||||
|
|
||||||
|
const meta = taskMetadataByType.get(task.type);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<FontAwesomeStringIcon icon={meta?.icon} />
|
||||||
|
{task.config.name as string}
|
||||||
|
{<ValidationErrorIcon visible={showValidationErrorIcon} />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TaskNameDisplayPanel;
|
||||||
@ -7,6 +7,7 @@ import ValidationErrorIcon from "../../../../components/validationErrorIcon";
|
|||||||
import { sortTasksTopologically } from "./workflowGraphUtils";
|
import { sortTasksTopologically } from "./workflowGraphUtils";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Namespaces } from "../../../../i18n/i18n";
|
import { Namespaces } from "../../../../i18n/i18n";
|
||||||
|
import TaskNameDisplayPanel from "./TaskNameDisplayPanel";
|
||||||
|
|
||||||
interface VisualiserTabProps {
|
interface VisualiserTabProps {
|
||||||
data: CreateWorkflowTemplateVersion;
|
data: CreateWorkflowTemplateVersion;
|
||||||
@ -684,10 +685,12 @@ const VisualiserTab: React.FC<VisualiserTabProps> = ({
|
|||||||
onMouseLeave={() => setHoveredGuid(null)}
|
onMouseLeave={() => setHoveredGuid(null)}
|
||||||
>
|
>
|
||||||
<div className="visualiser-node-content">
|
<div className="visualiser-node-content">
|
||||||
<ValidationErrorIcon
|
<TaskNameDisplayPanel
|
||||||
visible={taskValidation[guid] === false}
|
task={task}
|
||||||
|
showValidationErrorIcon={
|
||||||
|
taskValidation[guid] === false
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<span>{(task.config.name as string) || task.type}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user