Skip to content

Commit

Permalink
chore: Drop GOVPAY_METADATA feature flag (#2915)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Apr 10, 2024
1 parent 7d900da commit 6ed961e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 80 deletions.
3 changes: 0 additions & 3 deletions editor.planx.uk/src/@planx/components/Pay/Editor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ describe("Pay component - Editor Modal", () => {
describe("GOV.UK Pay Metadata section", () => {
jest.setTimeout(20000);

beforeAll(() => toggleFeatureFlag("GOVPAY_METADATA"));
afterAll(() => toggleFeatureFlag("GOVPAY_METADATA"));

// Set up mock state with platformAdmin user so all Editor features are enabled
const { getState, setState } = vanillaStore;
const mockUser: User = {
Expand Down
140 changes: 68 additions & 72 deletions editor.planx.uk/src/@planx/components/Pay/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
MoreInformation,
} from "@planx/components/ui";
import { Form, Formik, useFormikContext } from "formik";
import { hasFeatureFlag } from "lib/featureFlags";
import { useStore } from "pages/FlowEditor/lib/store";
import React from "react";
import ListManager, {
Expand Down Expand Up @@ -132,7 +131,6 @@ export type Props = EditorProps<TYPES.Pay, Pay>;

const Component: React.FC<Props> = (props: Props) => {
const [flowName] = useStore((store) => [store.flowName]);
const displayGovPayMetadataSection = hasFeatureFlag("GOVPAY_METADATA");

const initialValues: Pay = {
title: props.node?.data?.title || "Pay for your application",
Expand Down Expand Up @@ -269,79 +267,77 @@ const Component: React.FC<Props> = (props: Props) => {
Hide the pay buttons and show fee for information only
</OptionButton>
</ModalSection>
{displayGovPayMetadataSection && (
<ModalSection>
<ModalSectionContent
title="GOV.UK Pay Metadata"
Icon={DataObjectIcon}
<ModalSection>
<ModalSectionContent
title="GOV.UK Pay Metadata"
Icon={DataObjectIcon}
>
<Typography variant="subtitle2" sx={{ mb: 2 }}>
Include metadata alongside payments, such as VAT codes, cost
centers, or ledger codes. See{" "}
<Link
href={GOVPAY_DOCS_URL}
target="_blank"
rel="noopener noreferrer"
>
GOV.UK Pay documentation
</Link>{" "}
for more details.
</Typography>
<ErrorWrapper
error={
typeof errors.govPayMetadata === "string" &&
touched.govPayMetadata
? errors.govPayMetadata
: undefined
}
>
<Typography variant="subtitle2" sx={{ mb: 2 }}>
Include metadata alongside payments, such as VAT codes, cost
centers, or ledger codes. See{" "}
<Link
href={GOVPAY_DOCS_URL}
target="_blank"
rel="noopener noreferrer"
<>
<Box
sx={{
width: "100%",
mb: 1,
display: "flex",
justifyContent: "space-evenly",
}}
>
GOV.UK Pay documentation
</Link>{" "}
for more details.
</Typography>
<ErrorWrapper
error={
typeof errors.govPayMetadata === "string" &&
touched.govPayMetadata
? errors.govPayMetadata
: undefined
}
>
<>
<Box
sx={{
width: "100%",
mb: 1,
display: "flex",
justifyContent: "space-evenly",
}}
<Typography
sx={{ width: "100%", ml: 5 }}
variant="subtitle2"
component="label"
id="key-label"
>
<Typography
sx={{ width: "100%", ml: 5 }}
variant="subtitle2"
component="label"
id="key-label"
>
Key
</Typography>
<Typography
sx={{ width: "100%", ml: -5 }}
variant="subtitle2"
component="label"
id="value-label"
>
Value
</Typography>
</Box>
<ListManager
maxItems={10}
disableDragAndDrop
values={values.govPayMetadata || []}
onChange={(metadata) => {
setFieldValue("govPayMetadata", metadata);
}}
Editor={GovPayMetadataEditor}
newValue={() => {
setTouched({});
return { key: "", value: "" };
}}
isFieldDisabled={({ key }, index) =>
isFieldDisabled(key, index)
}
/>
</>
</ErrorWrapper>
</ModalSectionContent>
</ModalSection>
)}
Key
</Typography>
<Typography
sx={{ width: "100%", ml: -5 }}
variant="subtitle2"
component="label"
id="value-label"
>
Value
</Typography>
</Box>
<ListManager
maxItems={10}
disableDragAndDrop
values={values.govPayMetadata || []}
onChange={(metadata) => {
setFieldValue("govPayMetadata", metadata);
}}
Editor={GovPayMetadataEditor}
newValue={() => {
setTouched({});
return { key: "", value: "" };
}}
isFieldDisabled={({ key }, index) =>
isFieldDisabled(key, index)
}
/>
</>
</ErrorWrapper>
</ModalSectionContent>
</ModalSection>
<ModalSection>
<ModalSectionContent title="Invite to Pay" Icon={ICONS[TYPES.Pay]}>
<OptionButton
Expand Down
10 changes: 5 additions & 5 deletions editor.planx.uk/src/lib/featureFlags.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// add/edit/remove feature flags in array below
const AVAILABLE_FEATURE_FLAGS = ["GOVPAY_METADATA"] as const;
const AVAILABLE_FEATURE_FLAGS = [] as const;

type FeatureFlag = (typeof AVAILABLE_FEATURE_FLAGS)[number];

Expand All @@ -25,7 +25,7 @@ const activeFeatureFlags = (() => {
*/
export const toggleFeatureFlag = (
featureFlag: FeatureFlag,
autoReload = true,
autoReload = true
) => {
const supportedFlag = AVAILABLE_FEATURE_FLAGS.includes(featureFlag);

Expand All @@ -35,13 +35,13 @@ export const toggleFeatureFlag = (
activeFeatureFlags.add(featureFlag);
} else {
throw new Error(
`${featureFlag} is not a supported feature flag, try again. Available flags are: ${AVAILABLE_FEATURE_FLAGS}`,
`${featureFlag} is not a supported feature flag, try again. Available flags are: ${AVAILABLE_FEATURE_FLAGS}`
);
}

localStorage.setItem(
"FEATURE_FLAGS",
JSON.stringify(Array.from(activeFeatureFlags)),
JSON.stringify(Array.from(activeFeatureFlags))
);

if (autoReload) window.location.reload();
Expand Down Expand Up @@ -71,6 +71,6 @@ if (process.env.REACT_APP_ENV !== "test") {
]
.sort()
.join(", ")}`
: `🎏 no active feature flags`,
: `🎏 no active feature flags`
);
}

0 comments on commit 6ed961e

Please sign in to comment.