Skip to content

Commit

Permalink
Add checkbox for adding tutorials when creating new space and fix UI …
Browse files Browse the repository at this point in the history
…issue in Mozilla regarding the URL input (#7447)
  • Loading branch information
reactoholic authored Jan 17, 2025
1 parent a393c76 commit 40d077b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/core/i18n/en/translation.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,7 @@
},
"createSpace": {
"title": "Create a Space",
"addTutorialsLabel": "Show Tutorials in this Space",
"terms": {
"checkboxLabel": "I have read and accept the <terms>terms and agreements (click here to open them)</terms> for creating a Space.",
"dialogTitle": "Terms and Conditions for creating a Space",
Expand Down
1 change: 1 addition & 0 deletions src/core/utils/nameId/NameIdField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const NameIdField = ({
<FormikInputField
{...props}
name={name}
sx={{ whiteSpace: 'nowrap' }}
onBlur={() => setIsTouchedByUser(true)}
InputProps={{
startAdornment: <Typography color="neutral.light">{`${origin}/`}</Typography>,
Expand Down
64 changes: 39 additions & 25 deletions src/domain/journey/space/createSpace/CreateSpaceDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Loading from '@/core/ui/loading/Loading';
import { TagCategoryValues, info } from '@/core/logging/sentry/log';
import { compact } from 'lodash';
import { useNotification } from '@/core/ui/notifications/useNotification';
import Gutters from '@/core/ui/grid/Gutters';

interface FormValues extends SpaceEditFormValuesType {
licensePlanId: string;
Expand Down Expand Up @@ -100,6 +101,7 @@ const CreateSpaceDialog = ({ redirectOnComplete = true, onClose, account }: Crea
const { accountId: currentUserAccountId } = useUserContext();

const [hasAcceptedTerms, setHasAcceptedTerms] = useState(false);
const [addTutorialCallouts, setAddTutorialCallouts] = useState(true);

const [isTermsDialogOpen, setIsTermsDialogOpen] = useState(false);

Expand Down Expand Up @@ -129,6 +131,7 @@ const CreateSpaceDialog = ({ redirectOnComplete = true, onClose, account }: Crea
},
collaborationData: {
calloutsSetData: {},
addTutorialCallouts,
},
tags: compact(values.tagsets?.reduce((acc: string[], tagset) => [...acc, ...tagset.tags], [])),
licensePlanID: values.licensePlanId,
Expand Down Expand Up @@ -198,31 +201,42 @@ const CreateSpaceDialog = ({ redirectOnComplete = true, onClose, account }: Crea
maxLength={SMALL_TEXT_LENGTH}
/>
<TagsetSegment title={`${t('common.tags')} (${t('common.optional')})`} tagsets={tagsets} />
<FormControlLabel
value={hasAcceptedTerms}
onChange={(event, isChecked) => setHasAcceptedTerms(isChecked)}
required
control={<Checkbox />}
label={
<Caption>
<Trans
i18nKey="createSpace.terms.checkboxLabel"
components={{
terms: (
<Link
underline="always"
onClick={event => {
event.stopPropagation();
event.preventDefault();
setIsTermsDialogOpen(true);
}}
/>
),
}}
/>
</Caption>
}
/>

<Gutters disableGap disablePadding>
<FormControlLabel
value={addTutorialCallouts}
onChange={(event, isChecked) => setAddTutorialCallouts(isChecked)}
control={<Checkbox />}
label={<Caption>{t('createSpace.addTutorialsLabel')}</Caption>}
/>

<FormControlLabel
value={hasAcceptedTerms}
onChange={(event, isChecked) => setHasAcceptedTerms(isChecked)}
required
control={<Checkbox />}
label={
<Caption>
<Trans
i18nKey="createSpace.terms.checkboxLabel"
components={{
terms: (
<Link
underline="always"
onClick={event => {
event.stopPropagation();
event.preventDefault();
setIsTermsDialogOpen(true);
}}
/>
),
}}
/>
</Caption>
}
/>
</Gutters>

<DialogFooter>
<Actions justifyContent="end" padding={gutters()}>
<Button
Expand Down

0 comments on commit 40d077b

Please sign in to comment.