Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kie-issues#1276: Reuse components and retrieve workflow definitions from data index instead of openapi.json in sonataflow-deployment-webapp #2537

Merged
merged 9 commits into from
Sep 6, 2024
2 changes: 2 additions & 0 deletions packages/sonataflow-deployment-webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { OpenApiContextProvider } from "./context/OpenApiContextProvider";
import { RoutesSwitch } from "./navigation/RoutesSwitch";
import { DeploymentWorkflowListContextProvider } from "./runtimeTools/contexts/DeploymentWorkflowListContextProvider";
import { DeploymentWorkflowDetailsContextProvider } from "./runtimeTools/contexts/DeploymentWorkflowDetailsContextProvider";
import { DeploymentWorkflowDefinitionListContextProvider } from "./runtimeTools/contexts/DeploymentWorkflowDefinitionListContextProvider";

export const App = () => (
<HashRouter>
Expand All @@ -32,6 +33,7 @@ export const App = () => (
[OpenApiContextProvider, {}],
[DeploymentWorkflowListContextProvider, {}],
[DeploymentWorkflowDetailsContextProvider, {}],
[DeploymentWorkflowDefinitionListContextProvider, {}],
[RoutesSwitch, {}]
)}
</HashRouter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ import { CloudEventFormPage } from "../pages/Workflows/CloudEventFormPage";
import { WorkflowFormPage } from "../pages/Workflows/WorkflowFormPage";
import { routes } from "../routes";
import { RuntimeToolsRoutesSwitch } from "./RuntimeToolsRoutesSwitch";
import { RuntimeToolsWorkflowInstances } from "../runtimeTools/pages/RuntimeToolsWorkflowInstances";
import { RuntimeToolsWorkflowDetails } from "../runtimeTools/pages/RuntimeToolsWorkflowDetails";
import { RuntimeToolsWorkflowDefinitions } from "../runtimeTools/pages/RuntimeToolsWorkflowDefinitions";

export function RoutesSwitch() {
return (
<Switch>
<Route path={routes.runtimeTools.workflowInstances.path({})}>
<RuntimeToolsWorkflowInstances />
</Route>
<Route path={routes.runtimeTools.workflowDetails.path({ workflowId: ":workflowId" })}>
{({ match }) => <RuntimeToolsWorkflowDetails workflowId={match!.params.workflowId!} />}
</Route>
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
<Route path={routes.workflows.form.path({ workflowId: ":workflowId" })}>
{({ match }) => <WorkflowFormPage workflowId={match!.params.workflowId!} />}
</Route>
Expand All @@ -38,6 +47,7 @@ export function RoutesSwitch() {
</Route>
<Route path={routes.workflows.home.path({})}>
<Workflows />
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
{/* <RuntimeToolsWorkflowDefinitions /> */}
</Route>
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
<Route path={routes.runtimeTools.home.path({})}>
<RuntimeToolsRoutesSwitch />
Expand Down
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
fantonangeli marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { BasePage } from "../BasePage";
import { Link } from "react-router-dom";
import { routes } from "../../routes";
import { ErrorKind, ErrorPage } from "../ErrorPage";
import { RuntimeToolsWorkflowDefinitions } from "../../runtimeTools/pages/RuntimeToolsWorkflowDefinitions";

export function Workflows() {
const openApi = useOpenApi();
Expand All @@ -46,13 +47,13 @@ export function Workflows() {

return (
<BasePage>
<PageSection variant={"light"}>
{/* <PageSection variant={"light"}>
<TextContent>
<Text component={TextVariants.h1}>Workflows</Text>
</TextContent>
</PageSection>

<PageSection>
</PageSection> */}
<RuntimeToolsWorkflowDefinitions />
{/* <PageSection>
<Toolbar>
<ToolbarContent style={{ paddingLeft: "10px", paddingRight: "10px" }}>
<ToolbarItem alignment={{ default: "alignLeft" }}>
Expand Down Expand Up @@ -123,7 +124,7 @@ export function Workflows() {
/>
</Tbody>
</Table>
</PageSection>
</PageSection> */}
</BasePage>
);
}
Expand Down
9 changes: 8 additions & 1 deletion packages/sonataflow-deployment-webapp/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export enum QueryParams {

export enum PathParams {
WORKFLOW_ID = "workflowId",
WORKFLOW_NAME = "workflowName",
}

export class Route<
Expand Down Expand Up @@ -105,8 +106,14 @@ export const routes = {
queryParams: QueryParams.FILTERS | QueryParams.SORT_BY;
pathParams: PathParams.WORKFLOW_ID;
}>(({ workflowId }) => RUNTIME_TOOLS_ROUTE + `/workflow-details/${workflowId}`),
runtimeToolsWorkflowDefinitions: new Route<{}>(() => RUNTIME_TOOLS_ROUTE + `/workflow-definitions`),
runtimeToolsWorkflowForm: new Route<{
pathParams: PathParams.WORKFLOW_NAME;
}>(({ workflowName }) => RUNTIME_TOOLS_ROUTE + `/workflow-definition/${workflowName}`),
runtimeToolsTriggerCloudEventForWorkflowDefinition: new Route<{
pathParams: PathParams.WORKFLOW_NAME;
}>(({ workflowName }) => RUNTIME_TOOLS_ROUTE + `/workflow-definition/${workflowName}/trigger-cloud-event`),
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
},

dataJson: new Route<{}>(() => "/" + APPDATA_JSON_FILENAME),
openApiJson: new Route<{}>(() => "/q/openapi.json"),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as React from "react";
import { WorkflowDefinitionListContextProvider } from "@kie-tools/runtime-tools-swf-webapp-components/dist/WorkflowDefinitionList";
import { useApp } from "../../context/AppContext";

export function DeploymentWorkflowDefinitionListContextProvider(props: React.PropsWithChildren<{}>) {
const app = useApp();

return (
<WorkflowDefinitionListContextProvider dataIndexUrl={app.data.dataIndexUrl}>
{props.children}
</WorkflowDefinitionListContextProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React, { useCallback } from "react";
import { WorkflowDefinitionListContainer } from "@kie-tools/runtime-tools-swf-webapp-components/dist/WorkflowDefinitionListContainer";
import { Card } from "@patternfly/react-core/dist/esm/components/Card";
import { Page, PageSection } from "@patternfly/react-core/dist/js/components/Page";
import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/js/components/Text";
import { useHistory } from "react-router";
import { routes } from "../../routes";
import { WorkflowDefinition } from "@kie-tools/runtime-tools-swf-gateway-api/dist/types";
import { CloudEventPageSource } from "@kie-tools/runtime-tools-swf-webapp-components/dist/CloudEventForm";

const PAGE_TITLE = "Workflow Definitions";

export function RuntimeToolsWorkflowDefinitions() {
const history = useHistory();

const onOpenWorkflowForm = useCallback(
(workflowDefinition: WorkflowDefinition) => {
history.push({
pathname: routes.runtimeTools.runtimeToolsWorkflowForm.path({ workflowName: workflowDefinition.workflowName }),
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
state: {
workflowDefinition: {
workflowName: workflowDefinition.workflowName,
endpoint: workflowDefinition.endpoint,
serviceUrl: workflowDefinition.serviceUrl,
},
},
});
},
[history]
);

const onOpenTriggerCloudEventForWorkflow = useCallback(
(workflowDefinition: WorkflowDefinition) => {
history.push({
pathname: routes.runtimeTools.runtimeToolsTriggerCloudEventForWorkflowDefinition.path({
workflowName: workflowDefinition.workflowName,
}),
kumaradityaraj marked this conversation as resolved.
Show resolved Hide resolved
state: {
workflowDefinition: {
workflowName: workflowDefinition.workflowName,
endpoint: workflowDefinition.endpoint,
serviceUrl: workflowDefinition.serviceUrl,
},
source: CloudEventPageSource.DEFINITIONS,
},
});
},
[history]
);

return (
<Page>
<PageSection variant={"light"}>
<TextContent>
<Text component={TextVariants.h1}>{PAGE_TITLE}</Text>
<Text component={TextVariants.p}>
Start new workflow instances from the SonataFlow service linked in your Runtime Tools settings.
</Text>
</TextContent>
</PageSection>

<PageSection isFilled aria-label="workflow-definitions-section">
<Card>
<WorkflowDefinitionListContainer
onOpenWorkflowForm={onOpenWorkflowForm}
onOpenTriggerCloudEventForWorkflow={onOpenTriggerCloudEventForWorkflow}
/>
</Card>
</PageSection>
</Page>
);
}
8 changes: 8 additions & 0 deletions packages/sonataflow-deployment-webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ module.exports = async (env) =>
client: {
overlay: false,
},
proxy: [
{
context: (path, req) => req.method === "POST" || path === "/q/openapi.json",
target: "http://localhost:4000",
secure: false,
changeOrigin: true,
},
],
},
resolve: {
fallback: {
Expand Down
Loading