This is an automated email from the ASF dual-hosted git repository.
tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new e71a41a4341 [Incubator-kie-issues#1314] @kie-tools/jbpm-quarkus-devui:
Wrong behaviors on the Error notification in Start Process Form component
(#2675)
e71a41a4341 is described below
commit e71a41a434182d8ae67c8a4ba93ce19347137620
Author: bncriju <[email protected]>
AuthorDate: Tue Oct 22 09:39:52 2024 +0530
[Incubator-kie-issues#1314] @kie-tools/jbpm-quarkus-devui: Wrong behaviors
on the Error notification in Start Process Form component (#2675)
---
.../FormNotification/FormNotification.tsx | 8 ++++--
.../ProcessFormContainer/ProcessFormContainer.tsx | 2 +-
.../pages/ProcessFormPage/ProcessFormPage.tsx | 31 +++++++++++++---------
3 files changed, 26 insertions(+), 15 deletions(-)
diff --git
a/packages/runtime-tools-components/src/common/components/FormNotification/FormNotification.tsx
b/packages/runtime-tools-components/src/common/components/FormNotification/FormNotification.tsx
index 3d6449c9899..468f7fbceb0 100644
---
a/packages/runtime-tools-components/src/common/components/FormNotification/FormNotification.tsx
+++
b/packages/runtime-tools-components/src/common/components/FormNotification/FormNotification.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
-import React, { useState } from "react";
+import React, { useState, useMemo } from "react";
import { Alert, AlertActionCloseButton, AlertActionLink } from
"@patternfly/react-core/dist/js/components/Alert";
import { componentOuiaProps, OUIAProps } from "../../ouiaTools";
@@ -42,6 +42,10 @@ export const FormNotification: React.FC<IOwnProps &
OUIAProps> = ({ notification
const variant = notification.type === "error" ? "danger" : "success";
const [showDetails, setShowDetails] = useState<boolean>(false);
+ const content = useMemo(
+ () => showDetails && notification.details && <p>{notification.details}</p>,
+ [showDetails, notification.details]
+ );
return (
<Alert
isInline
@@ -66,7 +70,7 @@ export const FormNotification: React.FC<IOwnProps &
OUIAProps> = ({ notification
actionClose={<AlertActionCloseButton onClose={notification.close} />}
{...componentOuiaProps(ouiaId, "form-notification-alert", ouiaSafe)}
>
- {showDetails && notification.details && <p>{notification.details}</p>}
+ {content}
</Alert>
);
};
diff --git
a/packages/runtime-tools-process-dev-ui-webapp/src/components/containers/ProcessFormContainer/ProcessFormContainer.tsx
b/packages/runtime-tools-process-dev-ui-webapp/src/components/containers/ProcessFormContainer/ProcessFormContainer.tsx
index 5895d63c40d..6baa0e7be99 100755
---
a/packages/runtime-tools-process-dev-ui-webapp/src/components/containers/ProcessFormContainer/ProcessFormContainer.tsx
+++
b/packages/runtime-tools-process-dev-ui-webapp/src/components/containers/ProcessFormContainer/ProcessFormContainer.tsx
@@ -57,7 +57,7 @@ const ProcessFormContainer:
React.FC<ProcessFormContainerProps & OUIAProps> = ({
onSubmitSuccess(id);
})
.catch((error) => {
- const message = error.response ? error.response.data :
error.message;
+ const message = error.response ? `${error.response.statusText} :
${error.message}` : error.message;
onSubmitError(message);
});
},
diff --git
a/packages/runtime-tools-process-dev-ui-webapp/src/components/pages/ProcessFormPage/ProcessFormPage.tsx
b/packages/runtime-tools-process-dev-ui-webapp/src/components/pages/ProcessFormPage/ProcessFormPage.tsx
index 1de2b62da2e..ab68c515a7f 100644
---
a/packages/runtime-tools-process-dev-ui-webapp/src/components/pages/ProcessFormPage/ProcessFormPage.tsx
+++
b/packages/runtime-tools-process-dev-ui-webapp/src/components/pages/ProcessFormPage/ProcessFormPage.tsx
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React, { useEffect, useState } from "react";
+import React, { useEffect, useState, useCallback } from "react";
import { Card, CardBody } from
"@patternfly/react-core/dist/js/components/Card";
import { PageSection } from "@patternfly/react-core/dist/js/components/Page";
import ProcessFormContainer from
"../../containers/ProcessFormContainer/ProcessFormContainer";
@@ -51,10 +51,6 @@ const ProcessFormPage: React.FC<OUIAProps> = ({ ouiaId,
ouiaSafe }) => {
history.push("/Processes");
};
- const goToProcessDetails = () => {
- history.push(`/Process/${processId}`);
- };
-
const showNotification = (
notificationType: Notification["type"],
submitMessage: string,
@@ -72,18 +68,21 @@ const ProcessFormPage: React.FC<OUIAProps> = ({ ouiaId,
ouiaSafe }) => {
goToProcessDefinition();
},
},
- {
- label: "Go to Process details",
- onClick: () => {
- setNotification(null);
- goToProcessDetails();
- },
- },
],
close: () => {
setNotification(null);
},
});
+ return (
+ <>
+ {processId && (
+ <div>
+ <label>Go to Process details</label>
+ <button onClick={handleClick}>Click Here</button>
+ </div>
+ )}
+ </>
+ );
};
const onSubmitSuccess = (id: string): void => {
@@ -97,6 +96,14 @@ const ProcessFormPage: React.FC<OUIAProps> = ({ ouiaId,
ouiaSafe }) => {
showNotification("error", message, details);
};
+ const handleClick = useCallback(() => {
+ const goToProcessDetails = () => {
+ history.push(`/Process/${processId}`);
+ };
+ setNotification(null);
+ goToProcessDetails();
+ }, [setNotification, history, processId]);
+
return (
<React.Fragment>
<PageSection
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]