diff --git a/editor.planx.uk/src/@planx/components/Send/Public.tsx b/editor.planx.uk/src/@planx/components/Send/Public.tsx index a61699f0a8..898b1672f4 100644 --- a/editor.planx.uk/src/@planx/components/Send/Public.tsx +++ b/editor.planx.uk/src/@planx/components/Send/Public.tsx @@ -1,5 +1,6 @@ import axios from "axios"; import DelayedLoadingIndicator from "components/DelayedLoadingIndicator"; +import { hasFeatureFlag } from "lib/featureFlags"; import { useStore } from "pages/FlowEditor/lib/store"; import React, { useEffect } from "react"; import { useAsync } from "react-use"; @@ -19,6 +20,33 @@ export type Props = PublicProps; const SendComponent: React.FC = ({ destinations = [DEFAULT_DESTINATION], ...props +}) => { + // If testing with the feature flag, skip scheduled event creation because no stored lowcal_session to generate payloads + const testSession = hasFeatureFlag("DISABLE_SAVE_AND_RETURN"); + + useEffect(() => { + if (testSession) { + props.handleSubmit?.({ + ...makeData(props, true, "skippedEvents"), + auto: true, + }); + } + }, []); + + if (testSession) { + return ( + + + + ); + } else { + return ; + } +}; + +const SendEvents: React.FC = ({ + destinations = [DEFAULT_DESTINATION], + ...props }) => { const [passport, sessionId, teamSlug] = useStore((state) => [ state.computePassport(), diff --git a/editor.planx.uk/src/components/FeatureFlagBanner.tsx b/editor.planx.uk/src/components/FeatureFlagBanner.tsx new file mode 100644 index 0000000000..2ef337a446 --- /dev/null +++ b/editor.planx.uk/src/components/FeatureFlagBanner.tsx @@ -0,0 +1,54 @@ +import ReportIcon from "@mui/icons-material/Report"; +import Box from "@mui/material/Box"; +import Button from "@mui/material/Button"; +import Container from "@mui/material/Container"; +import { styled } from "@mui/material/styles"; +import Typography from "@mui/material/Typography"; +import { hasFeatureFlag } from "lib/featureFlags"; +import React, { useState } from "react"; + +const TestEnvironmentWarning = styled(Box)(({ theme }) => ({ + display: "flex", + backgroundColor: theme.palette.background.paper, + color: theme.palette.text.primary, + justifyContent: "space-between", + alignItems: "center", + padding: "0.2em 0", +})); + +const FeatureFlagBanner: React.FC = () => { + const [showWarning, setShowWarning] = useState(true); + + const isUsingFeatureFlag = () => hasFeatureFlag("DISABLE_SAVE_AND_RETURN"); + + return ( + <> + {isUsingFeatureFlag() && showWarning && ( + + + + + + You have disabled save and return via feature + flag. This means you cannot save or submit your test + applications. + + + + + + )} + + ); +}; + +export default FeatureFlagBanner; diff --git a/editor.planx.uk/src/components/Header.tsx b/editor.planx.uk/src/components/Header.tsx index 05a2af7dce..5a2fd1aba7 100644 --- a/editor.planx.uk/src/components/Header.tsx +++ b/editor.planx.uk/src/components/Header.tsx @@ -42,6 +42,7 @@ import Reset from "ui/icons/Reset"; import { useStore } from "../pages/FlowEditor/lib/store"; import { rootFlowPath } from "../routes/utils"; import AnalyticsDisabledBanner from "./AnalyticsDisabledBanner"; +import FeatureFlagBanner from "./FeatureFlagBanner"; import TestEnvironmentBanner from "./TestEnvironmentBanner"; export const HEADER_HEIGHT = 74; @@ -376,6 +377,7 @@ const PublicToolbar: React.FC<{ + ); }; diff --git a/scripts/seed-database/write/flows.sql b/scripts/seed-database/write/flows.sql index 035dcb620a..aedfed890b 100644 --- a/scripts/seed-database/write/flows.sql +++ b/scripts/seed-database/write/flows.sql @@ -24,7 +24,7 @@ INSERT INTO flows ( version, settings, copied_from, - null as analytics_link, + analytics_link ) SELECT id, @@ -35,7 +35,7 @@ SELECT version, settings, copied_from, - analytics_link + NULL FROM sync_flows ON CONFLICT (id) DO UPDATE SET @@ -46,7 +46,7 @@ SET version = EXCLUDED.version, settings = EXCLUDED.settings, copied_from = EXCLUDED.copied_from, - analytics_link = null; + analytics_link = NULL; -- ensure that original flows.version is overwritten to match new operation inserted below, else sharedb will fail UPDATE flows SET version = 1;