Skip to content

Commit

Permalink
Merge branch 'main' of github.com:theopensystemslab/planx-new into je…
Browse files Browse the repository at this point in the history
…ss/notify-flow-status-change
  • Loading branch information
jessicamcinchak committed Aug 8, 2024
2 parents 67401bb + f5b4686 commit f5d93d2
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 160 deletions.
3 changes: 3 additions & 0 deletions api.planx.uk/.env.test.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ EDITOR_URL_EXT=example.com
HASURA_GRAPHQL_URL=http://hasura:8080/v1/graphql
HASURA_PLANX_API_KEY=👻

# Minio object storage server port
MINIO_PORT=1234

# Integrations
BOPS_API_TOKEN=👻
BOPS_API_TOKEN=👻
Expand Down
5 changes: 4 additions & 1 deletion api.planx.uk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import dotenv from "dotenv";
import { queryMock } from "./tests/graphqlQueryMock";

dotenv.config({ path: "./.env.test" });
dotenv.config({
path: "./.env.test",
override: true,
});

beforeEach(() => {
queryMock.setup(process.env.HASURA_GRAPHQL_URL);
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/modules/file/service/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("s3 Factory", () => {
});

it("returns Minio config for local development", () => {
expect(s3Factory()).toHaveProperty("endpoint.host", "minio");
expect(s3Factory()).toHaveProperty("endpoint.host", "minio:1234");
});

["pizza", "staging", "production"].forEach((env) => {
Expand Down
7 changes: 4 additions & 3 deletions api.planx.uk/modules/gis/service/digitalLand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
} from "@opensystemslab/planx-core/types";
import { gql } from "graphql-request";
import fetch from "isomorphic-fetch";
import { addDesignatedVariable, omitGeometry } from "./helpers";
import { addDesignatedVariable } from "./helpers";
import { baseSchema } from "./local_authorities/metadata/base";
import { $api } from "../../../client";

Expand Down Expand Up @@ -68,6 +68,7 @@ async function go(
entries: "current",
geometry: geom,
geometry_relation: "intersects",
exclude_field: "geometry,point",
limit: "100", // TODO handle pagination in future for large polygons & many datasets, but should be well within this limit now
};
// 'dataset' param is not array[string] per docs, instead re-specify param name per unique dataset
Expand Down Expand Up @@ -120,14 +121,14 @@ async function go(
);
// because there can be many digital land datasets per planx variable, check if this key is already in our result
if (key && Object.keys(formattedResult).includes(key)) {
formattedResult[key]["data"]?.push(omitGeometry(entity));
formattedResult[key]["data"]?.push(entity);
} else {
if (key) {
formattedResult[key] = {
fn: key,
value: true,
text: baseSchema[key].pos,
data: [omitGeometry(entity)],
data: [entity],
category: baseSchema[key].category,
};
}
Expand Down
11 changes: 0 additions & 11 deletions api.planx.uk/modules/gis/service/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,6 @@ const getA4Subvariables = (features, articleFours, a4Key) => {
return result;
};

// Filter a Digital Land entity response object, omitting the "geometry" & "point" keys if exists
const omitGeometry = (entity) => {
return Object.keys(entity)
.filter((key) => !["geometry", "point"].includes(key))
.reduce((obj, key) => {
obj[key] = entity[key];
return obj;
}, {});
};

export {
setEsriGeometryType,
setEsriGeometry,
Expand All @@ -219,6 +209,5 @@ export {
squashResultLayers,
rollupResultLayers,
getA4Subvariables,
omitGeometry,
addDesignatedVariable,
};

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions e2e/tests/ui-driven/src/pay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,16 @@ test.describe("Gov Pay integration @regression", async () => {
await expect(page.getByText("Application sent")).toBeVisible();
await expect(page.getByText(actualPaymentId)).toBeVisible();

// try going back to the payment page
// Try going back to the GovPay payment page
await page.goBack();
// Unable to make another payment - just get a status page...
await expect(
page.locator("h1").getByText("Your payment session has expired"),
page.locator("h1").getByText("Your payment was successful"),
).toBeVisible();
// ...with a link back to PlanX
await page.locator("a").getByText("View your payment summary").click();
await expect(
page.locator("h1").getByText("Application sent"),
).toBeVisible();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import Chip from "@mui/material/Chip";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import React from "react";

import { StyledAvatar, StyledTableRow } from "./styles";
import { TeamMember } from "./types";

export const MembersTable: React.FC<{ members: TeamMember[] }> = ({
members,
}) => {
const roleLabels: Record<string, string> = {
platformAdmin: "Admin",
teamEditor: "Editor",
teamViewer: "Viewer",
};

const getRoleLabel = (role: string) => {
return roleLabels[role] || role;
};

if (members.length === 0) {
return (
<Table>
<TableHead>
<TableRow>
<TableCell>
<strong>No members found</strong>
</TableCell>
</TableRow>
</TableHead>
</Table>
);
}

return (
<TableContainer>
<Table>
<TableHead>
<StyledTableRow>
<TableCell sx={{ width: 300 }}>
<strong>User</strong>
</TableCell>
<TableCell sx={{ width: 200 }}>
<strong>Role</strong>
</TableCell>
<TableCell>
<strong>Email</strong>
</TableCell>
</StyledTableRow>
</TableHead>
<TableBody>
{members.map((member) => (
<StyledTableRow key={member.id}>
<TableCell
sx={{
display: "flex",
flexDirection: "row",
alignItems: "center",
}}
>
<StyledAvatar>
{member.firstName[0]}
{member.lastName[0]}
</StyledAvatar>
{member.firstName} {member.lastName}
</TableCell>
<TableCell>
<Chip
label={getRoleLabel(member.role)}
size="small"
sx={{ background: "#ddd" }}
/>
</TableCell>
<TableCell>{member.email}</TableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
);
};
107 changes: 2 additions & 105 deletions editor.planx.uk/src/pages/FlowEditor/components/Team/TeamMembers.tsx
Original file line number Diff line number Diff line change
@@ -1,113 +1,10 @@
import Avatar from "@mui/material/Avatar";
import Chip from "@mui/material/Chip";
import Container from "@mui/material/Container";
import { styled } from "@mui/material/styles";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import Typography from "@mui/material/Typography";
import { Role, User } from "@opensystemslab/planx-core/types";
import React from "react";
import { FONT_WEIGHT_SEMI_BOLD } from "theme";
import SettingsSection from "ui/editor/SettingsSection";

const StyledAvatar = styled(Avatar)(({ theme }) => ({
background: theme.palette.background.dark,
color: theme.palette.common.white,
fontSize: "1em",
fontWeight: FONT_WEIGHT_SEMI_BOLD,
marginRight: theme.spacing(1),
}));

const StyledTableRow = styled(TableRow)(({ theme }) => ({
"&:nth-of-type(even)": {
background: theme.palette.background.paper,
},
}));

export type TeamMember = Omit<User, "teams" | "isPlatformAdmin"> & {
role: Role;
};

const roleLabels: Record<string, string> = {
platformAdmin: "Admin",
teamEditor: "Editor",
teamViewer: "Viewer",
};

interface Props {
teamMembersByRole: Record<string, TeamMember[]>;
}

const MembersTable: React.FC<{ members: TeamMember[] }> = ({ members }) => {
const getRoleLabel = (role: string) => {
return roleLabels[role] || role;
};

if (members.length === 0) {
return (
<Table>
<TableHead>
<TableRow>
<TableCell>
<strong>No members found</strong>
</TableCell>
</TableRow>
</TableHead>
</Table>
);
}

return (
<TableContainer>
<Table>
<TableHead>
<StyledTableRow>
<TableCell sx={{ width: 300 }}>
<strong>User</strong>
</TableCell>
<TableCell sx={{ width: 200 }}>
<strong>Role</strong>
</TableCell>
<TableCell>
<strong>Email</strong>
</TableCell>
</StyledTableRow>
</TableHead>
<TableBody>
{members.map((member) => (
<StyledTableRow key={member.id}>
<TableCell
sx={{
display: "flex",
flexDirection: "row",
alignItems: "center",
}}
>
<StyledAvatar>
{member.firstName[0]}
{member.lastName[0]}
</StyledAvatar>
{member.firstName} {member.lastName}
</TableCell>
<TableCell>
<Chip
label={getRoleLabel(member.role)}
size="small"
sx={{ background: "#ddd" }}
/>
</TableCell>
<TableCell>{member.email}</TableCell>
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
);
};
import { MembersTable } from "./MembersTable";
import { Props, TeamMember } from "./types";

export const TeamMembers: React.FC<Props> = ({ teamMembersByRole }) => {
const platformAdmins = (teamMembersByRole.platformAdmin || []).filter(
Expand Down
18 changes: 18 additions & 0 deletions editor.planx.uk/src/pages/FlowEditor/components/Team/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Avatar from "@mui/material/Avatar";
import { styled } from "@mui/material/styles";
import TableRow from "@mui/material/TableRow";
import { FONT_WEIGHT_SEMI_BOLD } from "theme";

export const StyledAvatar = styled(Avatar)(({ theme }) => ({
background: theme.palette.background.dark,
color: theme.palette.common.white,
fontSize: "1em",
fontWeight: FONT_WEIGHT_SEMI_BOLD,
marginRight: theme.spacing(1),
}));

export const StyledTableRow = styled(TableRow)(({ theme }) => ({
"&:nth-of-type(even)": {
background: theme.palette.background.paper,
},
}));
9 changes: 9 additions & 0 deletions editor.planx.uk/src/pages/FlowEditor/components/Team/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Role, User } from "@opensystemslab/planx-core/types";

export type TeamMember = Omit<User, "teams" | "isPlatformAdmin"> & {
role: Role;
};

export interface Props {
teamMembersByRole: Record<string, TeamMember[]>;
}
6 changes: 2 additions & 4 deletions editor.planx.uk/src/routes/teamMembers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { Role, User } from "@opensystemslab/planx-core/types";
import gql from "graphql-tag";
import { groupBy } from "lodash";
import { compose, mount, NotFoundError, route, withData } from "navi";
import {
TeamMember,
TeamMembers,
} from "pages/FlowEditor/components/Team/TeamMembers";
import { TeamMembers } from "pages/FlowEditor/components/Team/TeamMembers";
import { TeamMember } from "pages/FlowEditor/components/Team/types";
import { useStore } from "pages/FlowEditor/lib/store";
import React from "react";

Expand Down

0 comments on commit f5d93d2

Please sign in to comment.