diff --git a/h/models/feature.py b/h/models/feature.py index 3c06d855d63..b59edb8f480 100644 --- a/h/models/feature.py +++ b/h/models/feature.py @@ -15,6 +15,7 @@ "pdf_custom_text_layer": "Use custom text layer in PDFs for improved text selection", "styled_highlight_clusters": "Style different clusters of highlights in the client", "client_user_profile": "Enable client-side user profile and preferences management", + "group_type": "Allow users to choose group type in group creation form", } diff --git a/h/static/scripts/group-forms/components/CreateEditGroupForm.tsx b/h/static/scripts/group-forms/components/CreateEditGroupForm.tsx index 7ec4f9feed5..3045e585bf8 100644 --- a/h/static/scripts/group-forms/components/CreateEditGroupForm.tsx +++ b/h/static/scripts/group-forms/components/CreateEditGroupForm.tsx @@ -216,10 +216,19 @@ export default function CreateEditGroupForm() { onSubmit = createGroup; } + let heading; + if (group) { + heading = 'Edit group'; + } else if (config.features.group_type) { + heading = 'Create a new group'; + } else { + heading = 'Create a new private group'; + } + return (

- {group ? 'Edit group' : 'Create a new private group'} + {heading}

diff --git a/h/static/scripts/group-forms/components/test/CreateEditGroupForm-test.js b/h/static/scripts/group-forms/components/test/CreateEditGroupForm-test.js index 9c65476f31a..eeedb8715a1 100644 --- a/h/static/scripts/group-forms/components/test/CreateEditGroupForm-test.js +++ b/h/static/scripts/group-forms/components/test/CreateEditGroupForm-test.js @@ -28,6 +28,9 @@ describe('CreateEditGroupForm', () => { context: { group: null, }, + features: { + group_type: false, + }, }; fakeCallAPI = sinon.stub(); @@ -187,21 +190,34 @@ describe('CreateEditGroupForm', () => { }); }); - it('displays a create-new-group form', async () => { - const { wrapper, elements } = createWrapper(); - const headerEl = elements.header.element; - const nameEl = elements.name.fieldEl; - const descriptionEl = elements.description.fieldEl; - const submitButtonEl = elements.submitButton.element; - - assert.equal(headerEl.text(), 'Create a new private group'); - assert.equal(nameEl.getDOMNode().value, ''); - assert.equal(descriptionEl.getDOMNode().value, ''); - assert.equal(submitButtonEl.text(), 'Create group'); - assert.isFalse(wrapper.exists('[data-testid="back-link"]')); - assert.isFalse(wrapper.exists('[data-testid="error-message"]')); - await assertInLoadingState(wrapper, false); - assert.isFalse(savedConfirmationShowing(wrapper)); + [ + { + groupTypeFlag: true, + heading: 'Create a new group', + }, + { + groupTypeFlag: false, + heading: 'Create a new private group', + }, + ].forEach(({ groupTypeFlag, heading }) => { + it('displays a create-new-group form', async () => { + config.features.group_type = groupTypeFlag; + + const { wrapper, elements } = createWrapper(); + const headerEl = elements.header.element; + const nameEl = elements.name.fieldEl; + const descriptionEl = elements.description.fieldEl; + const submitButtonEl = elements.submitButton.element; + + assert.equal(headerEl.text(), heading); + assert.equal(nameEl.getDOMNode().value, ''); + assert.equal(descriptionEl.getDOMNode().value, ''); + assert.equal(submitButtonEl.text(), 'Create group'); + assert.isFalse(wrapper.exists('[data-testid="back-link"]')); + assert.isFalse(wrapper.exists('[data-testid="error-message"]')); + await assertInLoadingState(wrapper, false); + assert.isFalse(savedConfirmationShowing(wrapper)); + }); }); it('does not warn when leaving page if there are unsaved changes', () => { diff --git a/h/static/scripts/group-forms/config.ts b/h/static/scripts/group-forms/config.ts index 11bf1f64388..f7a9410bbbd 100644 --- a/h/static/scripts/group-forms/config.ts +++ b/h/static/scripts/group-forms/config.ts @@ -19,6 +19,9 @@ export type ConfigObject = { link: string; } | null; }; + features: { + group_type: boolean; + }; }; /** Return the frontend config from the page's