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

Production deploy #3950

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ AWS_SECRET_KEY=👻
FILE_API_KEY=👻
FILE_API_KEY_NEXUS=👻
FILE_API_KEY_BARNET=👻
FILE_API_KEY_LAMBETH=👻
FILE_API_KEY_SOUTHWARK=👻

# Editor
Expand Down
1 change: 1 addition & 0 deletions api.planx.uk/.env.test.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ AWS_SECRET_KEY=👻
FILE_API_KEY=👻
FILE_API_KEY_NEXUS=👻
FILE_API_KEY_BARNET=👻
FILE_API_KEY_LAMBETH=👻
FILE_API_KEY_SOUTHWARK=👻

# Editor
Expand Down
4 changes: 4 additions & 0 deletions api.planx.uk/modules/auth/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export const useFilePermission: RequestHandler = (req, _res, next): void => {
req.headers["api-key"] as string,
process.env.FILE_API_KEY_BARNET!,
) ||
isEqual(
req.headers["api-key"] as string,
process.env.FILE_API_KEY_LAMBETH!,
) ||
isEqual(
req.headers["api-key"] as string,
process.env.FILE_API_KEY_SOUTHWARK!,
Expand Down
35 changes: 34 additions & 1 deletion api.planx.uk/modules/webhooks/service/sendNotification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,40 @@ export const sendSlackNotification = async (
if (disability) message += " [Exempt]";
if (resubmission) message += " [Resubmission]";

await slack.send(":incoming_envelope: " + message);
// Prefix message with a custom emoji if this submission fits November 2024 ODP Pilot testing criteria
const pilotCouncils = [
"barnet",
"buckinghamshire",
"camden",
"lambeth",
"medway",
];
// Message app types are a bit messy - Uniform won't have app type at all so we id by system because only accepts LDCs,
// BOPS will have internal ID with app type prefix, Email & S3 will have full PlanX service name
const pilotServices = [
"uniform",
"happ",
"ldc",
"apply for planning permission",
"apply for a lawful development certificate",
];

let isPilotEvent = false;
pilotCouncils.forEach((council) => {
pilotServices.forEach((service) => {
if (
message?.toLowerCase()?.includes(council) &&
message?.toLowerCase()?.includes(service)
) {
isPilotEvent = true;
}
});
});

const baseMessage = ":incoming_envelope: " + message;
message = isPilotEvent ? ":large_orange_square: " + baseMessage : baseMessage;

await slack.send(message);
return message;
};

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ services:
EDITOR_URL_EXT: ${EDITOR_URL_EXT}
ENCRYPTION_KEY: ${ENCRYPTION_KEY}
FILE_API_KEY_BARNET: ${FILE_API_KEY_BARNET}
FILE_API_KEY_LAMBETH: ${FILE_API_KEY_LAMBETH}
FILE_API_KEY_SOUTHWARK: ${FILE_API_KEY_SOUTHWARK}
FILE_API_KEY_NEXUS: ${FILE_API_KEY_NEXUS}
FILE_API_KEY: ${FILE_API_KEY}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
import { FeedbackEditor } from "./Editor";

const meta = {
title: "Editor Components/Feedback",
title: "Editor Components/Feedback modal",
component: FeedbackEditor,
} satisfies Meta<typeof FeedbackEditor>;

Expand Down
69 changes: 61 additions & 8 deletions editor.planx.uk/src/@planx/components/Notice/Public.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mostReadable } from "@ctrl/tinycolor";
import ErrorOutline from "@mui/icons-material/ErrorOutline";
import HelpIcon from "@mui/icons-material/Help";
import Box, { BoxProps } from "@mui/material/Box";
import Button from "@mui/material/Button";
import { styled, useTheme } from "@mui/material/styles";
Expand All @@ -8,14 +9,18 @@ import type { Notice } from "@planx/components/Notice/model";
import Card, {
contentFlowSpacing,
} from "@planx/components/shared/Preview/Card";
import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader";
import { PublicProps } from "@planx/components/shared/types";
import { useAnalyticsTracking } from "pages/FlowEditor/lib/analytics/provider";
import React from "react";
import { getContrastTextColor } from "styleUtils";
import { FONT_WEIGHT_SEMI_BOLD } from "theme";
import { emptyContent } from "ui/editor/RichTextInput/RichTextInput";
import ReactMarkdownOrHtml from "ui/shared/ReactMarkdownOrHtml/ReactMarkdownOrHtml";

import { HelpButton, Image } from "../shared/Preview/CardHeader/styled";
import MoreInfo from "../shared/Preview/MoreInfo";
import MoreInfoSection from "../shared/Preview/MoreInfoSection";

export type Props = PublicProps<Notice>;

const Container = styled(Box, {
Expand Down Expand Up @@ -77,12 +82,21 @@ const NoticeComponent: React.FC<Props> = (props) => {
props.color,
theme.palette.text.primary,
);

const { info, policyRef, howMeasured, definitionImg } = props;

const [open, setOpen] = React.useState(false);
const { trackEvent } = useAnalyticsTracking();

const handleHelpClick = () => {
setOpen(true);
trackEvent({ event: "helpClick", metadata: {} }); // This returns a promise but we don't need to await for it
};

const handleSubmit = !props.resetButton
? () => props.handleSubmit?.()
: undefined;

const { trackEvent } = useAnalyticsTracking();

const handleNoticeResetClick = () => {
trackEvent({
event: "flowDirectionChange",
Expand All @@ -95,11 +109,6 @@ const NoticeComponent: React.FC<Props> = (props) => {
return (
<Card handleSubmit={handleSubmit} isValid>
<>
<CardHeader
info={props.info}
policyRef={props.policyRef}
howMeasured={props.howMeasured}
/>
<Container customColor={props.color}>
<Content>
<TitleWrap>
Expand All @@ -117,6 +126,50 @@ const NoticeComponent: React.FC<Props> = (props) => {
</Box>
</Content>
</Container>
{!!(info || policyRef || howMeasured) && (
<Typography variant="subtitle1" component="div">
<HelpButton
variant="help"
title={`More information`}
aria-label={`See more information about this notice`}
onClick={handleHelpClick}
aria-haspopup="dialog"
data-testid="more-info-button"
>
<HelpIcon /> More information
</HelpButton>
</Typography>
)}
<MoreInfo open={open} handleClose={() => setOpen(false)}>
{info && info !== emptyContent ? (
<MoreInfoSection title="Why does it matter?">
<ReactMarkdownOrHtml source={info} openLinksOnNewTab />
</MoreInfoSection>
) : undefined}
{policyRef && policyRef !== emptyContent ? (
<MoreInfoSection title="Source">
<ReactMarkdownOrHtml source={policyRef} openLinksOnNewTab />
</MoreInfoSection>
) : undefined}
{howMeasured && howMeasured !== emptyContent ? (
<MoreInfoSection title="How is it defined?">
<>
{definitionImg && (
<Image
src={definitionImg}
alt=""
aria-describedby="howMeasured"
/>
)}
<ReactMarkdownOrHtml
source={howMeasured}
openLinksOnNewTab
id="howMeasured"
/>
</>
</MoreInfoSection>
) : undefined}
</MoreInfo>
{props.resetButton && (
<Button
variant="contained"
Expand Down
1 change: 1 addition & 0 deletions editor.planx.uk/src/components/Feedback/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type FeedbackCategory =
| "comment"
| "inaccuracy"
| "component";

export type FeedbackView = "banner" | "triage" | FeedbackCategory | "thanks";
export type ClickEvents = "close" | "back" | "triage" | FeedbackCategory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export const FeedbackLog: React.FC<FeedbackLogProps> = ({ feedback }) => {
<TableCell sx={{ width: 100 }}>
<strong>Date</strong>
</TableCell>
<TableCell sx={{ width: 140 }}>
<strong>Rating</strong>
</TableCell>
<TableCell sx={{ width: 340 }}>
<strong>Comment</strong>
</TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ export const CollapsibleRow: React.FC<CollapsibleRowProps> = (item) => {
userContext: "What were you doing?",
};

enum EmojiRating {
Terrible,
Poor,
Average,
Good,
Excellent,
}

const feedbackScore =
item.feedbackScore && EmojiRating[item.feedbackScore + 1]; // enums are 0-indexed

const renderContent = (key: string, value: any) => {
if (key === "combinedHelp" && value) {
return <ReactMarkdownOrHtml source={value} openLinksOnNewTab />;
Expand All @@ -144,6 +155,7 @@ export const CollapsibleRow: React.FC<CollapsibleRowProps> = (item) => {
<TableCell>
{format(new Date(item.createdAt), "dd/MM/yy hh:mm:ss")}
</TableCell>
<TableCell sx={{ textAlign: "center" }}>{feedbackScore}</TableCell>
<TableCell>{commentSummary}</TableCell>
<TableCell sx={{ textAlign: "right" }}>
<IconButton
Expand Down
8 changes: 5 additions & 3 deletions editor.planx.uk/src/routes/feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Feedback {
userContext: string | null;
createdAt: string;
address: string | null;
feedbackScore: number;
}

const feedbackRoutes = compose(
Expand All @@ -36,14 +37,14 @@ const feedbackRoutes = compose(
const isAuthorised = useStore.getState().canUserEditTeam(teamSlug);
if (!isAuthorised)
throw new NotFoundError(
`User does not have access to ${req.originalUrl}`,
`User does not have access to ${req.originalUrl}`
);

const {
data: { feedback },
} = await client.query<{ feedback: Feedback[] }>({
query: gql`
query GetFeebackForFlow($teamSlug: String!, $flowSlug: String!) {
query GetFeedbackForFlow($teamSlug: String!, $flowSlug: String!) {
feedback: feedback_summary(
order_by: { created_at: asc }
where: {
Expand All @@ -57,6 +58,7 @@ const feedbackRoutes = compose(
nodeType: node_type
userComment: user_comment
userContext: user_context
feedbackScore: feedback_score
createdAt: created_at
address
}
Expand All @@ -70,7 +72,7 @@ const feedbackRoutes = compose(
view: <FeedbackLog feedback={feedback} />,
};
}),
}),
})
);

export default feedbackRoutes;
Loading