diff --git a/api.planx.uk/helpers.ts b/api.planx.uk/helpers.ts index 22af164e16..d2d3c9a44a 100644 --- a/api.planx.uk/helpers.ts +++ b/api.planx.uk/helpers.ts @@ -4,6 +4,7 @@ import type { Flow, Node } from "./types.js"; import type { FlowGraph } from "@opensystemslab/planx-core/types"; import { ComponentType } from "@opensystemslab/planx-core/types"; import { $public, getClient } from "./client/index.js"; +import { userContext } from "./modules/auth/middleware.js"; export interface FlowData { slug: string; @@ -67,10 +68,11 @@ const insertFlow = async ( slug: string, name: string, flowData: Flow["data"], - creatorId?: number, copiedFrom?: Flow["id"], ) => { const { client: $client } = getClient(); + const userId = userContext.getStore()?.user?.sub; + try { const { flow: { id }, @@ -81,7 +83,6 @@ const insertFlow = async ( $slug: String! $name: String! $data: jsonb = {} - $creator_id: Int $copied_from: uuid ) { flow: insert_flows_one( @@ -91,7 +92,6 @@ const insertFlow = async ( name: $name data: $data version: 1 - creator_id: $creator_id copied_from: $copied_from } ) { @@ -104,7 +104,6 @@ const insertFlow = async ( slug: slug, name: name, data: flowData, - creator_id: creatorId, copied_from: copiedFrom, }, ); @@ -113,7 +112,7 @@ const insertFlow = async ( return { id }; } catch (error) { throw Error( - `User ${creatorId} failed to insert flow to teamId ${teamId}. Please check permissions. Error: ${error}`, + `User ${userId} failed to insert flow to teamId ${teamId}. Please check permissions. Error: ${error}`, ); } }; diff --git a/api.planx.uk/modules/flows/copyFlow/service.ts b/api.planx.uk/modules/flows/copyFlow/service.ts index c232cbc7e4..163fbae852 100644 --- a/api.planx.uk/modules/flows/copyFlow/service.ts +++ b/api.planx.uk/modules/flows/copyFlow/service.ts @@ -1,5 +1,4 @@ import { makeUniqueFlow, getFlowData, insertFlow } from "../../../helpers.js"; -import { userContext } from "../../auth/middleware.js"; const copyFlow = async ( flowId: string, @@ -16,18 +15,9 @@ const copyFlow = async ( if (insert) { const newSlug = flow.slug + "-copy"; const newName = flow.name + " (copy)"; - const creatorId = userContext.getStore()?.user?.sub; - if (!creatorId) throw Error("User details missing from request"); // Insert the flow and an associated operation - await insertFlow( - flow.team_id, - newSlug, - newName, - uniqueFlowData, - parseInt(creatorId), - flowId, - ); + await insertFlow(flow.team_id, newSlug, newName, uniqueFlowData, flowId); } return { flow, uniqueFlowData }; diff --git a/editor.planx.uk/src/@planx/components/AddressInput/Editor.tsx b/editor.planx.uk/src/@planx/components/AddressInput/Editor.tsx index e7bfef588d..35a9a643a1 100644 --- a/editor.planx.uk/src/@planx/components/AddressInput/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/AddressInput/Editor.tsx @@ -1,5 +1,5 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -9,6 +9,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import { AddressInput, parseAddressInput } from "./model"; export type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/AddressInput/Public.tsx b/editor.planx.uk/src/@planx/components/AddressInput/Public.tsx index c48adc4897..3ae055715f 100644 --- a/editor.planx.uk/src/@planx/components/AddressInput/Public.tsx +++ b/editor.planx.uk/src/@planx/components/AddressInput/Public.tsx @@ -1,6 +1,6 @@ import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import type { PublicProps } from "@planx/components/ui"; +import type { PublicProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import InputLabel from "ui/public/InputLabel"; diff --git a/editor.planx.uk/src/@planx/components/Calculate/Editor.tsx b/editor.planx.uk/src/@planx/components/Calculate/Editor.tsx index 7937956891..3cb8da3c9a 100644 --- a/editor.planx.uk/src/@planx/components/Calculate/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Calculate/Editor.tsx @@ -3,7 +3,7 @@ import { styled } from "@mui/material/styles"; import Switch from "@mui/material/Switch"; import Typography from "@mui/material/Typography"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { FormikErrors, useFormik } from "formik"; import React from "react"; import InputGroup from "ui/editor/InputGroup"; @@ -13,6 +13,7 @@ import ModalSectionContent from "ui/editor/ModalSectionContent"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import type { Calculate } from "./model"; import { evaluate, getVariables, parseCalculate } from "./model"; diff --git a/editor.planx.uk/src/@planx/components/Calculate/Public.tsx b/editor.planx.uk/src/@planx/components/Calculate/Public.tsx index af6aaffbcb..93d4766298 100644 --- a/editor.planx.uk/src/@planx/components/Calculate/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Calculate/Public.tsx @@ -1,5 +1,5 @@ +import type { PublicProps } from "@planx/components/shared/types"; import { makeData } from "@planx/components/shared/utils"; -import type { PublicProps } from "@planx/components/ui"; import { useStore } from "pages/FlowEditor/lib/store"; import { useEffect } from "react"; diff --git a/editor.planx.uk/src/@planx/components/Checklist/Editor.tsx b/editor.planx.uk/src/@planx/components/Checklist/Editor.tsx index c4585a46da..48eb498c13 100644 --- a/editor.planx.uk/src/@planx/components/Checklist/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Checklist/Editor.tsx @@ -23,37 +23,14 @@ import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; -import { BaseNodeData, Option, parseBaseNodeData } from "../shared"; +import { Option, parseBaseNodeData } from "../shared"; +import { ICONS } from "../shared/icons"; import PermissionSelect from "../shared/PermissionSelect"; -import { ICONS } from "../ui"; -import type { Category, Checklist, Group } from "./model"; +import type { Checklist, Group } from "./model"; import { toggleExpandableChecklist } from "./model"; +import { ChecklistProps, OptionEditorProps } from "./types"; -export interface ChecklistProps extends Checklist { - text: string; - handleSubmit?: Function; - node?: { - data?: { - allRequired?: boolean; - neverAutoAnswer?: boolean; - categories?: Array; - description?: string; - fn?: string; - img?: string; - text: string; - } & BaseNodeData; - }; -} - -const OptionEditor: React.FC<{ - index: number; - value: Option; - onChange: (newVal: Option) => void; - groupIndex?: number; - groups?: Array; - onMoveToGroup?: (itemIndex: number, groupIndex: number) => void; - showValueField?: boolean; -}> = (props) => { +const OptionEditor: React.FC = (props) => { return (
diff --git a/editor.planx.uk/src/@planx/components/Checklist/Public.tsx b/editor.planx.uk/src/@planx/components/Checklist/Public.tsx index bbc4cf7b02..3291b9b988 100644 --- a/editor.planx.uk/src/@planx/components/Checklist/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Checklist/Public.tsx @@ -22,7 +22,7 @@ import ErrorWrapper from "ui/shared/ErrorWrapper"; import { object } from "yup"; import { Option } from "../shared"; -import type { PublicProps } from "../ui"; +import type { PublicProps } from "../shared/types"; export type Props = PublicProps; diff --git a/editor.planx.uk/src/@planx/components/Checklist/types.ts b/editor.planx.uk/src/@planx/components/Checklist/types.ts new file mode 100644 index 0000000000..9078812768 --- /dev/null +++ b/editor.planx.uk/src/@planx/components/Checklist/types.ts @@ -0,0 +1,27 @@ +import { BaseNodeData, Option } from "../shared"; +import type { Category, Checklist } from "./model"; + +export interface ChecklistProps extends Checklist { + text: string; + handleSubmit?: Function; + node?: { + data?: { + allRequired?: boolean; + neverAutoAnswer?: boolean; + categories?: Array; + description?: string; + fn?: string; + img?: string; + text: string; + } & BaseNodeData; + }; +} +export interface OptionEditorProps { + index: number; + value: Option; + onChange: (newVal: Option) => void; + groupIndex?: number; + groups?: Array; + onMoveToGroup?: (itemIndex: number, groupIndex: number) => void; + showValueField?: boolean; +} diff --git a/editor.planx.uk/src/@planx/components/Confirmation/Editor.tsx b/editor.planx.uk/src/@planx/components/Confirmation/Editor.tsx index 75da2069f9..2e64a68f6f 100644 --- a/editor.planx.uk/src/@planx/components/Confirmation/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Confirmation/Editor.tsx @@ -1,6 +1,6 @@ import Box from "@mui/material/Box"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React, { ChangeEvent } from "react"; import ListManager, { @@ -12,6 +12,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import { Confirmation, parseNextSteps, Step } from "./model"; export type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx b/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx index e6316ad774..f6cd94fd2c 100644 --- a/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Confirmation/Public.tsx @@ -4,7 +4,7 @@ import Typography from "@mui/material/Typography"; import { QuestionAndResponses } from "@opensystemslab/planx-core/types"; import Card from "@planx/components/shared/Preview/Card"; import { SummaryListTable } from "@planx/components/shared/Preview/SummaryList"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { objectWithoutNullishValues } from "lib/objectHelpers"; import { Store, useStore } from "pages/FlowEditor/lib/store"; import React, { useEffect, useState } from "react"; diff --git a/editor.planx.uk/src/@planx/components/ContactInput/Editor.tsx b/editor.planx.uk/src/@planx/components/ContactInput/Editor.tsx index 962d0330bf..c8bb017dcb 100644 --- a/editor.planx.uk/src/@planx/components/ContactInput/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/ContactInput/Editor.tsx @@ -1,5 +1,5 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -9,6 +9,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import { ContactInput, parseContactInput } from "./model"; export type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/ContactInput/Public.tsx b/editor.planx.uk/src/@planx/components/ContactInput/Public.tsx index 340f124957..5dd8ad58c4 100644 --- a/editor.planx.uk/src/@planx/components/ContactInput/Public.tsx +++ b/editor.planx.uk/src/@planx/components/ContactInput/Public.tsx @@ -1,6 +1,6 @@ import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import type { PublicProps } from "@planx/components/ui"; +import type { PublicProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import InputLabel from "ui/public/InputLabel"; diff --git a/editor.planx.uk/src/@planx/components/Content/Editor.tsx b/editor.planx.uk/src/@planx/components/Content/Editor.tsx index c361ddee4a..fa973ddffe 100644 --- a/editor.planx.uk/src/@planx/components/Content/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Content/Editor.tsx @@ -1,7 +1,7 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import type { Content } from "@planx/components/Content/model"; import { parseContent } from "@planx/components/Content/model"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import ColorPicker from "ui/editor/ColorPicker/ColorPicker"; @@ -11,6 +11,8 @@ import ModalSectionContent from "ui/editor/ModalSectionContent"; import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; + export type Props = EditorProps; const ContentComponent: React.FC = (props) => { diff --git a/editor.planx.uk/src/@planx/components/Content/Public.tsx b/editor.planx.uk/src/@planx/components/Content/Public.tsx index 3f3fba2c55..ec0d61c092 100644 --- a/editor.planx.uk/src/@planx/components/Content/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Content/Public.tsx @@ -5,7 +5,7 @@ import { styled } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; import type { Content } from "@planx/components/Content/model"; import Card from "@planx/components/shared/Preview/Card"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { useAnalyticsTracking } from "pages/FlowEditor/lib/analytics/provider"; import React from "react"; import { getContrastTextColor } from "styleUtils"; diff --git a/editor.planx.uk/src/@planx/components/DateInput/Editor.tsx b/editor.planx.uk/src/@planx/components/DateInput/Editor.tsx index 50cd6d1d63..b1e9bde74a 100644 --- a/editor.planx.uk/src/@planx/components/DateInput/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/DateInput/Editor.tsx @@ -6,7 +6,7 @@ import { paddedDate, parseDateInput, } from "@planx/components/DateInput/model"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -17,6 +17,8 @@ import DateInputUi from "ui/shared/DateInput/DateInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; + export type Props = EditorProps; const DateInputComponent: React.FC = (props) => { diff --git a/editor.planx.uk/src/@planx/components/DateInput/Public.tsx b/editor.planx.uk/src/@planx/components/DateInput/Public.tsx index 2d8db2ff69..14c492d15a 100644 --- a/editor.planx.uk/src/@planx/components/DateInput/Public.tsx +++ b/editor.planx.uk/src/@planx/components/DateInput/Public.tsx @@ -7,7 +7,7 @@ import { } from "@planx/components/DateInput/model"; import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import DateInputComponent from "ui/shared/DateInput/DateInput"; diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx b/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx index 2b6050db9a..01bbfb47f0 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/Editor.tsx @@ -1,7 +1,7 @@ import FormControlLabel from "@mui/material/FormControlLabel"; import Switch from "@mui/material/Switch"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import InputGroup from "ui/editor/InputGroup"; @@ -12,6 +12,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import type { DrawBoundary } from "./model"; import { parseDrawBoundary } from "./model"; diff --git a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx index 0d09c79d65..8c533ae74b 100644 --- a/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/DrawBoundary/Public/index.tsx @@ -11,8 +11,8 @@ import { MapFooter, } from "@planx/components/shared/Preview/MapContainer"; import { PrivateFileUpload } from "@planx/components/shared/PrivateFileUpload/PrivateFileUpload"; +import type { PublicProps } from "@planx/components/shared/types"; import { squareMetresToHectares } from "@planx/components/shared/utils"; -import type { PublicProps } from "@planx/components/ui"; import buffer from "@turf/buffer"; import { point } from "@turf/helpers"; import { Feature } from "geojson"; diff --git a/editor.planx.uk/src/@planx/components/ExternalPortal/Editor.tsx b/editor.planx.uk/src/@planx/components/ExternalPortal/Editor.tsx index 9e8d44e52c..99735c9aaf 100644 --- a/editor.planx.uk/src/@planx/components/ExternalPortal/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/ExternalPortal/Editor.tsx @@ -4,7 +4,7 @@ import React from "react"; import ModalSection from "ui/editor/ModalSection"; import ModalSectionContent from "ui/editor/ModalSectionContent"; -import { ICONS } from "../ui"; +import { ICONS } from "../shared/icons"; interface Flow { id: string; diff --git a/editor.planx.uk/src/@planx/components/Feedback/Public.tsx b/editor.planx.uk/src/@planx/components/Feedback/Public.tsx index a26a2d7fe5..e547afcaf0 100644 --- a/editor.planx.uk/src/@planx/components/Feedback/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Feedback/Public.tsx @@ -4,7 +4,7 @@ import Link from "@mui/material/Link"; import Typography from "@mui/material/Typography"; import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import type { PublicProps } from "@planx/components/ui"; +import type { PublicProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; diff --git a/editor.planx.uk/src/@planx/components/FileUpload/Editor.tsx b/editor.planx.uk/src/@planx/components/FileUpload/Editor.tsx index 3e6b69c6cc..cd84592001 100644 --- a/editor.planx.uk/src/@planx/components/FileUpload/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/FileUpload/Editor.tsx @@ -1,5 +1,4 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { ICONS } from "@planx/components/ui"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -9,6 +8,8 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; + function Component(props: any) { const formik = useFormik<{ color: string; diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.tsx index 3635853e62..b769d7a563 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Editor.tsx @@ -7,7 +7,7 @@ import { styled } from "@mui/material/styles"; import Switch from "@mui/material/Switch"; import Typography from "@mui/material/Typography"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import { lowerCase, merge, upperFirst } from "lodash"; import React from "react"; @@ -25,6 +25,7 @@ import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; +import { ICONS } from "../shared/icons"; import { checkIfConditionalRule, Condition, diff --git a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx index a661f1ad28..c1708cd6e0 100644 --- a/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx +++ b/editor.planx.uk/src/@planx/components/FileUploadAndLabel/Public.tsx @@ -6,7 +6,7 @@ import ListItem from "@mui/material/ListItem"; import ListSubheader from "@mui/material/ListSubheader"; import { styled } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { PrintButton } from "components/PrintButton"; import capitalize from "lodash/capitalize"; import { useAnalyticsTracking } from "pages/FlowEditor/lib/analytics/provider"; diff --git a/editor.planx.uk/src/@planx/components/Filter/Editor.tsx b/editor.planx.uk/src/@planx/components/Filter/Editor.tsx index 835c3c4abb..cffef5eb6b 100644 --- a/editor.planx.uk/src/@planx/components/Filter/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Filter/Editor.tsx @@ -9,7 +9,7 @@ import React from "react"; import ModalSection from "ui/editor/ModalSection"; import ModalSectionContent from "ui/editor/ModalSectionContent"; -import { ICONS } from "../ui"; +import { ICONS } from "../shared/icons"; export interface Props { id?: string; diff --git a/editor.planx.uk/src/@planx/components/Filter/Public.tsx b/editor.planx.uk/src/@planx/components/Filter/Public.tsx index b0d65628e8..44c9ee62ec 100644 --- a/editor.planx.uk/src/@planx/components/Filter/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Filter/Public.tsx @@ -1,16 +1,14 @@ -import type { PublicProps } from "@planx/components/ui"; import { useStore } from "pages/FlowEditor/lib/store"; import { useEffect } from "react"; +import { PublicProps } from "../shared/types"; import type { Props as Filter } from "./Editor"; export type Props = PublicProps; // Filters are always auto-answered and never seen by a user, but should still leave a breadcrumb export default function Component(props: Props) { - const autoAnswerableFlag = useStore( - (state) => state.autoAnswerableFlag, - ); + const autoAnswerableFlag = useStore((state) => state.autoAnswerableFlag); let idThatCanBeAutoAnswered: string | undefined; if (props.id) idThatCanBeAutoAnswered = autoAnswerableFlag(props.id); diff --git a/editor.planx.uk/src/@planx/components/FindProperty/Editor.tsx b/editor.planx.uk/src/@planx/components/FindProperty/Editor.tsx index 208bd2333c..2cfee8fd4e 100644 --- a/editor.planx.uk/src/@planx/components/FindProperty/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/FindProperty/Editor.tsx @@ -1,7 +1,7 @@ import FormControlLabel from "@mui/material/FormControlLabel"; import Switch from "@mui/material/Switch"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import InputGroup from "ui/editor/InputGroup"; @@ -13,6 +13,7 @@ import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; +import { ICONS } from "../shared/icons"; import type { FindProperty } from "./model"; import { parseFindProperty } from "./model"; diff --git a/editor.planx.uk/src/@planx/components/FindProperty/Public/index.tsx b/editor.planx.uk/src/@planx/components/FindProperty/Public/index.tsx index c5fed728cb..c7f3093821 100644 --- a/editor.planx.uk/src/@planx/components/FindProperty/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/FindProperty/Public/index.tsx @@ -5,8 +5,8 @@ import { styled } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; +import { PublicProps } from "@planx/components/shared/types"; import { squareMetresToHectares } from "@planx/components/shared/utils"; -import { PublicProps } from "@planx/components/ui"; import area from "@turf/area"; import DelayedLoadingIndicator from "components/DelayedLoadingIndicator/DelayedLoadingIndicator"; import { Feature } from "geojson"; diff --git a/editor.planx.uk/src/@planx/components/InternalPortal/Editor.tsx b/editor.planx.uk/src/@planx/components/InternalPortal/Editor.tsx index 127d0862fd..01a3af5944 100644 --- a/editor.planx.uk/src/@planx/components/InternalPortal/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/InternalPortal/Editor.tsx @@ -3,7 +3,7 @@ import { useFormik } from "formik"; import React from "react"; import InputField from "ui/editor/InputField/InputField"; -import { FormError } from "../ui"; +import { FormError } from "../shared/types"; interface Flow { id: string; diff --git a/editor.planx.uk/src/@planx/components/List/Editor.tsx b/editor.planx.uk/src/@planx/components/List/Editor.tsx index 00b057be3d..72b01dc3b7 100644 --- a/editor.planx.uk/src/@planx/components/List/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/List/Editor.tsx @@ -13,7 +13,8 @@ import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; import InputRowLabel from "ui/shared/InputRowLabel"; -import { EditorProps, ICONS } from "../ui"; +import { ICONS } from "../shared/icons"; +import { EditorProps } from "../shared/types"; import { List, parseContent, validationSchema } from "./model"; import { ProposedAdvertisements } from "./schemas/Adverts"; import { NonResidentialFloorspace } from "./schemas/Floorspace"; diff --git a/editor.planx.uk/src/@planx/components/List/Public/Context.tsx b/editor.planx.uk/src/@planx/components/List/Public/Context.tsx index 929320bd68..e6c0741555 100644 --- a/editor.planx.uk/src/@planx/components/List/Public/Context.tsx +++ b/editor.planx.uk/src/@planx/components/List/Public/Context.tsx @@ -4,11 +4,11 @@ import { SchemaUserData, SchemaUserResponse, } from "@planx/components/shared/Schema/model"; +import { PublicProps } from "@planx/components/shared/types"; import { getPreviouslySubmittedData, makeData, } from "@planx/components/shared/utils"; -import { PublicProps } from "@planx/components/ui"; import { FormikProps, useFormik } from "formik"; import React, { createContext, diff --git a/editor.planx.uk/src/@planx/components/List/Public/index.tsx b/editor.planx.uk/src/@planx/components/List/Public/index.tsx index 861e7268da..8fe0fc4afb 100644 --- a/editor.planx.uk/src/@planx/components/List/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/List/Public/index.tsx @@ -9,7 +9,7 @@ import TableCell from "@mui/material/TableCell"; import TableRow from "@mui/material/TableRow"; import Typography from "@mui/material/Typography"; import { SchemaFields } from "@planx/components/shared/Schema/SchemaFields"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import React, { useEffect, useRef } from "react"; import { FONT_WEIGHT_SEMI_BOLD } from "theme"; import FullWidthWrapper from "ui/public/FullWidthWrapper"; diff --git a/editor.planx.uk/src/@planx/components/List/schemas/Trees.ts b/editor.planx.uk/src/@planx/components/List/schemas/Trees.ts index 8bd539c31b..4e01cd2523 100644 --- a/editor.planx.uk/src/@planx/components/List/schemas/Trees.ts +++ b/editor.planx.uk/src/@planx/components/List/schemas/Trees.ts @@ -57,6 +57,7 @@ export const Trees: Schema = { type: "date", data: { title: "Expected completion date", + description: "For example, 16 04 2027", fn: "completionDate", }, }, diff --git a/editor.planx.uk/src/@planx/components/List/schemas/TreesMapFirst.ts b/editor.planx.uk/src/@planx/components/List/schemas/TreesMapFirst.ts index a0077adb43..8370e44193 100644 --- a/editor.planx.uk/src/@planx/components/List/schemas/TreesMapFirst.ts +++ b/editor.planx.uk/src/@planx/components/List/schemas/TreesMapFirst.ts @@ -70,6 +70,7 @@ export const TreesMapFirst: Schema = { type: "date", data: { title: "Expected completion date", + description: "For example, 16 04 2027", fn: "completionDate", }, }, diff --git a/editor.planx.uk/src/@planx/components/MapAndLabel/Editor.tsx b/editor.planx.uk/src/@planx/components/MapAndLabel/Editor.tsx index 6f14c52153..4c8643b78f 100644 --- a/editor.planx.uk/src/@planx/components/MapAndLabel/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/MapAndLabel/Editor.tsx @@ -17,8 +17,9 @@ import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; +import { ICONS } from "../shared/icons"; import BasicRadio from "../shared/Radio/BasicRadio"; -import { EditorProps, ICONS } from "../ui"; +import { EditorProps } from "../shared/types"; import { MapAndLabel, parseContent } from "./model"; import { Trees } from "./schemas/Trees"; diff --git a/editor.planx.uk/src/@planx/components/MapAndLabel/Public/index.tsx b/editor.planx.uk/src/@planx/components/MapAndLabel/Public/index.tsx index b6aee6bfa5..5ffc2d2313 100644 --- a/editor.planx.uk/src/@planx/components/MapAndLabel/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/MapAndLabel/Public/index.tsx @@ -21,7 +21,7 @@ import ErrorWrapper from "ui/shared/ErrorWrapper"; import Card from "../../shared/Preview/Card"; import { CardHeader } from "../../shared/Preview/CardHeader/CardHeader"; import { MapContainer } from "../../shared/Preview/MapContainer"; -import { PublicProps } from "../../ui"; +import { PublicProps } from "../../shared/types"; import type { MapAndLabel } from "./../model"; import { MAP_ID, MapAndLabelProvider, useMapAndLabelContext } from "./Context"; import { CopyFeature } from "./CopyFeature"; diff --git a/editor.planx.uk/src/@planx/components/MapAndLabel/schemas/Trees.ts b/editor.planx.uk/src/@planx/components/MapAndLabel/schemas/Trees.ts index 6cc37e0267..cf79d415ca 100644 --- a/editor.planx.uk/src/@planx/components/MapAndLabel/schemas/Trees.ts +++ b/editor.planx.uk/src/@planx/components/MapAndLabel/schemas/Trees.ts @@ -57,6 +57,7 @@ export const Trees: Schema = { type: "date", data: { title: "Expected completion date", + description: "For example, 16 04 2027", fn: "completionDate", }, }, diff --git a/editor.planx.uk/src/@planx/components/NextSteps/Editor.tsx b/editor.planx.uk/src/@planx/components/NextSteps/Editor.tsx index 17e7c42aeb..8ac202989c 100644 --- a/editor.planx.uk/src/@planx/components/NextSteps/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/NextSteps/Editor.tsx @@ -2,7 +2,7 @@ import Box from "@mui/material/Box"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import type { NextSteps, Step } from "@planx/components/NextSteps/model"; import { parseNextSteps } from "@planx/components/NextSteps/model"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React, { ChangeEvent } from "react"; import ListManager, { @@ -15,6 +15,8 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; + type Props = EditorProps; const newStep = (): Step => ({ diff --git a/editor.planx.uk/src/@planx/components/NextSteps/Public.tsx b/editor.planx.uk/src/@planx/components/NextSteps/Public.tsx index 208cd4dc0f..3ae2b0fa4d 100644 --- a/editor.planx.uk/src/@planx/components/NextSteps/Public.tsx +++ b/editor.planx.uk/src/@planx/components/NextSteps/Public.tsx @@ -1,4 +1,4 @@ -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import React from "react"; import NextStepsList from "ui/public/NextStepsList"; diff --git a/editor.planx.uk/src/@planx/components/Notice/Editor.tsx b/editor.planx.uk/src/@planx/components/Notice/Editor.tsx index 48d2a9cc09..3988ad511a 100644 --- a/editor.planx.uk/src/@planx/components/Notice/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Notice/Editor.tsx @@ -3,7 +3,6 @@ import Switch from "@mui/material/Switch"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import type { Notice } from "@planx/components/Notice/model"; import { parseNotice } from "@planx/components/Notice/model"; -import { ICONS, InternalNotes, MoreInformation } from "@planx/components/ui"; import { useFormik } from "formik"; import React from "react"; import ColorPicker from "ui/editor/ColorPicker/ColorPicker"; @@ -14,6 +13,10 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { InternalNotes } from "../../../ui/editor/InternalNotes"; +import { MoreInformation } from "../../../ui/editor/MoreInformation/MoreInformation"; +import { ICONS } from "../shared/icons"; + export interface Props { id?: string; handleSubmit?: (data: { type: TYPES.Notice; data: Notice }) => void; diff --git a/editor.planx.uk/src/@planx/components/Notice/Public.tsx b/editor.planx.uk/src/@planx/components/Notice/Public.tsx index e87b9d133b..2f5a875314 100644 --- a/editor.planx.uk/src/@planx/components/Notice/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Notice/Public.tsx @@ -9,7 +9,7 @@ import Card, { contentFlowSpacing, } from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { useAnalyticsTracking } from "pages/FlowEditor/lib/analytics/provider"; import React from "react"; import { getContrastTextColor } from "styleUtils"; diff --git a/editor.planx.uk/src/@planx/components/NumberInput/Editor.tsx b/editor.planx.uk/src/@planx/components/NumberInput/Editor.tsx index dbe326843c..7ba24d3cff 100644 --- a/editor.planx.uk/src/@planx/components/NumberInput/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/NumberInput/Editor.tsx @@ -3,7 +3,7 @@ import Switch from "@mui/material/Switch"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import type { NumberInput } from "@planx/components/NumberInput/model"; import { parseNumberInput } from "@planx/components/NumberInput/model"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -15,6 +15,8 @@ import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; import InputRowLabel from "ui/shared/InputRowLabel"; +import { ICONS } from "../shared/icons"; + export type Props = EditorProps; export default function NumberInputComponent(props: Props): FCReturn { diff --git a/editor.planx.uk/src/@planx/components/NumberInput/Public.tsx b/editor.planx.uk/src/@planx/components/NumberInput/Public.tsx index 3987e98396..ac35e9cdef 100644 --- a/editor.planx.uk/src/@planx/components/NumberInput/Public.tsx +++ b/editor.planx.uk/src/@planx/components/NumberInput/Public.tsx @@ -1,6 +1,6 @@ import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import isNil from "lodash/isNil"; import React, { useEffect, useRef } from "react"; diff --git a/editor.planx.uk/src/@planx/components/Page/Editor.tsx b/editor.planx.uk/src/@planx/components/Page/Editor.tsx index b70b830a85..282e9087da 100644 --- a/editor.planx.uk/src/@planx/components/Page/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Page/Editor.tsx @@ -12,7 +12,8 @@ import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; import InputRowLabel from "ui/shared/InputRowLabel"; -import { EditorProps, ICONS } from "../ui"; +import { ICONS } from "../shared/icons"; +import { EditorProps } from "../shared/types"; import { Page, parsePage } from "./model"; import { ProposedAdvertisements } from "./schema/AdvertConsent"; diff --git a/editor.planx.uk/src/@planx/components/Page/Public.tsx b/editor.planx.uk/src/@planx/components/Page/Public.tsx index 615fbb4108..62f1f49a89 100644 --- a/editor.planx.uk/src/@planx/components/Page/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Page/Public.tsx @@ -1,4 +1,4 @@ -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { FormikConfig, useFormik } from "formik"; import React from "react"; diff --git a/editor.planx.uk/src/@planx/components/Pay/Editor.tsx b/editor.planx.uk/src/@planx/components/Pay/Editor.tsx index 2716d7c509..2efb9c7b83 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Editor.tsx @@ -14,26 +14,25 @@ import { validationSchema, } from "@planx/components/Pay/model"; import { parseBaseNodeData } from "@planx/components/shared"; -import { - EditorProps, - ICONS, - InternalNotes, - MoreInformation, -} from "@planx/components/ui"; import { Form, Formik, useFormikContext } from "formik"; import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; import { ComponentTagSelect } from "ui/editor/ComponentTagSelect"; +import { InternalNotes } from "ui/editor/InternalNotes"; import ListManager, { EditorProps as ListManagerEditorProps, } from "ui/editor/ListManager/ListManager"; import ModalSection from "ui/editor/ModalSection"; import ModalSectionContent from "ui/editor/ModalSectionContent"; +import { MoreInformation } from "ui/editor/MoreInformation/MoreInformation"; import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import ErrorWrapper from "ui/shared/ErrorWrapper"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; +import { EditorProps } from "../shared/types"; + type FormikGovPayMetadata = | Record[] | string diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx index ec7318a1f1..f9f4a4398c 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx @@ -3,7 +3,7 @@ import { GovUKPayment, PaymentStatus, } from "@opensystemslab/planx-core/types"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { logger } from "airbrake"; import axios from "axios"; import DelayedLoadingIndicator from "components/DelayedLoadingIndicator/DelayedLoadingIndicator"; diff --git a/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx b/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx index ee7ced4ac4..0e084932ed 100644 --- a/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx @@ -8,7 +8,7 @@ import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; import Typography from "@mui/material/Typography"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { FONT_WEIGHT_BOLD } from "theme"; @@ -20,6 +20,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import { availableDatasets, parseContent, PlanningConstraints } from "./model"; type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx b/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx index af0fa89e5b..f622093b59 100644 --- a/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx +++ b/editor.planx.uk/src/@planx/components/PlanningConstraints/Public.tsx @@ -4,7 +4,7 @@ import type { } from "@opensystemslab/planx-core/types"; import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import type { PublicProps } from "@planx/components/ui"; +import type { PublicProps } from "@planx/components/shared/types"; import DelayedLoadingIndicator from "components/DelayedLoadingIndicator/DelayedLoadingIndicator"; import { GraphError } from "components/Error/GraphError"; import { useStore } from "pages/FlowEditor/lib/store"; diff --git a/editor.planx.uk/src/@planx/components/PropertyInformation/Editor.tsx b/editor.planx.uk/src/@planx/components/PropertyInformation/Editor.tsx index 9ce1c9e0cd..a968492ae8 100644 --- a/editor.planx.uk/src/@planx/components/PropertyInformation/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/PropertyInformation/Editor.tsx @@ -1,7 +1,7 @@ import FormControlLabel from "@mui/material/FormControlLabel"; import Switch from "@mui/material/Switch"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -11,6 +11,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import { parseContent, PropertyInformation } from "./model"; type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx b/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx index cd9402734a..5cc2e29352 100644 --- a/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx +++ b/editor.planx.uk/src/@planx/components/PropertyInformation/Public.tsx @@ -5,7 +5,7 @@ import { visuallyHidden } from "@mui/utils"; import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; import { SummaryListTable } from "@planx/components/shared/Preview/SummaryList"; -import type { PublicProps } from "@planx/components/ui"; +import type { PublicProps } from "@planx/components/shared/types"; import { GraphError } from "components/Error/GraphError"; import { Feature } from "geojson"; import { publicClient } from "lib/graphql"; diff --git a/editor.planx.uk/src/@planx/components/Question/Editor.tsx b/editor.planx.uk/src/@planx/components/Question/Editor.tsx index 26d2e5d4cc..a5855342e3 100644 --- a/editor.planx.uk/src/@planx/components/Question/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Question/Editor.tsx @@ -14,9 +14,11 @@ import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; import InputRowItem from "ui/shared/InputRowItem"; +import { InternalNotes } from "../../../ui/editor/InternalNotes"; +import { MoreInformation } from "../../../ui/editor/MoreInformation/MoreInformation"; import { BaseNodeData, Option, parseBaseNodeData } from "../shared"; +import { ICONS } from "../shared/icons"; import PermissionSelect from "../shared/PermissionSelect"; -import { ICONS, InternalNotes, MoreInformation } from "../ui"; interface Props { node: { diff --git a/editor.planx.uk/src/@planx/components/Result/Editor.tsx b/editor.planx.uk/src/@planx/components/Result/Editor.tsx index 87c8ff7dde..5423ac452b 100644 --- a/editor.planx.uk/src/@planx/components/Result/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Result/Editor.tsx @@ -14,7 +14,8 @@ import InputLabel from "ui/public/InputLabel"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; -import { EditorProps, ICONS } from "../ui"; +import { ICONS } from "../shared/icons"; +import { EditorProps } from "../shared/types"; import { FlagDisplayText, Result } from "./model"; type FlagWithValue = Flag & { value: NonNullable }; diff --git a/editor.planx.uk/src/@planx/components/Result/Public/index.tsx b/editor.planx.uk/src/@planx/components/Result/Public/index.tsx index 81bdce60c7..ef90adedd8 100644 --- a/editor.planx.uk/src/@planx/components/Result/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/Result/Public/index.tsx @@ -6,7 +6,7 @@ import { DEFAULT_FLAG_CATEGORY } from "@opensystemslab/planx-core/types"; import Card from "@planx/components/shared/Preview/Card"; import SimpleExpand from "@planx/components/shared/Preview/SimpleExpand"; import { WarningContainer } from "@planx/components/shared/Preview/WarningContainer"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { useStore } from "pages/FlowEditor/lib/store"; import { Response } from "pages/FlowEditor/lib/store/preview"; import React from "react"; @@ -177,4 +177,4 @@ const ResultComponent: React.FC = (props) => { ); }; -export default ResultComponent; \ No newline at end of file +export default ResultComponent; diff --git a/editor.planx.uk/src/@planx/components/Review/Editor.tsx b/editor.planx.uk/src/@planx/components/Review/Editor.tsx index 463d70c56a..0673d8176a 100644 --- a/editor.planx.uk/src/@planx/components/Review/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Review/Editor.tsx @@ -8,7 +8,8 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; -import { EditorProps, ICONS } from "../ui"; +import { ICONS } from "../shared/icons"; +import { EditorProps } from "../shared/types"; import { parseContent, Review } from "./model"; type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/Review/Public/index.tsx b/editor.planx.uk/src/@planx/components/Review/Public/index.tsx index 44ead5f360..0295db3a9a 100644 --- a/editor.planx.uk/src/@planx/components/Review/Public/index.tsx +++ b/editor.planx.uk/src/@planx/components/Review/Public/index.tsx @@ -1,4 +1,4 @@ -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { useStore } from "pages/FlowEditor/lib/store"; import React from "react"; diff --git a/editor.planx.uk/src/@planx/components/Section/Editor.tsx b/editor.planx.uk/src/@planx/components/Section/Editor.tsx index fcf6e3292c..54d0dcb5c1 100644 --- a/editor.planx.uk/src/@planx/components/Section/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Section/Editor.tsx @@ -1,5 +1,5 @@ import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -9,6 +9,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import { parseSection, Section } from "./model"; type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/Section/Public.tsx b/editor.planx.uk/src/@planx/components/Section/Public.tsx index 48c8fb6b65..76224ea839 100644 --- a/editor.planx.uk/src/@planx/components/Section/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Section/Public.tsx @@ -4,7 +4,7 @@ import { styled } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; import visuallyHidden from "@mui/utils/visuallyHidden"; import Tag, { TagType } from "@planx/components/shared/Buttons/Tag"; -import type { PublicProps } from "@planx/components/ui"; +import type { PublicProps } from "@planx/components/shared/types"; import { useAnalyticsTracking } from "pages/FlowEditor/lib/analytics/provider"; import { Store, useStore } from "pages/FlowEditor/lib/store"; import React from "react"; diff --git a/editor.planx.uk/src/@planx/components/Send/Editor.tsx b/editor.planx.uk/src/@planx/components/Send/Editor.tsx index 867e55c9a6..6cad4a9328 100644 --- a/editor.planx.uk/src/@planx/components/Send/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Send/Editor.tsx @@ -16,9 +16,9 @@ import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; import { array, object } from "yup"; -import { EditorProps, ICONS } from "../ui"; -import { Send } from "./model"; -import { parseContent } from "./model"; +import { ICONS } from "../shared/icons"; +import { EditorProps } from "../shared/types"; +import { parseContent, Send } from "./model"; export type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/Send/Public.tsx b/editor.planx.uk/src/@planx/components/Send/Public.tsx index 42cb18de02..22cf28488d 100644 --- a/editor.planx.uk/src/@planx/components/Send/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Send/Public.tsx @@ -10,7 +10,7 @@ import { AsyncState } from "react-use/lib/useAsyncFn"; import Card from "../shared/Preview/Card"; import { WarningContainer } from "../shared/Preview/WarningContainer"; -import { PublicProps } from "../ui"; +import { PublicProps } from "../shared/types"; import { DEFAULT_DESTINATION, getCombinedEventsPayload, Send } from "./model"; /** Response returned by /create-send-events endpoint */ diff --git a/editor.planx.uk/src/@planx/components/SetValue/Editor.tsx b/editor.planx.uk/src/@planx/components/SetValue/Editor.tsx index a05222118a..6bf65d51ca 100644 --- a/editor.planx.uk/src/@planx/components/SetValue/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/SetValue/Editor.tsx @@ -3,7 +3,7 @@ import RadioGroup from "@mui/material/RadioGroup"; import Typography from "@mui/material/Typography"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import BasicRadio from "@planx/components/shared/Radio/BasicRadio"; -import { EditorProps } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; diff --git a/editor.planx.uk/src/@planx/components/SetValue/Public.tsx b/editor.planx.uk/src/@planx/components/SetValue/Public.tsx index 870d4b2948..c5484870d2 100644 --- a/editor.planx.uk/src/@planx/components/SetValue/Public.tsx +++ b/editor.planx.uk/src/@planx/components/SetValue/Public.tsx @@ -1,5 +1,5 @@ +import type { PublicProps } from "@planx/components/shared/types"; import { makeData } from "@planx/components/shared/utils"; -import type { PublicProps } from "@planx/components/ui"; import { useEffect } from "react"; import type { SetValue } from "./model"; diff --git a/editor.planx.uk/src/@planx/components/TaskList/Editor.tsx b/editor.planx.uk/src/@planx/components/TaskList/Editor.tsx index 5eab90d175..b4da1112b0 100644 --- a/editor.planx.uk/src/@planx/components/TaskList/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/TaskList/Editor.tsx @@ -1,8 +1,8 @@ import Box from "@mui/material/Box"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; +import { EditorProps } from "@planx/components/shared/types"; import type { Task, TaskList } from "@planx/components/TaskList/model"; import { parseTaskList } from "@planx/components/TaskList/model"; -import { EditorProps, ICONS } from "@planx/components/ui"; import { useFormik } from "formik"; import React, { ChangeEvent } from "react"; import ListManager, { @@ -15,6 +15,8 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; + export type Props = EditorProps; const newTask = (): Task => ({ diff --git a/editor.planx.uk/src/@planx/components/TaskList/Public.tsx b/editor.planx.uk/src/@planx/components/TaskList/Public.tsx index b348e7d72f..8dd61bc46b 100644 --- a/editor.planx.uk/src/@planx/components/TaskList/Public.tsx +++ b/editor.planx.uk/src/@planx/components/TaskList/Public.tsx @@ -1,7 +1,7 @@ import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; +import { PublicProps } from "@planx/components/shared/types"; import type { TaskList } from "@planx/components/TaskList/model"; -import { PublicProps } from "@planx/components/ui"; import React from "react"; import NumberedList from "ui/public/NumberedList"; diff --git a/editor.planx.uk/src/@planx/components/TextInput/Editor.tsx b/editor.planx.uk/src/@planx/components/TextInput/Editor.tsx index 769c36e57d..054c71f287 100644 --- a/editor.planx.uk/src/@planx/components/TextInput/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/TextInput/Editor.tsx @@ -2,7 +2,7 @@ import FormControl from "@mui/material/FormControl"; import RadioGroup from "@mui/material/RadioGroup"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; import BasicRadio from "@planx/components/shared/Radio/BasicRadio"; -import { EditorProps, ICONS } from "@planx/components/ui"; +import { EditorProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import { ModalFooter } from "ui/editor/ModalFooter"; @@ -12,6 +12,7 @@ import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; import Input from "ui/shared/Input/Input"; import InputRow from "ui/shared/InputRow"; +import { ICONS } from "../shared/icons"; import { parseTextInput, TextInput } from "./model"; export type Props = EditorProps; diff --git a/editor.planx.uk/src/@planx/components/TextInput/Public.tsx b/editor.planx.uk/src/@planx/components/TextInput/Public.tsx index ff97a75d91..1c7e885e8d 100644 --- a/editor.planx.uk/src/@planx/components/TextInput/Public.tsx +++ b/editor.planx.uk/src/@planx/components/TextInput/Public.tsx @@ -1,6 +1,6 @@ import Card from "@planx/components/shared/Preview/Card"; import { CardHeader } from "@planx/components/shared/Preview/CardHeader/CardHeader"; -import { PublicProps } from "@planx/components/ui"; +import { PublicProps } from "@planx/components/shared/types"; import { useFormik } from "formik"; import React from "react"; import InputLabel from "ui/public/InputLabel"; diff --git a/editor.planx.uk/src/@planx/components/fixtures/Wrapper.tsx b/editor.planx.uk/src/@planx/components/fixtures/Wrapper.tsx index 6a68513ae3..6bfd9381c3 100644 --- a/editor.planx.uk/src/@planx/components/fixtures/Wrapper.tsx +++ b/editor.planx.uk/src/@planx/components/fixtures/Wrapper.tsx @@ -1,5 +1,5 @@ import Button from "@mui/material/Button"; -import { EditorProps, PublicProps } from "@planx/components/ui"; +import { EditorProps, PublicProps } from "@planx/components/shared/types"; import React, { useState } from "react"; export default Wrapper; diff --git a/editor.planx.uk/src/@planx/components/shared/icons.tsx b/editor.planx.uk/src/@planx/components/shared/icons.tsx new file mode 100644 index 0000000000..8cb11eeed0 --- /dev/null +++ b/editor.planx.uk/src/@planx/components/shared/icons.tsx @@ -0,0 +1,70 @@ +import ArrowForwardIcon from "@mui/icons-material/ArrowForward"; +import Article from "@mui/icons-material/Article"; +import CallSplit from "@mui/icons-material/CallSplit"; +import CheckBoxOutlined from "@mui/icons-material/CheckBoxOutlined"; +import CloudUpload from "@mui/icons-material/CloudUpload"; +import ContactPage from "@mui/icons-material/ContactPage"; +import CopyAll from "@mui/icons-material/CopyAll"; +import Create from "@mui/icons-material/Create"; +import DoorFrontOutlined from "@mui/icons-material/DoorFrontOutlined"; +import Event from "@mui/icons-material/Event"; +import FilterAltOutlined from "@mui/icons-material/FilterAltOutlined"; +import FunctionsIcon from "@mui/icons-material/Functions"; +import Home from "@mui/icons-material/Home"; +import List from "@mui/icons-material/List"; +import ListAlt from "@mui/icons-material/ListAlt"; +import LocationOnOutlined from "@mui/icons-material/LocationOnOutlined"; +import Map from "@mui/icons-material/Map"; +import PaymentOutlined from "@mui/icons-material/PaymentOutlined"; +import Pin from "@mui/icons-material/Pin"; +import PlaylistAdd from "@mui/icons-material/PlaylistAdd"; +import PlaylistAddCheck from "@mui/icons-material/PlaylistAddCheck"; +import RateReviewOutlined from "@mui/icons-material/RateReviewOutlined"; +import ReportProblemOutlined from "@mui/icons-material/ReportProblemOutlined"; +import SearchOutlined from "@mui/icons-material/SearchOutlined"; +import Send from "@mui/icons-material/Send"; +import ShapeLine from "@mui/icons-material/ShapeLine"; +import SquareFoot from "@mui/icons-material/SquareFoot"; +import TextFields from "@mui/icons-material/TextFields"; +import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; + +// XXX: We define the Icon type in terms of one of the Icons so as not to have to repeat ourselves +type Icon = typeof CheckBoxOutlined; + +export const ICONS: { + [key in TYPES]: Icon | undefined; +} = { + [TYPES.AddressInput]: Home, + [TYPES.Calculate]: FunctionsIcon, + [TYPES.Checklist]: CheckBoxOutlined, + [TYPES.ContactInput]: ContactPage, + [TYPES.Content]: TextFields, + [TYPES.Confirmation]: TextFields, + [TYPES.DateInput]: Event, + [TYPES.DrawBoundary]: SquareFoot, + [TYPES.ExternalPortal]: CopyAll, + [TYPES.FileUpload]: CloudUpload, + [TYPES.FileUploadAndLabel]: CloudUpload, + [TYPES.Filter]: FilterAltOutlined, + [TYPES.FindProperty]: SearchOutlined, + [TYPES.Flow]: undefined, + [TYPES.InternalPortal]: DoorFrontOutlined, + [TYPES.List]: ListAlt, + [TYPES.MapAndLabel]: ShapeLine, + [TYPES.Notice]: ReportProblemOutlined, + [TYPES.NextSteps]: ArrowForwardIcon, + [TYPES.NumberInput]: Pin, + [TYPES.Page]: Article, + [TYPES.Pay]: PaymentOutlined, + [TYPES.PlanningConstraints]: Map, + [TYPES.PropertyInformation]: LocationOnOutlined, + [TYPES.Answer]: undefined, + [TYPES.Result]: PlaylistAddCheck, + [TYPES.Review]: RateReviewOutlined, + [TYPES.Section]: List, + [TYPES.Send]: Send, + [TYPES.SetValue]: PlaylistAdd, + [TYPES.Question]: CallSplit, + [TYPES.TaskList]: List, + [TYPES.TextInput]: Create, +} as const; diff --git a/editor.planx.uk/src/@planx/components/shared/types.tsx b/editor.planx.uk/src/@planx/components/shared/types.tsx new file mode 100644 index 0000000000..475a8a2e59 --- /dev/null +++ b/editor.planx.uk/src/@planx/components/shared/types.tsx @@ -0,0 +1,21 @@ +import { Store } from "pages/FlowEditor/lib/store"; +import type { HandleSubmit } from "pages/Preview/Node"; +import React from "react"; + +export interface EditorProps { + id?: string; + handleSubmit?: (data: { type: Type; data: Data }) => void; + node?: any; +} + +export type PublicProps = Data & { + id?: string; + handleSubmit?: HandleSubmit; + resetButton?: boolean; + resetPreview?: () => void; + autoFocus?: boolean; + previouslySubmittedData?: Store.UserData; +}; + +export const FormError: React.FC<{ message: string }> = ({ message }) => + message ? {message} : null; diff --git a/editor.planx.uk/src/@planx/components/ui.tsx b/editor.planx.uk/src/@planx/components/ui.tsx deleted file mode 100644 index 7018d6ed96..0000000000 --- a/editor.planx.uk/src/@planx/components/ui.tsx +++ /dev/null @@ -1,190 +0,0 @@ -import ArrowForwardIcon from "@mui/icons-material/ArrowForward"; -import Article from "@mui/icons-material/Article"; -import BorderColorIcon from "@mui/icons-material/BorderColor"; -import CallSplit from "@mui/icons-material/CallSplit"; -import CheckBoxOutlined from "@mui/icons-material/CheckBoxOutlined"; -import CloudUpload from "@mui/icons-material/CloudUpload"; -import ContactPage from "@mui/icons-material/ContactPage"; -import CopyAll from "@mui/icons-material/CopyAll"; -import Create from "@mui/icons-material/Create"; -import DoorFrontOutlined from "@mui/icons-material/DoorFrontOutlined"; -import Event from "@mui/icons-material/Event"; -import FilterAltOutlined from "@mui/icons-material/FilterAltOutlined"; -import FunctionsIcon from "@mui/icons-material/Functions"; -import Home from "@mui/icons-material/Home"; -import InfoOutlined from "@mui/icons-material/InfoOutlined"; -import List from "@mui/icons-material/List"; -import ListAlt from "@mui/icons-material/ListAlt"; -import LocationOnOutlined from "@mui/icons-material/LocationOnOutlined"; -import Map from "@mui/icons-material/Map"; -import PaymentOutlined from "@mui/icons-material/PaymentOutlined"; -import Pin from "@mui/icons-material/Pin"; -import PlaylistAdd from "@mui/icons-material/PlaylistAdd"; -import PlaylistAddCheck from "@mui/icons-material/PlaylistAddCheck"; -import RateReviewOutlined from "@mui/icons-material/RateReviewOutlined"; -import ReportProblemOutlined from "@mui/icons-material/ReportProblemOutlined"; -import SearchOutlined from "@mui/icons-material/SearchOutlined"; -import Send from "@mui/icons-material/Send"; -import ShapeLine from "@mui/icons-material/ShapeLine"; -import SquareFoot from "@mui/icons-material/SquareFoot"; -import TextFields from "@mui/icons-material/TextFields"; -import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { Store } from "pages/FlowEditor/lib/store"; -import type { HandleSubmit } from "pages/Preview/Node"; -import React, { ChangeEvent } from "react"; -import ImgInput from "ui/editor/ImgInput/ImgInput"; -import InputGroup from "ui/editor/InputGroup"; -import InputLabel from "ui/editor/InputLabel"; -import ModalSection from "ui/editor/ModalSection"; -import ModalSectionContent from "ui/editor/ModalSectionContent"; -import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; -import Input from "ui/shared/Input/Input"; -import InputRow from "ui/shared/InputRow"; - -export interface EditorProps { - id?: string; - handleSubmit?: (data: { type: Type; data: Data }) => void; - node?: any; -} - -export type PublicProps = Data & { - id?: string; - handleSubmit?: HandleSubmit; - resetButton?: boolean; - resetPreview?: () => void; - autoFocus?: boolean; - previouslySubmittedData?: Store.UserData; -}; - -// XXX: We define the Icon type in terms of one of the Icons so as not to have to repeat ourselves -type Icon = typeof CheckBoxOutlined; - -export const ICONS: { - [key in TYPES]: Icon | undefined; -} = { - [TYPES.AddressInput]: Home, - [TYPES.Calculate]: FunctionsIcon, - [TYPES.Checklist]: CheckBoxOutlined, - [TYPES.ContactInput]: ContactPage, - [TYPES.Content]: TextFields, - [TYPES.Confirmation]: TextFields, - [TYPES.DateInput]: Event, - [TYPES.DrawBoundary]: SquareFoot, - [TYPES.ExternalPortal]: CopyAll, - [TYPES.FileUpload]: CloudUpload, - [TYPES.FileUploadAndLabel]: CloudUpload, - [TYPES.Filter]: FilterAltOutlined, - [TYPES.FindProperty]: SearchOutlined, - [TYPES.Flow]: undefined, - [TYPES.InternalPortal]: DoorFrontOutlined, - [TYPES.List]: ListAlt, - [TYPES.MapAndLabel]: ShapeLine, - [TYPES.Notice]: ReportProblemOutlined, - [TYPES.NextSteps]: ArrowForwardIcon, - [TYPES.NumberInput]: Pin, - [TYPES.Page]: Article, - [TYPES.Pay]: PaymentOutlined, - [TYPES.PlanningConstraints]: Map, - [TYPES.PropertyInformation]: LocationOnOutlined, - [TYPES.Answer]: undefined, - [TYPES.Result]: PlaylistAddCheck, - [TYPES.Review]: RateReviewOutlined, - [TYPES.Section]: List, - [TYPES.Send]: Send, - [TYPES.SetValue]: PlaylistAdd, - [TYPES.Question]: CallSplit, - [TYPES.TaskList]: List, - [TYPES.TextInput]: Create, -} as const; - -interface MoreInformationProps { - changeField: (changes: any) => any; - howMeasured?: string; - policyRef?: string; - info?: string; - definitionImg?: string; -} - -export const MoreInformation = ({ - changeField, - definitionImg, - howMeasured, - policyRef, - info, -}: MoreInformationProps) => { - return ( - - - - - - - - - - - - - { - changeField({ - target: { name: "definitionImg", value: newUrl }, - }); - }} - /> - - - - - - ); -}; - -export interface InternalNotesProps { - name?: string; - value?: string; - onChange: (ev: ChangeEvent) => void; -} - -export const InternalNotes: React.FC = ({ - name, - value, - onChange, -}) => { - return ( - - - - - - - - ); -}; - -export const FormError: React.FC<{ message: string }> = ({ message }) => - message ? {message} : null; diff --git a/editor.planx.uk/src/pages/FlowEditor/components/Flow/components/Checklist.tsx b/editor.planx.uk/src/pages/FlowEditor/components/Flow/components/Checklist.tsx index f818d7210d..b56db2325c 100644 --- a/editor.planx.uk/src/pages/FlowEditor/components/Flow/components/Checklist.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/components/Flow/components/Checklist.tsx @@ -3,7 +3,7 @@ import { ComponentType as TYPES, NodeTags, } from "@opensystemslab/planx-core/types"; -import { ICONS } from "@planx/components/ui"; +import { ICONS } from "@planx/components/shared/icons"; import classNames from "classnames"; import mapAccum from "ramda/src/mapAccum"; import React, { useMemo } from "react"; @@ -94,11 +94,13 @@ const Checklist: React.FC = React.memo((props) => { onContextMenu={handleContext} ref={drag} > - + {props.data?.img && ( = { data: { fn: "completionDate", title: "Expected completion date", + description: "For example, 16 04 2027", }, type: "date", }, diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts index f71f85ade4..eabf4710cd 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/user.ts @@ -36,10 +36,10 @@ export const userStore: StateCreator< const user = get().getUser(); if (!user) return false; - const hasTeamEditorRole = (team: UserTeams) => - team.role === "teamEditor" && team.team.slug === teamSlug; + const canEditTeam = (team: UserTeams) => + team.role !== "teamViewer" && team.team.slug === teamSlug; - return user.isPlatformAdmin || user.teams.some(hasTeamEditorRole); + return user.isPlatformAdmin || user.teams.some(canEditTeam); }, async initUserStore() { diff --git a/editor.planx.uk/src/ui/editor/InternalNotes.tsx b/editor.planx.uk/src/ui/editor/InternalNotes.tsx new file mode 100644 index 0000000000..0ea5e00dc1 --- /dev/null +++ b/editor.planx.uk/src/ui/editor/InternalNotes.tsx @@ -0,0 +1,36 @@ +import BorderColorIcon from "@mui/icons-material/BorderColor"; +import React, { ChangeEvent } from "react"; +import ModalSection from "ui/editor/ModalSection"; +import ModalSectionContent from "ui/editor/ModalSectionContent"; +import Input from "ui/shared/Input/Input"; +import InputRow from "ui/shared/InputRow"; + +export interface InternalNotesProps { + name?: string; + value?: string; + onChange: (ev: ChangeEvent) => void; +} + +export const InternalNotes: React.FC = ({ + name, + value, + onChange, +}) => { + return ( + + + + + + + + ); +}; diff --git a/editor.planx.uk/src/ui/editor/ModalFooter.tsx b/editor.planx.uk/src/ui/editor/ModalFooter.tsx index 07fb31f349..119096ac87 100644 --- a/editor.planx.uk/src/ui/editor/ModalFooter.tsx +++ b/editor.planx.uk/src/ui/editor/ModalFooter.tsx @@ -1,7 +1,8 @@ import { BaseNodeData } from "@planx/components/shared"; -import { InternalNotes, MoreInformation } from "@planx/components/ui"; import { useFormik } from "formik"; import React from "react"; +import { InternalNotes } from "ui/editor/InternalNotes"; +import { MoreInformation } from "ui/editor/MoreInformation/MoreInformation"; import { ComponentTagSelect } from "./ComponentTagSelect"; diff --git a/editor.planx.uk/src/ui/editor/MoreInformation/MoreInformation.tsx b/editor.planx.uk/src/ui/editor/MoreInformation/MoreInformation.tsx new file mode 100644 index 0000000000..d0eaf5e709 --- /dev/null +++ b/editor.planx.uk/src/ui/editor/MoreInformation/MoreInformation.tsx @@ -0,0 +1,60 @@ +import InfoOutlined from "@mui/icons-material/InfoOutlined"; +import React from "react"; +import ImgInput from "ui/editor/ImgInput/ImgInput"; +import InputGroup from "ui/editor/InputGroup"; +import InputLabel from "ui/editor/InputLabel"; +import ModalSection from "ui/editor/ModalSection"; +import ModalSectionContent from "ui/editor/ModalSectionContent"; +import RichTextInput from "ui/editor/RichTextInput/RichTextInput"; +import InputRow from "ui/shared/InputRow"; + +export const MoreInformation = ({ + changeField, + definitionImg, + howMeasured, + policyRef, + info, +}: MoreInformationProps) => { + return ( + + + + + + + + + + + + + { + changeField({ + target: { name: "definitionImg", value: newUrl }, + }); + }} + /> + + + + + + ); +}; diff --git a/editor.planx.uk/src/ui/editor/MoreInformation/types.ts b/editor.planx.uk/src/ui/editor/MoreInformation/types.ts new file mode 100644 index 0000000000..c3f4b90c78 --- /dev/null +++ b/editor.planx.uk/src/ui/editor/MoreInformation/types.ts @@ -0,0 +1,7 @@ +interface MoreInformationProps { + changeField: (changes: any) => any; + howMeasured?: string; + policyRef?: string; + info?: string; + definitionImg?: string; +} diff --git a/hasura.planx.uk/metadata/tables.yaml b/hasura.planx.uk/metadata/tables.yaml index b24e87efbb..f1b5797f3f 100644 --- a/hasura.planx.uk/metadata/tables.yaml +++ b/hasura.planx.uk/metadata/tables.yaml @@ -589,6 +589,7 @@ - role: demoUser permission: columns: + - analytics_link - created_at - creator_id - data @@ -1075,8 +1076,15 @@ check: flow: creator_id: - _eq: x-hausra-user-id - columns: [] + _eq: x-hasura-user-id + columns: + - id + - actor_id + - version + - data + - created_at + - updated_at + - flow_id comment: "" - role: platformAdmin permission: @@ -1146,11 +1154,18 @@ update_permissions: - role: demoUser permission: - columns: [] + columns: + - id + - actor_id + - version + - data + - created_at + - updated_at + - flow_id filter: flow: creator_id: - _eq: x-hausra-user-id + _eq: x-hasura-user-id check: null comment: "" - role: platformAdmin @@ -1960,6 +1975,17 @@ - role - id filter: {} + - role: demoUser + permission: + columns: + - team_id + - user_id + - role + - id + filter: + user_id: + _eq: x-hasura-user-id + comment: "" - role: platformAdmin permission: columns: @@ -2037,6 +2063,24 @@ - team_id filter: {} comment: "" + - role: demoUser + permission: + columns: + - id + - external_planning_site_name + - external_planning_site_url + - homepage + - help_email + - help_opening_hours + - help_phone + - email_reply_to_id + - team_id + - boundary_bbox + - submission_email + - reference_code + - boundary_url + filter: {} + comment: "" - role: platformAdmin permission: columns: diff --git a/hasura.planx.uk/tests/team_members.test.js b/hasura.planx.uk/tests/team_members.test.js index f46b3609dd..5a0c47f81f 100644 --- a/hasura.planx.uk/tests/team_members.test.js +++ b/hasura.planx.uk/tests/team_members.test.js @@ -66,8 +66,8 @@ describe("team_members", () => { i = await introspectAs("demoUser"); }); - test("cannot query teams", () => { - expect(i.queries).not.toContain("team_members"); + test("can query teams", () => { + expect(i.queries).toContain("team_members"); }); test("cannot create, update, or delete team_members", () => {