Skip to content

The open alternative to Salesforce, designed for AI.

Align settings switches and complete feature flag labels (#27370)

Thomas des Francs7008b9a1cba8
diff --git a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx
index e00d10b1dd4..e034cb86bdc 100644
--- a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx
+++ b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventComposerFields.tsx
@@ -28,10 +28,6 @@ import { themeCssVariables } from 'twenty-ui/theme';
const COMPOSER_LABEL_MIN_WIDTH = '80px';
-const StyledSwitch = styled(Switch)`
- align-self: center;
-`;
-
const StyledFieldsContainer = styled.div`
display: flex;
flex: 1;
@@ -170,7 +166,7 @@ export const CalendarEventComposerFields = ({
composerState.handleIsFullDayChange(!composerState.isFullDay)
}
trailing={
- <StyledSwitch
+ <Switch
aria-label={t`All day`}
size="sm"
checked={composerState.isFullDay}
@@ -255,7 +251,7 @@ export const CalendarEventComposerFields = ({
composerState.setSendInvitations(!composerState.sendInvitations)
}
trailing={
- <StyledSwitch
+ <Switch
aria-label={t`Send invitations`}
size="sm"
checked={composerState.sendInvitations}
@@ -274,7 +270,7 @@ export const CalendarEventComposerFields = ({
composerState.setAddConferencing(!composerState.addConferencing)
}
trailing={
- <StyledSwitch
+ <Switch
aria-label={t`Video conferencing`}
size="sm"
checked={composerState.addConferencing}
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/constants/SettingsAdminFeatureFlagMetadata.ts b/packages/twenty-front/src/modules/settings/admin-panel/constants/SettingsAdminFeatureFlagMetadata.ts
index bab34854424..db774e8772c 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/constants/SettingsAdminFeatureFlagMetadata.ts
+++ b/packages/twenty-front/src/modules/settings/admin-panel/constants/SettingsAdminFeatureFlagMetadata.ts
@@ -4,11 +4,9 @@ import { msg } from '@lingui/core/macro';
import { FeatureFlagKey } from '~/generated-admin/graphql';
// Public flags use server-provided client config metadata to stay consistent with the lab.
-export const SETTINGS_ADMIN_FEATURE_FLAG_METADATA: Partial<
- Record<
- FeatureFlagKey,
- { label: MessageDescriptor; description: MessageDescriptor }
- >
+export const SETTINGS_ADMIN_FEATURE_FLAG_METADATA: Record<
+ FeatureFlagKey,
+ { label: MessageDescriptor; description: MessageDescriptor }
> = {
[FeatureFlagKey.IS_ASYNC_CSV_EXPORT_ENABLED]: {
label: msg`Async CSV export`,
@@ -42,10 +40,18 @@ export const SETTINGS_ADMIN_FEATURE_FLAG_METADATA: Partial<
label: msg`AI chat sharing dropdown`,
description: msg`Show the sharing dropdown on AI conversations when record sharing is enabled.`,
},
+ [FeatureFlagKey.IS_INITIAL_OBJECT_VIEW_ENABLED]: {
+ label: msg`Initial object views`,
+ description: msg`Use a dedicated initial view for each object in navigation and the view picker.`,
+ },
[FeatureFlagKey.IS_RECORD_LEVEL_SHARING_ENABLED]: {
label: msg`Record sharing`,
description: msg`Let people restrict and share individual records.`,
},
+ [FeatureFlagKey.IS_RECORD_SHARE_VISIBILITY_GATING_ENABLED]: {
+ label: msg`Record sharing visibility`,
+ description: msg`Apply record sharing visibility rules when accessing records.`,
+ },
[FeatureFlagKey.IS_DEFERRED_WORKSPACE_MIGRATION_ACTIONS_ENABLED]: {
label: msg`Deferred workspace migration actions`,
description: msg`Run the slow parts of data model changes in the background after they are saved.`,
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSwitch.tsx b/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSwitch.tsx
index 03a4142b860..9c10b057d5a 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSwitch.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsOptions/SettingsOptionCardContentSwitch.tsx
@@ -14,10 +14,6 @@ import { Switch } from 'twenty-ui/primitives/input';
import { themeCssVariables } from 'twenty-ui/theme';
const StyledSwitch = styled(Switch)`
- &[data-centered] {
- align-self: center;
- }
-
&[data-advanced-mode] {
color: ${themeCssVariables.color.yellow};
}
@@ -58,7 +54,6 @@ type SettingsOptionCardContentSwitchProps = {
divider?: boolean;
disabled?: boolean;
advancedMode?: boolean;
- switchCentered?: boolean;
checked: boolean;
onChange: (checked: boolean) => void;
};
@@ -70,7 +65,6 @@ export const SettingsOptionCardContentSwitch = ({
divider,
disabled = false,
advancedMode = false,
- switchCentered = true,
checked,
onChange,
}: SettingsOptionCardContentSwitchProps) => {
@@ -105,7 +99,6 @@ export const SettingsOptionCardContentSwitch = ({
disabled={disabled}
size="sm"
data-advanced-mode={advancedMode || undefined}
- data-centered={switchCentered || undefined}
/>
</StyledSettingsCardSwitchButtonContainer>
</StyledSettingsCardSwitchContent>
diff --git a/packages/twenty-front/src/modules/settings/lab/components/SettingsLabContent.tsx b/packages/twenty-front/src/modules/settings/lab/components/SettingsLabContent.tsx
index 2ab1e781b8e..b4271773133 100644
--- a/packages/twenty-front/src/modules/settings/lab/components/SettingsLabContent.tsx
+++ b/packages/twenty-front/src/modules/settings/lab/components/SettingsLabContent.tsx
@@ -70,7 +70,6 @@ export const SettingsLabContent = () => {
description={flag.metadata.description}
checked={flag.value}
onChange={(value) => handleToggle(flag.key, value)}
- switchCentered={false}
/>
</Card.Root>
))}
@@ -88,7 +87,6 @@ export const SettingsLabContent = () => {
description={flag.metadata.description}
checked={flag.value}
onChange={(value) => handleToggle(flag.key, value)}
- switchCentered={false}
divider={index < labPublicFeatureFlagsWithoutImage.length - 1}
/>
))}
diff --git a/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx b/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx
index ab73ce2e913..f98b9987057 100644
--- a/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx
+++ b/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx
@@ -1,16 +1,6 @@
-import { styled } from '@linaria/react';
import { type ReactNode } from 'react';
import { Section } from 'twenty-ui/components/layout';
import { Switch } from 'twenty-ui/primitives/input';
-import { themeCssVariables } from 'twenty-ui/theme';
-
-const StyledHeader = styled.div`
- align-items: center;
- display: flex;
- gap: ${themeCssVariables.spacing[3]};
- justify-content: space-between;
- margin-bottom: ${themeCssVariables.spacing[4]};
-`;
type SettingsLogicFunctionTriggerSectionProps = {
title: string;
@@ -38,17 +28,20 @@ export const SettingsLogicFunctionTriggerSection = ({
return (
<Section.Root>
- <StyledHeader>
- <Section.Header title={title} description={description} />
- {!readonly && (
- <Switch
- aria-label={title}
- checked={enabled}
- onCheckedChange={onEnabledChange}
- size="sm"
- />
- )}
- </StyledHeader>
+ <Section.Header
+ title={title}
+ description={description}
+ adornment={
+ readonly ? undefined : (
+ <Switch
+ aria-label={title}
+ checked={enabled}
+ onCheckedChange={onEnabledChange}
+ size="sm"
+ />
+ )
+ }
+ />
{enabled && children}
</Section.Root>
);
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx
index 9e251121954..a0bed1648ad 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx
+++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/ValidationStep/components/columns.tsx
@@ -47,10 +47,6 @@ const StyledSwitchContainer = styled.div`
height: 100%;
`;
-const StyledSwitch = styled(Switch)`
- align-self: center;
-`;
-
const StyledInputContainer = styled.div`
align-items: center;
display: flex;
@@ -184,7 +180,7 @@ export const generateColumns = (
event.stopPropagation();
}}
>
- <StyledSwitch
+ <Switch
aria-label={column.label}
checked={row[columnKey] as boolean}
onCheckedChange={() => {
diff --git a/packages/twenty-front/src/modules/ui/input/components/AdvancedSettingsSwitch.tsx b/packages/twenty-front/src/modules/ui/input/components/AdvancedSettingsSwitch.tsx
index b3fd421d81b..222d5f560d6 100644
--- a/packages/twenty-front/src/modules/ui/input/components/AdvancedSettingsSwitch.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/AdvancedSettingsSwitch.tsx
@@ -30,7 +30,6 @@ const StyledText = styled.div`
const StyledSwitch = styled(Switch)`
${StyledContainer} & {
- align-self: center;
color: ${themeCssVariables.color.yellow};
}
`;
diff --git a/packages/twenty-ui/src/primitives/input/Switch/Switch.module.scss b/packages/twenty-ui/src/primitives/input/Switch/Switch.module.scss
index 59570042d2e..3275aa5d526 100644
--- a/packages/twenty-ui/src/primitives/input/Switch/Switch.module.scss
+++ b/packages/twenty-ui/src/primitives/input/Switch/Switch.module.scss
@@ -6,7 +6,6 @@
box-sizing: border-box;
flex-shrink: 0;
align-items: center;
- align-self: flex-start;
padding: 0;
border: 0;
border-radius: var(--t-border-radius-pill);
diff --git a/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.interactions.stories.tsx b/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.interactions.stories.tsx
index 7fb08bae1ec..5c226f0c872 100644
--- a/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.interactions.stories.tsx
+++ b/packages/twenty-ui/src/primitives/input/Switch/__stories__/Switch.interactions.stories.tsx
@@ -17,6 +17,83 @@ const meta: Meta<typeof Switch> = {
export default meta;
type Story = StoryObj<typeof Switch>;
+export const ParentAlignment: Story = {
+ render: () => (
+ <div style={{ display: 'grid', gap: 16 }}>
+ {(['sm', 'md'] as const).map((size) => (
+ <div
+ key={size}
+ role="group"
+ aria-label={`${size} centered row`}
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ height: 32,
+ gap: 16,
+ }}
+ >
+ <span>Centered {size} switch</span>
+ <Switch size={size} aria-label={`Centered ${size} switch`} />
+ </div>
+ ))}
+ <div
+ role="group"
+ aria-label="Top aligned row"
+ style={{ display: 'flex', alignItems: 'flex-start', height: 48 }}
+ >
+ <Switch aria-label="Top aligned switch" />
+ </div>
+ <div
+ role="group"
+ aria-label="Bottom aligned row"
+ style={{ display: 'flex', alignItems: 'flex-end', height: 48 }}
+ >
+ <Switch aria-label="Bottom aligned switch" />
+ </div>
+ <div
+ role="group"
+ aria-label="Column layout"
+ style={{ display: 'flex', flexDirection: 'column', width: 240 }}
+ >
+ <Switch aria-label="Column switch" />
+ </div>
+ </div>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ for (const size of ['sm', 'md'] as const) {
+ const row = canvas.getByRole('group', { name: `${size} centered row` });
+ const controlBounds = within(row)
+ .getByRole('switch')
+ .getBoundingClientRect();
+ const labelBounds = within(row)
+ .getByText(`Centered ${size} switch`)
+ .getBoundingClientRect();
+
+ await expect(controlBounds.top + controlBounds.height / 2).toBeCloseTo(
+ labelBounds.top + labelBounds.height / 2,
+ );
+ }
+
+ const topRow = canvas.getByRole('group', { name: 'Top aligned row' });
+ await expect(
+ within(topRow).getByRole('switch').getBoundingClientRect().top,
+ ).toBeCloseTo(topRow.getBoundingClientRect().top);
+
+ const bottomRow = canvas.getByRole('group', { name: 'Bottom aligned row' });
+ await expect(
+ within(bottomRow).getByRole('switch').getBoundingClientRect().bottom,
+ ).toBeCloseTo(bottomRow.getBoundingClientRect().bottom);
+
+ await expect(
+ canvas
+ .getByRole('switch', { name: 'Column switch' })
+ .getBoundingClientRect().width,
+ ).toBe(32);
+ },
+};
+
export const Pointer: Story = {
decorators: [ComponentDecorator],
args: { onCheckedChange: fn() },