Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
85e9736
refactor(frontend): copy jsonforms components to new ui package
JamesDoingStuff Nov 18, 2026
f0a9fbd
feat(dashboard-2): add SciReactUI fonts
JamesDoingStuff Nov 18, 2026
e09138f
feat(RepositoryLink): add a button to link to a template repository
JamesDoingStuff Nov 18, 2026
4a3be9c
feat(WorkflowSubmitter): add component to submit a workflow from temp…
JamesDoingStuff Nov 18, 2026
82a8744
feat(WorkflowTemplateDetails): add workflow template page component
JamesDoingStuff Nov 18, 2026
14cb7b8
feat(WorkflowTemplateDetails): add query-wrapped WorkflowTemplateDeta…
JamesDoingStuff Nov 18, 2026
46963b0
fix(dashboard-2): allow content window to use all space
JamesDoingStuff Nov 18, 2026
d5aa755
feat(dashboard-2): add single template page
JamesDoingStuff Nov 18, 2026
ce56ea4
test(WorkflowTemplateDetails): add tests for workflow template page
JamesDoingStuff Nov 20, 2026
f9b165c
build(tests): configure test types
JamesDoingStuff Nov 20, 2026
055d99e
docs(WorkflowsTemplatePage): add stories for workflow template compon…
JamesDoingStuff Nov 20, 2026
d4de88e
build(workflows-apollo): fix package name in config
JamesDoingStuff Nov 23, 2026
b7c85fc
chore(WorkflowTemplateDetails): add mock queries
JamesDoingStuff Nov 23, 2026
32da7a9
docs(WorkflowTemplateDetails): add story for workflow template page w…
JamesDoingStuff Nov 23, 2026
6a352d1
test(WorkflowTemplateDetails): add tests for workflow template page w…
JamesDoingStuff Nov 23, 2026
456d86b
ci: compile Apollo queries
JamesDoingStuff Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/_frontend_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
working-directory: frontend
run: pnpm install --frozen-lockfile

- name: Download Graph Proxy Schema Artifact
- name: Download Graph Proxy Schema Artifact for Relay
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: graph-proxy
Expand All @@ -29,6 +29,16 @@ jobs:
working-directory: frontend/relay-workflows-lib
run: pnpm relay

- name: Download Graph Proxy Schema Artifact for Apollo
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: graph-proxy
path: frontend/workflows-apollo

- name: Compile Apollo
working-directory: frontend/workflows-apollo
run: pnpm codegen

- name: Build Typescript
working-directory: frontend/
run: pnpm tsc
Expand Down
5 changes: 3 additions & 2 deletions frontend/dashboard-2/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import WorkflowsRouterProvider from "./navigation-overlay/WorkflowsRouterProvide
import { NotepadText, Workflow, Zap } from "lucide-react";
import { WorkflowsApolloProvider } from "workflows-apollo";
import { NavRouteObject } from "./navigation-overlay/utils";

import "@diamondlightsource/sci-react-ui/font-styles.css";
import { WorkflowTemplatesPage } from "./routes/WorkflowTemplatesPage";
// Having to set index to true for all of them is quite annoying
// TODO: Fix this
const routeObjects: NavRouteObject[] = [
{
path: "templates",
element: <p>Templates list page</p>,
element: <WorkflowTemplatesPage />,
index: true,
icon: <NotepadText />,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function NavigationOverlay({
const [open, setOpen] = useState(true);

return (
<Box sx={{ display: "flex", maxWidth: "100vw", maxHeight: "100vh" }}>
<Box sx={{ display: "flex", width: "100vw", height: "100vh" }}>
<AppBar
position="fixed"
sx={{
Expand Down Expand Up @@ -89,7 +89,14 @@ export default function NavigationOverlay({
</AppBar>

<SidebarNav navigation={navigation} open={open} setOpen={setOpen} />
<Box sx={{ display: "flex", flexDirection: "column", height: "inherit" }}>
<Box
sx={{
display: "flex",
flexDirection: "column",
height: "inherit",
flexGrow: 1,
}}
>
{/* Toolbar call here is to align main content vertically below the AppBar
This is in the official MUI example:
https://mui.com/material-ui/react-drawer/#clipped-under-the-app-bar
Expand Down
5 changes: 5 additions & 0 deletions frontend/dashboard-2/src/routes/WorkflowTemplatesPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WorkflowTemplateDetails } from "workflows-apollo";

export function WorkflowTemplatesPage() {
return <WorkflowTemplateDetails templateName={"conditional-steps"} />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { gql, TypedDocumentNode } from "@apollo/client";
import {
WorkflowTemplateQuery as WorkflowTemplateQueryType,
WorkflowTemplateQueryVariables,
SubmitWorfklowTemplateMutation as SubmitWorkflowTemplateMutationType,
SubmitWorfklowTemplateMutationVariables,
} from "../../types/__generated__/graphql";

export const workflowTemplateQuery: TypedDocumentNode<
WorkflowTemplateQueryType,
WorkflowTemplateQueryVariables
> = gql`
query workflowTemplate($name: String!) {
workflowTemplate(name: $name) {
name
title
description
maintainer
arguments
uiSchema
repository
templateSource {
repositoryUrl
path
targetRevision
}
}
}
`;

export const submitWorkflowTemplateMutation: TypedDocumentNode<
SubmitWorkflowTemplateMutationType,
SubmitWorfklowTemplateMutationVariables
> = gql`
mutation submitWorfklowTemplate(
$name: String!
$visit: VisitInput!
$parameters: JSON!
) {
submitWorkflowTemplate(
name: $name
visit: $visit
parameters: $parameters
) {
id
}
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
submitWorkflowTemplateMock,
workflowTemplateMock,
} from "../../types/mocks";
import { WorkflowTemplateDetails } from "./WorkflowTemplateDetails";
import { Meta, StoryObj } from "@storybook/react";

const meta: Meta<typeof WorkflowTemplateDetails> = {
title: "WorkflowTemplateDetails",
component: WorkflowTemplateDetails,
tags: ["autodocs"],
parameters: {
docs: {
description: {
component:
"Displays a workflow template submission page and contains the relevant Apollo queries/mutations for populating the page and submitting workflows.",
},
},
},
};

type Story = StoryObj<typeof WorkflowTemplateDetails>;

export const TemplateSubmissionPage: Story = {
args: {
templateName: "mock-template",
},
parameters: {
apolloClient: {
mocks: [workflowTemplateMock, submitWorkflowTemplateMock],
},
},
};

export const Loading: Story = {
args: {
templateName: "mock-template",
},
parameters: {
apolloClient: {
mocks: [{ ...workflowTemplateMock, delay: Infinity }],
},
},
};

export default meta;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import "@testing-library/jest-dom";
import { render, screen } from "@testing-library/react";
import { MockedProvider } from "@apollo/client/testing/react";
import { WorkflowTemplateDetails } from "./WorkflowTemplateDetails";
import {
WorkflowTemplateDetails as MockedTemplateDetails,
type WorkflowTemplateDetailsProps,
} from "workflows-ui";
import { workflowTemplateMock } from "../../types/mocks";

vi.mock("workflows-ui", () => ({
WorkflowTemplateDetails: vi.fn((props: WorkflowTemplateDetailsProps) => (
<p>{props.template.title}</p>
)),
}));

const lastProps = () => {
const call = vi.mocked(MockedTemplateDetails).mock.lastCall;
if (!call) {
throw new Error("WorkflowTemplateDetails mock was never called");
}
return call[0];
};

describe("Apollo WorkflowTemplateDetails", () => {
afterEach(() => {
vi.clearAllMocks();
});

it("renders a TemplateDetails component with query data", async () => {
render(
<MockedProvider mocks={[workflowTemplateMock]}>
<WorkflowTemplateDetails templateName={"mock-template"} />
</MockedProvider>,
);
expect(await screen.findByText("Mock Template Title")).toBeInTheDocument();
});

it("passes a function to the submitter", async () => {
render(
<MockedProvider mocks={[{ ...workflowTemplateMock }]}>
<WorkflowTemplateDetails templateName={"mock-template"} />
</MockedProvider>,
);
await screen.findByText("Mock Template Title");
expect(lastProps().onSubmit).toEqual(expect.any(Function));
});

it("shows a loading component while query is fetched", async () => {
render(
<MockedProvider mocks={[{ ...workflowTemplateMock, delay: Infinity }]}>
<WorkflowTemplateDetails templateName={"mock-template"} />
</MockedProvider>,
);
expect(await screen.findByRole("progressbar")).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useMutation, useQuery } from "@apollo/client/react";
import { Progress, Visit } from "@diamondlightsource/sci-react-ui";
import { WorkflowTemplateDetails as WorkflowTemplateDetailsBase } from "workflows-ui";
import { Typography } from "@mui/material";
import {
submitWorkflowTemplateMutation,
workflowTemplateQuery,
} from "../../apollo/queries/WorkflowTemplateQueries";

interface WorkflowTemplateDetailsApolloProps {
templateName: string | null;
}

export function WorkflowTemplateDetails({
templateName,
}: WorkflowTemplateDetailsApolloProps) {
const { loading, error, data } = useQuery(workflowTemplateQuery, {
variables: { name: templateName ?? "example-template" },
});
const [submitWorkflowTemplate] = useMutation(submitWorkflowTemplateMutation);

async function onSubmit(name: string, session: Visit, parameters: object) {
await submitWorkflowTemplate({
variables: { name, visit: session, parameters },
});
}

return loading ? (
<Progress />
) : error || !data ? (
<Typography>Error! {error?.message}</Typography>
) : (
<WorkflowTemplateDetailsBase
template={data.workflowTemplate}
onSubmit={onSubmit}
/>
);
}
1 change: 1 addition & 0 deletions frontend/workflows-apollo/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as WorkflowsApolloProvider } from "./apollo/components/Workflow
export { externalRedirect } from "./auth/utils/coreUtils";
export { getUseAuthGateway } from "./auth/utils/useAuthGateway";
export { getUser } from "./auth/utils/keycloak";
export { WorkflowTemplateDetails } from "./components/templates/WorkflowTemplateDetails";
70 changes: 70 additions & 0 deletions frontend/workflows-apollo/lib/types/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
workflowTemplateQuery,
submitWorkflowTemplateMutation,
} from "../apollo/queries/WorkflowTemplateQueries";

export const workflowTemplateMock = {
request: {
query: workflowTemplateQuery,
variables: {
name: "mock-template",
},
},
result: {
data: {
workflowTemplate: {
name: "mock-template",
title: "Mock Template Title",
maintainer: "workflows-test",
description: "Mock workflows test template",
arguments: {
properties: {
jpeg: {
default: "true",
type: "boolean",
},
jpg: {
default: "true",
type: "boolean",
},
png: {
default: "true",
type: "boolean",
},
tif: {
default: "true",
type: "boolean",
},
tiff: {
default: "true",
type: "boolean",
},
},
required: ["jpeg", "jpg", "png", "tif", "tiff"],
type: "object",
},
uiSchema: null,
repository: "https://github.com/DiamondLightSource/workflows",
templateSource: {
repositoryUrl: "www.example.org",
path: "/test",
targetRevision: "HEAD",
},
},
},
},
};

export const submitWorkflowTemplateMock = {
request: {
query: submitWorkflowTemplateMutation,
variables: () => true,
},
result: {
data: {
submitWorkflowTemplate: {
id: "ks10000-1:mock-template-1a2b3:12345-abcde-67890",
},
},
},
};
2 changes: 1 addition & 1 deletion frontend/workflows-apollo/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
build: {
lib: {
entry: resolve(import.meta.dirname, "lib/main.ts"),
fileName: "workflows-ui",
fileName: "workflows-apollo",
formats: ["es", "cjs"],
},
rolldownOptions: {
Expand Down
Loading