More work on the create activity page
This commit is contained in:
parent
156d822cf5
commit
1b2637d89d
@ -2,6 +2,7 @@
|
|||||||
"Account": "Account",
|
"Account": "Account",
|
||||||
"Activate": "Activate",
|
"Activate": "Activate",
|
||||||
"Active": "Active",
|
"Active": "Active",
|
||||||
|
"ActivityWithNameCreated": "Activity '{{activityName}}' created",
|
||||||
"ActivityNameTemplate": "Activity Name Template",
|
"ActivityNameTemplate": "Activity Name Template",
|
||||||
"Add": "Add",
|
"Add": "Add",
|
||||||
"AddWithValue": "Add {{value}}",
|
"AddWithValue": "Add {{value}}",
|
||||||
|
|||||||
@ -4,11 +4,13 @@ import { useFormWithGuard } from "../../../components/common/useFormRouter";
|
|||||||
import Joi from "joi";
|
import Joi from "joi";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
renderButton,
|
||||||
renderInput,
|
renderInput,
|
||||||
renderWorkflowTemplatePicker,
|
renderWorkflowTemplatePicker,
|
||||||
} from "../../../components/common/formHelpers";
|
} from "../../../components/common/formHelpers";
|
||||||
import { InputType } from "../../../components/common/Input";
|
import { InputType } from "../../../components/common/Input";
|
||||||
import templateVersionsService from "../workflowTemplates/services/WorkflowTemplateService";
|
import templateVersionsService from "../workflowTemplates/services/WorkflowTemplateService";
|
||||||
|
import { toast } from "react-toastify";
|
||||||
|
|
||||||
const CreateActivity: React.FC = () => {
|
const CreateActivity: React.FC = () => {
|
||||||
const { t } = useTranslation(Namespaces.Common);
|
const { t } = useTranslation(Namespaces.Common);
|
||||||
@ -17,16 +19,14 @@ const CreateActivity: React.FC = () => {
|
|||||||
|
|
||||||
const form = useFormWithGuard({
|
const form = useFormWithGuard({
|
||||||
loaded: true,
|
loaded: true,
|
||||||
data: {
|
data: { workflowTemplate: undefined, activityName: "" },
|
||||||
workflowTemplate: undefined,
|
|
||||||
},
|
|
||||||
errors: {},
|
errors: {},
|
||||||
redirect: "",
|
redirect: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
form.schema = {
|
form.schema = {
|
||||||
workflowTemplate: Joi.object().required().label(t("WorkflowTemplate")),
|
workflowTemplate: Joi.object().required().label(t("WorkflowTemplate")),
|
||||||
activityName: Joi.string().max(450).label(t("ActivityName")),
|
activityName: Joi.string().allow("").max(450).label(t("ActivityName")),
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -61,8 +61,46 @@ const CreateActivity: React.FC = () => {
|
|||||||
const datePrefix = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")} ${String(now.getHours()).padStart(2, "0")}${String(now.getMinutes()).padStart(2, "0")}${String(now.getSeconds()).padStart(2, "0")}`;
|
const datePrefix = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")} ${String(now.getHours()).padStart(2, "0")}${String(now.getMinutes()).padStart(2, "0")}${String(now.getSeconds()).padStart(2, "0")}`;
|
||||||
const defaultActivityName = `${datePrefix} ${selectedWorkflowTemplateName ?? "New Activity"}`;
|
const defaultActivityName = `${datePrefix} ${selectedWorkflowTemplateName ?? "New Activity"}`;
|
||||||
|
|
||||||
|
const doSubmit = async (buttonName: string) => {
|
||||||
|
try {
|
||||||
|
const { workflowTemplate, activityName } = form.state.data;
|
||||||
|
|
||||||
|
const actualActivityName =
|
||||||
|
activityName == "" ? defaultActivityName : activityName;
|
||||||
|
|
||||||
|
// const response = await ssoManagerService.postSsoProvider(
|
||||||
|
// nameStr,
|
||||||
|
// clientIdStr,
|
||||||
|
// clientSecretStr,
|
||||||
|
// validIssuerStr,
|
||||||
|
// authorizationEndpointStr,
|
||||||
|
// tokenEndpointStr,
|
||||||
|
// isPublicValue,
|
||||||
|
// );
|
||||||
|
//if (response) {
|
||||||
|
toast.info(
|
||||||
|
t("ActivityWithNameCreated", {
|
||||||
|
activityName: actualActivityName,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// if (buttonName === "save") {
|
||||||
|
// form.setState({ redirect: "/ssoManager" });
|
||||||
|
// }
|
||||||
|
|
||||||
|
form.markAsSaved();
|
||||||
|
} catch (ex: any) {
|
||||||
|
form.handleGeneralError(ex);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
|
form.handleSubmit(e, doSubmit);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form>
|
<form onSubmit={handleSubmit}>
|
||||||
{renderWorkflowTemplatePicker(
|
{renderWorkflowTemplatePicker(
|
||||||
true,
|
true,
|
||||||
"workflowTemplate",
|
"workflowTemplate",
|
||||||
@ -71,20 +109,23 @@ const CreateActivity: React.FC = () => {
|
|||||||
form.state.errors,
|
form.state.errors,
|
||||||
form.handleWorkflowTemplatePickerChange,
|
form.handleWorkflowTemplatePickerChange,
|
||||||
)}
|
)}
|
||||||
{renderInput(
|
{selectedWorkflowTemplateName &&
|
||||||
"activityName",
|
renderInput(
|
||||||
t("ActivityName"),
|
"activityName",
|
||||||
form.state.data,
|
t("ActivityName"),
|
||||||
form.state.errors,
|
form.state.data,
|
||||||
InputType.text,
|
form.state.errors,
|
||||||
false,
|
InputType.text,
|
||||||
"",
|
false,
|
||||||
defaultActivityName,
|
"",
|
||||||
0,
|
defaultActivityName,
|
||||||
true,
|
0,
|
||||||
undefined,
|
true,
|
||||||
form.handleChange,
|
undefined,
|
||||||
)}
|
form.handleChange,
|
||||||
|
)}
|
||||||
|
{selectedWorkflowTemplateName &&
|
||||||
|
renderButton(t("CreateActivity"), form.state.errors, "save")}
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user