Skip to content

Commit

Permalink
Settings options (#8996)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillim authored Dec 10, 2024
1 parent 0a8960c commit afd3252
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from '@emotion/styled';

const StyledHr = styled.hr`
border: none;
border-top: 1px solid ${({ theme }) => theme.border.color.light};
margin: 0px;
margin-left: ${({ theme }) => theme.spacing(4)};
margin-right: ${({ theme }) => theme.spacing(4)};
`;

export const Separator = () => {
return <StyledHr />;
};
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import styled from '@emotion/styled';
import { CardContent } from 'twenty-ui';

type StyledCardContentProps = {
disabled?: boolean;
divider?: boolean;
};

export const StyledSettingsOptionCardContent = styled(
CardContent,
)<StyledCardContentProps>`
export const StyledSettingsOptionCardContent = styled.div<StyledCardContentProps>`
align-items: center;
display: flex;
gap: ${({ theme }) => theme.spacing(3)};
background-color: ${({ theme }) => theme.background.secondary};
padding: ${({ theme }) => theme.spacing(4)};
`;
export const StyledSettingsOptionCardIcon = styled.div`
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type SettingsOptionCardContentCounterProps = {
Icon?: IconComponent;
title: React.ReactNode;
description?: string;
divider?: boolean;
disabled?: boolean;
value: number;
onChange: (value: number) => void;
Expand All @@ -24,15 +23,14 @@ export const SettingsOptionCardContentCounter = ({
Icon,
title,
description,
divider,
disabled = false,
value,
onChange,
minValue,
maxValue,
}: SettingsOptionCardContentCounterProps) => {
return (
<StyledSettingsOptionCardContent divider={divider} disabled={disabled}>
<StyledSettingsOptionCardContent disabled={disabled}>
{Icon && (
<StyledSettingsOptionCardIcon>
<SettingsOptionIconCustomizer Icon={Icon} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ type SettingsOptionCardContentSelectProps = {
Icon?: IconComponent;
title: React.ReactNode;
description?: string;
divider?: boolean;
disabled?: boolean;
selectClassName?: string;
children?: React.ReactNode;
};

Expand All @@ -26,12 +24,11 @@ export const SettingsOptionCardContentSelect = ({
Icon,
title,
description,
divider,
disabled = false,
children,
}: SettingsOptionCardContentSelectProps) => {
return (
<StyledSettingsOptionCardContent divider={divider} disabled={disabled}>
<StyledSettingsOptionCardContent disabled={disabled}>
{Icon && (
<StyledSettingsOptionCardIcon>
<SettingsOptionIconCustomizer Icon={Icon} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Separator } from '@/settings/components/Separator';
import {
StyledSettingsOptionCardContent,
StyledSettingsOptionCardDescription,
Expand Down Expand Up @@ -57,34 +58,34 @@ export const SettingsOptionCardContentToggle = ({
const toggleId = useId();

return (
<StyledSettingsOptionCardToggleContent
divider={divider}
disabled={disabled}
>
{Icon && (
<StyledSettingsOptionCardIcon>
<SettingsOptionIconCustomizer Icon={Icon} />
</StyledSettingsOptionCardIcon>
)}
<div>
<StyledSettingsOptionCardTitle>
<label htmlFor={toggleId}>
{title}
<StyledSettingsOptionCardToggleCover />
</label>
</StyledSettingsOptionCardTitle>
<StyledSettingsOptionCardDescription>
{description}
</StyledSettingsOptionCardDescription>
</div>
<StyledSettingsOptionCardToggleButton
id={toggleId}
value={checked}
onChange={onChange}
disabled={disabled}
toggleSize="small"
color={advancedMode ? theme.color.yellow : theme.color.blue}
/>
</StyledSettingsOptionCardToggleContent>
<>
<StyledSettingsOptionCardToggleContent disabled={disabled}>
{Icon && (
<StyledSettingsOptionCardIcon>
<SettingsOptionIconCustomizer Icon={Icon} />
</StyledSettingsOptionCardIcon>
)}
<div>
<StyledSettingsOptionCardTitle>
<label htmlFor={toggleId}>
{title}
<StyledSettingsOptionCardToggleCover />
</label>
</StyledSettingsOptionCardTitle>
<StyledSettingsOptionCardDescription>
{description}
</StyledSettingsOptionCardDescription>
</div>
<StyledSettingsOptionCardToggleButton
id={toggleId}
value={checked}
onChange={onChange}
disabled={disabled}
toggleSize="small"
color={advancedMode ? theme.color.yellow : theme.color.blue}
/>
</StyledSettingsOptionCardToggleContent>
{divider && <Separator />}
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const SettingsOptionCardContentCounterWrapper = (
Icon={args.Icon}
title={args.title}
description={args.description}
divider={args.divider}
disabled={args.disabled}
minValue={args.minValue}
maxValue={args.maxValue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from 'zod';

import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { numberFieldDefaultValueSchema } from '@/object-record/record-field/validation-schemas/numberFieldDefaultValueSchema';
import { Separator } from '@/settings/components/Separator';
import { SettingsOptionCardContentCounter } from '@/settings/components/SettingsOptions/SettingsOptionCardContentCounter';
import { SettingsOptionCardContentSelect } from '@/settings/components/SettingsOptions/SettingsOptionCardContentSelect';
import { Select } from '@/ui/input/components/Select';
Expand Down Expand Up @@ -72,6 +73,7 @@ export const SettingsDataModelFieldNumberForm = ({
]}
/>
</SettingsOptionCardContentSelect>
<Separator />
<SettingsOptionCardContentCounter
Icon={IconDecimal}
title="Number of decimals"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { SettingsOptionCardContentToggle } from '@/settings/components/SettingsOptions/SettingsOptionCardContentToggle';
import { SSOIdentitiesProvidersState } from '@/settings/security/states/SSOIdentitiesProvidersState';
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import styled from '@emotion/styled';
import { useRecoilState, useRecoilValue } from 'recoil';
import {
IconLink,
Card,
IconGoogle,
IconLink,
IconMicrosoft,
IconPassword,
} from 'twenty-ui';
import { useUpdateWorkspaceMutation } from '~/generated/graphql';
import { AuthProviders } from '~/generated-metadata/graphql';
import { useUpdateWorkspaceMutation } from '~/generated/graphql';
import { capitalize } from '~/utils/string/capitalize';
import { SSOIdentitiesProvidersState } from '@/settings/security/states/SSOIdentitiesProvidersState';

const StyledSettingsSecurityOptionsList = styled.div`
display: flex;
Expand Down Expand Up @@ -122,13 +122,14 @@ export const SettingsSecurityOptionsList = () => {
<StyledSettingsSecurityOptionsList>
{currentWorkspace && (
<>
<Card>
<Card rounded>
<SettingsOptionCardContentToggle
Icon={IconGoogle}
title="Google"
description="Allow logins through Google's single sign-on functionality."
checked={currentWorkspace.isGoogleAuthEnabled}
advancedMode
divider
onChange={() => toggleAuthMethod('google')}
/>
<SettingsOptionCardContentToggle
Expand All @@ -137,6 +138,7 @@ export const SettingsSecurityOptionsList = () => {
description="Allow logins through Microsoft's single sign-on functionality."
checked={currentWorkspace.isMicrosoftAuthEnabled}
advancedMode
divider
onChange={() => toggleAuthMethod('microsoft')}
/>
<SettingsOptionCardContentToggle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const SettingsWorkspaceMembers = () => {
)}
<Section>
<H2Title
title="Members"
title="Manage Members"
description="Manage the members of your space here"
/>
<Table>
Expand Down

0 comments on commit afd3252

Please sign in to comment.