Add new Settings to front-end (#6154)
<img width="1512" alt="image" src="https://github.com/twentyhq/twenty/assets/12035771/cfcc6ac9-feeb-4d91-aa68-bd0119780d6d">
This commit is contained in:
@ -1,9 +1,17 @@
|
|||||||
import { MessageChannelVisibility } from '~/generated/graphql';
|
import { MessageChannelVisibility } from '~/generated/graphql';
|
||||||
|
|
||||||
|
export enum MessageChannelContactAutoCreationPolicy {
|
||||||
|
SENT_AND_RECEIVED = 'SENT_AND_RECEIVED',
|
||||||
|
SENT = 'SENT',
|
||||||
|
NONE = 'NONE',
|
||||||
|
}
|
||||||
|
|
||||||
export type MessageChannel = {
|
export type MessageChannel = {
|
||||||
id: string;
|
id: string;
|
||||||
handle: string;
|
handle: string;
|
||||||
isContactAutoCreationEnabled?: boolean;
|
contactAutoCreationPolicy?: MessageChannelContactAutoCreationPolicy;
|
||||||
|
excludeNonProfessionalEmails: boolean;
|
||||||
|
excludeGroupEmails: boolean;
|
||||||
isSyncEnabled: boolean;
|
isSyncEnabled: boolean;
|
||||||
visibility: MessageChannelVisibility;
|
visibility: MessageChannelVisibility;
|
||||||
syncStatus: string;
|
syncStatus: string;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
|
import { SettingsAccountsVisibilityIcon } from '@/settings/accounts/components/SettingsAccountsVisibilityIcon';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { SettingsAccountsVisibilitySettingCardMedia } from '@/settings/accounts/components/SettingsAccountsVisibilitySettingCardMedia';
|
|
||||||
import { MessageChannelVisibility } from '~/generated/graphql';
|
import { MessageChannelVisibility } from '~/generated/graphql';
|
||||||
|
|
||||||
const StyledCardMedia = styled(SettingsAccountsVisibilitySettingCardMedia)`
|
const StyledCardMedia = styled(SettingsAccountsVisibilityIcon)`
|
||||||
width: ${({ theme }) => theme.spacing(10)};
|
width: ${({ theme }) => theme.spacing(10)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -2,18 +2,12 @@ import { CalendarChannel } from '@/accounts/types/CalendarChannel';
|
|||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||||
import { SettingsAccountsEventVisibilitySettingsCard } from '@/settings/accounts/components/SettingsAccountsCalendarVisibilitySettingsCard';
|
import { SettingsAccountsEventVisibilitySettingsCard } from '@/settings/accounts/components/SettingsAccountsCalendarVisibilitySettingsCard';
|
||||||
import { SettingsAccountsCardMedia } from '@/settings/accounts/components/SettingsAccountsCardMedia';
|
|
||||||
import { SettingsAccountsToggleSettingCard } from '@/settings/accounts/components/SettingsAccountsToggleSettingCard';
|
import { SettingsAccountsToggleSettingCard } from '@/settings/accounts/components/SettingsAccountsToggleSettingCard';
|
||||||
import { useTheme } from '@emotion/react';
|
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { Section } from '@react-email/components';
|
import { Section } from '@react-email/components';
|
||||||
import { H2Title, IconRefresh, IconUser } from 'twenty-ui';
|
import { H2Title } from 'twenty-ui';
|
||||||
import { CalendarChannelVisibility } from '~/generated-metadata/graphql';
|
import { CalendarChannelVisibility } from '~/generated-metadata/graphql';
|
||||||
|
|
||||||
const StyledCardMedia = styled(SettingsAccountsCardMedia)`
|
|
||||||
height: ${({ theme }) => theme.spacing(6)};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StyledDetailsContainer = styled.div`
|
const StyledDetailsContainer = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -31,8 +25,6 @@ type SettingsAccountsCalendarChannelDetailsProps = {
|
|||||||
export const SettingsAccountsCalendarChannelDetails = ({
|
export const SettingsAccountsCalendarChannelDetails = ({
|
||||||
calendarChannel,
|
calendarChannel,
|
||||||
}: SettingsAccountsCalendarChannelDetailsProps) => {
|
}: SettingsAccountsCalendarChannelDetailsProps) => {
|
||||||
const theme = useTheme();
|
|
||||||
|
|
||||||
const { updateOneRecord } = useUpdateOneRecord<CalendarChannel>({
|
const { updateOneRecord } = useUpdateOneRecord<CalendarChannel>({
|
||||||
objectNameSingular: CoreObjectNameSingular.CalendarChannel,
|
objectNameSingular: CoreObjectNameSingular.CalendarChannel,
|
||||||
});
|
});
|
||||||
@ -55,14 +47,6 @@ export const SettingsAccountsCalendarChannelDetails = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSyncEventsToggle = (value: boolean) => {
|
|
||||||
updateOneRecord({
|
|
||||||
idToUpdate: calendarChannel.id,
|
|
||||||
updateOneRecordInput: {
|
|
||||||
isSyncEnabled: value,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<StyledDetailsContainer>
|
<StyledDetailsContainer>
|
||||||
<Section>
|
<Section>
|
||||||
@ -81,36 +65,14 @@ export const SettingsAccountsCalendarChannelDetails = ({
|
|||||||
description="Automatically create contacts for people you've participated in an event with."
|
description="Automatically create contacts for people you've participated in an event with."
|
||||||
/>
|
/>
|
||||||
<SettingsAccountsToggleSettingCard
|
<SettingsAccountsToggleSettingCard
|
||||||
cardMedia={
|
parameters={[
|
||||||
<StyledCardMedia>
|
{
|
||||||
<IconUser
|
value: !!calendarChannel.isContactAutoCreationEnabled,
|
||||||
size={theme.icon.size.sm}
|
title: 'Auto-creation',
|
||||||
stroke={theme.icon.stroke.lg}
|
description: 'Automatically create contacts for people.',
|
||||||
/>
|
onToggle: handleContactAutoCreationToggle,
|
||||||
</StyledCardMedia>
|
},
|
||||||
}
|
]}
|
||||||
title="Auto-creation"
|
|
||||||
value={!!calendarChannel.isContactAutoCreationEnabled}
|
|
||||||
onToggle={handleContactAutoCreationToggle}
|
|
||||||
/>
|
|
||||||
</Section>
|
|
||||||
<Section>
|
|
||||||
<H2Title
|
|
||||||
title="Synchronization"
|
|
||||||
description="Past and future calendar events will automatically be synced to this workspace"
|
|
||||||
/>
|
|
||||||
<SettingsAccountsToggleSettingCard
|
|
||||||
cardMedia={
|
|
||||||
<StyledCardMedia>
|
|
||||||
<IconRefresh
|
|
||||||
size={theme.icon.size.sm}
|
|
||||||
stroke={theme.icon.stroke.lg}
|
|
||||||
/>
|
|
||||||
</StyledCardMedia>
|
|
||||||
}
|
|
||||||
title="Sync events"
|
|
||||||
value={!!calendarChannel.isSyncEnabled}
|
|
||||||
onToggle={handleSyncEventsToggle}
|
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
</StyledDetailsContainer>
|
</StyledDetailsContainer>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { SettingsAccountsRadioSettingsCard } from '@/settings/accounts/components/SettingsAccountsRadioSettingsCard';
|
import { SettingsAccountsRadioSettingsCard } from '@/settings/accounts/components/SettingsAccountsRadioSettingsCard';
|
||||||
import { SettingsAccountsVisibilitySettingCardMedia } from '@/settings/accounts/components/SettingsAccountsVisibilitySettingCardMedia';
|
import { SettingsAccountsVisibilityIcon } from '@/settings/accounts/components/SettingsAccountsVisibilityIcon';
|
||||||
import { CalendarChannelVisibility } from '~/generated/graphql';
|
import { CalendarChannelVisibility } from '~/generated/graphql';
|
||||||
|
|
||||||
type SettingsAccountsEventVisibilitySettingsCardProps = {
|
type SettingsAccountsEventVisibilitySettingsCardProps = {
|
||||||
@ -9,7 +9,7 @@ type SettingsAccountsEventVisibilitySettingsCardProps = {
|
|||||||
value?: CalendarChannelVisibility;
|
value?: CalendarChannelVisibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledCardMedia = styled(SettingsAccountsVisibilitySettingCardMedia)`
|
const StyledCardMedia = styled(SettingsAccountsVisibilityIcon)`
|
||||||
height: ${({ theme }) => theme.spacing(6)};
|
height: ${({ theme }) => theme.spacing(6)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
import { MessageChannelContactAutoCreationPolicy } from '@/accounts/types/MessageChannel';
|
||||||
|
import { SettingsAccountsMessageAutoCreationIcon } from '@/settings/accounts/components/SettingsAccountsMessageAutoCreationIcon';
|
||||||
|
import { SettingsAccountsRadioSettingsCard } from '@/settings/accounts/components/SettingsAccountsRadioSettingsCard';
|
||||||
|
|
||||||
|
type SettingsAccountsMessageAutoCreationCardProps = {
|
||||||
|
onChange: (nextValue: MessageChannelContactAutoCreationPolicy) => void;
|
||||||
|
value?: MessageChannelContactAutoCreationPolicy;
|
||||||
|
};
|
||||||
|
|
||||||
|
const autoCreationOptions = [
|
||||||
|
{
|
||||||
|
title: 'Send and Received',
|
||||||
|
description: 'People I’ve sent emails to and received emails from.',
|
||||||
|
value: MessageChannelContactAutoCreationPolicy.SENT_AND_RECEIVED,
|
||||||
|
cardMedia: (
|
||||||
|
<SettingsAccountsMessageAutoCreationIcon isSentActive isReceivedActive />
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Sent',
|
||||||
|
description: 'People I’ve sent emails to.',
|
||||||
|
value: MessageChannelContactAutoCreationPolicy.SENT,
|
||||||
|
cardMedia: <SettingsAccountsMessageAutoCreationIcon isSentActive />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'None',
|
||||||
|
description: 'Don’t auto-create contacts.',
|
||||||
|
value: MessageChannelContactAutoCreationPolicy.NONE,
|
||||||
|
cardMedia: (
|
||||||
|
<SettingsAccountsMessageAutoCreationIcon
|
||||||
|
isSentActive={false}
|
||||||
|
isReceivedActive={false}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const SettingsAccountsMessageAutoCreationCard = ({
|
||||||
|
onChange,
|
||||||
|
value = MessageChannelContactAutoCreationPolicy.SENT_AND_RECEIVED,
|
||||||
|
}: SettingsAccountsMessageAutoCreationCardProps) => (
|
||||||
|
<SettingsAccountsRadioSettingsCard
|
||||||
|
options={autoCreationOptions}
|
||||||
|
value={value}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
|
import { SettingsAccountsCardMedia } from '@/settings/accounts/components/SettingsAccountsCardMedia';
|
||||||
|
|
||||||
|
type SettingsAccountsMessageAutoCreationIconProps = {
|
||||||
|
className?: string;
|
||||||
|
isSentActive?: boolean;
|
||||||
|
isReceivedActive?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
const StyledIconContainer = styled(SettingsAccountsCardMedia)`
|
||||||
|
align-items: stretch;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledDirectionSkeleton = styled.div<{ isActive?: boolean }>`
|
||||||
|
background-color: ${({ isActive, theme }) =>
|
||||||
|
isActive ? theme.accent.accent4060 : theme.background.quaternary};
|
||||||
|
border-radius: 1px;
|
||||||
|
height: 24px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const SettingsAccountsMessageAutoCreationIcon = ({
|
||||||
|
className,
|
||||||
|
isSentActive,
|
||||||
|
isReceivedActive,
|
||||||
|
}: SettingsAccountsMessageAutoCreationIconProps) => (
|
||||||
|
<StyledIconContainer className={className}>
|
||||||
|
<StyledDirectionSkeleton isActive={isSentActive} />
|
||||||
|
<StyledDirectionSkeleton isActive={isReceivedActive} />
|
||||||
|
</StyledIconContainer>
|
||||||
|
);
|
||||||
@ -1,12 +1,14 @@
|
|||||||
import { useTheme } from '@emotion/react';
|
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { H2Title, IconRefresh, IconUser } from 'twenty-ui';
|
import { H2Title } from 'twenty-ui';
|
||||||
|
|
||||||
import { MessageChannel } from '@/accounts/types/MessageChannel';
|
import {
|
||||||
|
MessageChannel,
|
||||||
|
MessageChannelContactAutoCreationPolicy,
|
||||||
|
} from '@/accounts/types/MessageChannel';
|
||||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||||
import { SettingsAccountsCardMedia } from '@/settings/accounts/components/SettingsAccountsCardMedia';
|
import { SettingsAccountsMessageAutoCreationCard } from '@/settings/accounts/components/SettingsAccountsMessageAutoCreationCard';
|
||||||
import { SettingsAccountsInboxVisibilitySettingsCard } from '@/settings/accounts/components/SettingsAccountsInboxVisibilitySettingsCard';
|
import { SettingsAccountsMessageVisibilityCard } from '@/settings/accounts/components/SettingsAccountsMessageVisibilityCard';
|
||||||
import { SettingsAccountsToggleSettingCard } from '@/settings/accounts/components/SettingsAccountsToggleSettingCard';
|
import { SettingsAccountsToggleSettingCard } from '@/settings/accounts/components/SettingsAccountsToggleSettingCard';
|
||||||
import { Section } from '@/ui/layout/section/components/Section';
|
import { Section } from '@/ui/layout/section/components/Section';
|
||||||
import { MessageChannelVisibility } from '~/generated-metadata/graphql';
|
import { MessageChannelVisibility } from '~/generated-metadata/graphql';
|
||||||
@ -14,7 +16,12 @@ import { MessageChannelVisibility } from '~/generated-metadata/graphql';
|
|||||||
type SettingsAccountsMessageChannelDetailsProps = {
|
type SettingsAccountsMessageChannelDetailsProps = {
|
||||||
messageChannel: Pick<
|
messageChannel: Pick<
|
||||||
MessageChannel,
|
MessageChannel,
|
||||||
'id' | 'visibility' | 'isContactAutoCreationEnabled' | 'isSyncEnabled'
|
| 'id'
|
||||||
|
| 'visibility'
|
||||||
|
| 'contactAutoCreationPolicy'
|
||||||
|
| 'excludeNonProfessionalEmails'
|
||||||
|
| 'excludeGroupEmails'
|
||||||
|
| 'isSyncEnabled'
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,8 +35,6 @@ const StyledDetailsContainer = styled.div`
|
|||||||
export const SettingsAccountsMessageChannelDetails = ({
|
export const SettingsAccountsMessageChannelDetails = ({
|
||||||
messageChannel,
|
messageChannel,
|
||||||
}: SettingsAccountsMessageChannelDetailsProps) => {
|
}: SettingsAccountsMessageChannelDetailsProps) => {
|
||||||
const theme = useTheme();
|
|
||||||
|
|
||||||
const { updateOneRecord } = useUpdateOneRecord<MessageChannel>({
|
const { updateOneRecord } = useUpdateOneRecord<MessageChannel>({
|
||||||
objectNameSingular: CoreObjectNameSingular.MessageChannel,
|
objectNameSingular: CoreObjectNameSingular.MessageChannel,
|
||||||
});
|
});
|
||||||
@ -43,20 +48,31 @@ export const SettingsAccountsMessageChannelDetails = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleContactAutoCreationToggle = (value: boolean) => {
|
const handleContactAutoCreationChange = (
|
||||||
|
value: MessageChannelContactAutoCreationPolicy,
|
||||||
|
) => {
|
||||||
updateOneRecord({
|
updateOneRecord({
|
||||||
idToUpdate: messageChannel.id,
|
idToUpdate: messageChannel.id,
|
||||||
updateOneRecordInput: {
|
updateOneRecordInput: {
|
||||||
isContactAutoCreationEnabled: value,
|
contactAutoCreationPolicy: value,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleIsSyncEnabledToggle = (value: boolean) => {
|
const handleIsGroupEmailExcludedToggle = (value: boolean) => {
|
||||||
updateOneRecord({
|
updateOneRecord({
|
||||||
idToUpdate: messageChannel.id,
|
idToUpdate: messageChannel.id,
|
||||||
updateOneRecordInput: {
|
updateOneRecordInput: {
|
||||||
isSyncEnabled: value,
|
excludeGroupEmails: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleIsNonProfessionalEmailExcludedToggle = (value: boolean) => {
|
||||||
|
updateOneRecord({
|
||||||
|
idToUpdate: messageChannel.id,
|
||||||
|
updateOneRecordInput: {
|
||||||
|
excludeNonProfessionalEmails: value,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -68,7 +84,7 @@ export const SettingsAccountsMessageChannelDetails = ({
|
|||||||
title="Visibility"
|
title="Visibility"
|
||||||
description="Define what will be visible to other users in your workspace"
|
description="Define what will be visible to other users in your workspace"
|
||||||
/>
|
/>
|
||||||
<SettingsAccountsInboxVisibilitySettingsCard
|
<SettingsAccountsMessageVisibilityCard
|
||||||
value={messageChannel.visibility}
|
value={messageChannel.visibility}
|
||||||
onChange={handleVisibilityChange}
|
onChange={handleVisibilityChange}
|
||||||
/>
|
/>
|
||||||
@ -76,39 +92,29 @@ export const SettingsAccountsMessageChannelDetails = ({
|
|||||||
<Section>
|
<Section>
|
||||||
<H2Title
|
<H2Title
|
||||||
title="Contact auto-creation"
|
title="Contact auto-creation"
|
||||||
description="Automatically create contacts for people you’ve sent emails to"
|
description="Automatically create People records when receiving or sending emails"
|
||||||
/>
|
/>
|
||||||
<SettingsAccountsToggleSettingCard
|
<SettingsAccountsMessageAutoCreationCard
|
||||||
cardMedia={
|
value={messageChannel.contactAutoCreationPolicy}
|
||||||
<SettingsAccountsCardMedia>
|
onChange={handleContactAutoCreationChange}
|
||||||
<IconUser
|
|
||||||
size={theme.icon.size.sm}
|
|
||||||
stroke={theme.icon.stroke.lg}
|
|
||||||
/>
|
|
||||||
</SettingsAccountsCardMedia>
|
|
||||||
}
|
|
||||||
title="Auto-creation"
|
|
||||||
value={!!messageChannel.isContactAutoCreationEnabled}
|
|
||||||
onToggle={handleContactAutoCreationToggle}
|
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section>
|
<Section>
|
||||||
<H2Title
|
|
||||||
title="Synchronization"
|
|
||||||
description="Past and future emails will automatically be synced to this workspace"
|
|
||||||
/>
|
|
||||||
<SettingsAccountsToggleSettingCard
|
<SettingsAccountsToggleSettingCard
|
||||||
cardMedia={
|
parameters={[
|
||||||
<SettingsAccountsCardMedia>
|
{
|
||||||
<IconRefresh
|
title: 'Exclude non-professional emails',
|
||||||
size={theme.icon.size.sm}
|
description: 'Don’t sync emails from/to Gmail, Outlook...',
|
||||||
stroke={theme.icon.stroke.lg}
|
value: !!messageChannel.excludeNonProfessionalEmails,
|
||||||
/>
|
onToggle: handleIsNonProfessionalEmailExcludedToggle,
|
||||||
</SettingsAccountsCardMedia>
|
},
|
||||||
}
|
{
|
||||||
title="Sync emails"
|
title: 'Exclude group emails',
|
||||||
value={!!messageChannel.isSyncEnabled}
|
description: 'Don’t sync emails from team@ support@ noreply@...',
|
||||||
onToggle={handleIsSyncEnabledToggle}
|
value: !!messageChannel.excludeGroupEmails,
|
||||||
|
onToggle: handleIsGroupEmailExcludedToggle,
|
||||||
|
},
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
</StyledDetailsContainer>
|
</StyledDetailsContainer>
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { SettingsAccountsRadioSettingsCard } from '@/settings/accounts/components/SettingsAccountsRadioSettingsCard';
|
import { SettingsAccountsRadioSettingsCard } from '@/settings/accounts/components/SettingsAccountsRadioSettingsCard';
|
||||||
import { SettingsAccountsVisibilitySettingCardMedia } from '@/settings/accounts/components/SettingsAccountsVisibilitySettingCardMedia';
|
import { SettingsAccountsVisibilityIcon } from '@/settings/accounts/components/SettingsAccountsVisibilityIcon';
|
||||||
import { MessageChannelVisibility } from '~/generated/graphql';
|
import { MessageChannelVisibility } from '~/generated/graphql';
|
||||||
|
|
||||||
type SettingsAccountsInboxVisibilitySettingsCardProps = {
|
type SettingsAccountsMessageVisibilityCardProps = {
|
||||||
onChange: (nextValue: MessageChannelVisibility) => void;
|
onChange: (nextValue: MessageChannelVisibility) => void;
|
||||||
value?: MessageChannelVisibility;
|
value?: MessageChannelVisibility;
|
||||||
};
|
};
|
||||||
@ -13,7 +13,7 @@ const inboxSettingsVisibilityOptions = [
|
|||||||
description: 'Subject, body and attachments will be shared with your team.',
|
description: 'Subject, body and attachments will be shared with your team.',
|
||||||
value: MessageChannelVisibility.ShareEverything,
|
value: MessageChannelVisibility.ShareEverything,
|
||||||
cardMedia: (
|
cardMedia: (
|
||||||
<SettingsAccountsVisibilitySettingCardMedia
|
<SettingsAccountsVisibilityIcon
|
||||||
metadata="active"
|
metadata="active"
|
||||||
subject="active"
|
subject="active"
|
||||||
body="active"
|
body="active"
|
||||||
@ -25,7 +25,7 @@ const inboxSettingsVisibilityOptions = [
|
|||||||
description: 'Subject and metadata will be shared with your team.',
|
description: 'Subject and metadata will be shared with your team.',
|
||||||
value: MessageChannelVisibility.Subject,
|
value: MessageChannelVisibility.Subject,
|
||||||
cardMedia: (
|
cardMedia: (
|
||||||
<SettingsAccountsVisibilitySettingCardMedia
|
<SettingsAccountsVisibilityIcon
|
||||||
metadata="active"
|
metadata="active"
|
||||||
subject="active"
|
subject="active"
|
||||||
body="inactive"
|
body="inactive"
|
||||||
@ -37,7 +37,7 @@ const inboxSettingsVisibilityOptions = [
|
|||||||
description: 'Timestamp and participants will be shared with your team.',
|
description: 'Timestamp and participants will be shared with your team.',
|
||||||
value: MessageChannelVisibility.Metadata,
|
value: MessageChannelVisibility.Metadata,
|
||||||
cardMedia: (
|
cardMedia: (
|
||||||
<SettingsAccountsVisibilitySettingCardMedia
|
<SettingsAccountsVisibilityIcon
|
||||||
metadata="active"
|
metadata="active"
|
||||||
subject="inactive"
|
subject="inactive"
|
||||||
body="inactive"
|
body="inactive"
|
||||||
@ -46,10 +46,10 @@ const inboxSettingsVisibilityOptions = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const SettingsAccountsInboxVisibilitySettingsCard = ({
|
export const SettingsAccountsMessageVisibilityCard = ({
|
||||||
onChange,
|
onChange,
|
||||||
value = MessageChannelVisibility.ShareEverything,
|
value = MessageChannelVisibility.ShareEverything,
|
||||||
}: SettingsAccountsInboxVisibilitySettingsCardProps) => (
|
}: SettingsAccountsMessageVisibilityCardProps) => (
|
||||||
<SettingsAccountsRadioSettingsCard
|
<SettingsAccountsRadioSettingsCard
|
||||||
options={inboxSettingsVisibilityOptions}
|
options={inboxSettingsVisibilityOptions}
|
||||||
value={value}
|
value={value}
|
||||||
@ -1,31 +0,0 @@
|
|||||||
import { useGetSyncStatusOptions } from '@/settings/accounts/hooks//useGetSyncStatusOptions';
|
|
||||||
import { Status } from '@/ui/display/status/components/Status';
|
|
||||||
|
|
||||||
export type SettingsAccountsSynchronizationStatusProps = {
|
|
||||||
syncStatus: string;
|
|
||||||
isSyncEnabled?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const SettingsAccountsSynchronizationStatus = ({
|
|
||||||
syncStatus,
|
|
||||||
isSyncEnabled,
|
|
||||||
}: SettingsAccountsSynchronizationStatusProps) => {
|
|
||||||
const syncStatusOptions = useGetSyncStatusOptions();
|
|
||||||
|
|
||||||
const syncStatusOption = syncStatusOptions?.find(
|
|
||||||
(option) => option.value === syncStatus,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!isSyncEnabled) {
|
|
||||||
return <Status color="gray" text="Not synced" weight="medium" />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Status
|
|
||||||
color={syncStatusOption?.color ?? 'gray'}
|
|
||||||
isLoaderVisible={syncStatus === 'ONGOING' || syncStatus === 'PENDING'}
|
|
||||||
text={syncStatusOption?.label ?? 'Not synced'}
|
|
||||||
weight="medium"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@ -1,22 +1,24 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { Toggle } from '@/ui/input/components/Toggle';
|
import { Toggle } from '@/ui/input/components/Toggle';
|
||||||
import { Card } from '@/ui/layout/card/components/Card';
|
import { Card } from '@/ui/layout/card/components/Card';
|
||||||
import { CardContent } from '@/ui/layout/card/components/CardContent';
|
import { CardContent } from '@/ui/layout/card/components/CardContent';
|
||||||
|
|
||||||
type SettingsAccountsToggleSettingCardProps = {
|
type Parameter = {
|
||||||
cardMedia: ReactNode;
|
|
||||||
value: boolean;
|
value: boolean;
|
||||||
onToggle: (value: boolean) => void;
|
|
||||||
title: string;
|
title: string;
|
||||||
|
description: string;
|
||||||
|
onToggle: (value: boolean) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SettingsAccountsToggleSettingCardProps = {
|
||||||
|
parameters: Parameter[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledCardContent = styled(CardContent)`
|
const StyledCardContent = styled(CardContent)`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: ${({ theme }) => theme.spacing(4)};
|
gap: ${({ theme }) => theme.spacing(4)};
|
||||||
padding: ${({ theme }) => theme.spacing(2, 4)};
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
@ -24,23 +26,37 @@ const StyledCardContent = styled(CardContent)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledTitle = styled.span`
|
const StyledTitle = styled.div`
|
||||||
color: ${({ theme }) => theme.font.color.primary};
|
color: ${({ theme }) => theme.font.color.primary};
|
||||||
font-weight: ${({ theme }) => theme.font.weight.medium};
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
||||||
margin-right: auto;
|
margin-bottom: ${({ theme }) => theme.spacing(2)};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledDescription = styled.div`
|
||||||
|
color: ${({ theme }) => theme.font.color.tertiary};
|
||||||
|
font-size: ${({ theme }) => theme.font.size.sm};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledToggle = styled(Toggle)`
|
||||||
|
margin-left: auto;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const SettingsAccountsToggleSettingCard = ({
|
export const SettingsAccountsToggleSettingCard = ({
|
||||||
cardMedia,
|
parameters,
|
||||||
value,
|
|
||||||
onToggle,
|
|
||||||
title,
|
|
||||||
}: SettingsAccountsToggleSettingCardProps) => (
|
}: SettingsAccountsToggleSettingCardProps) => (
|
||||||
<Card rounded>
|
<Card rounded>
|
||||||
<StyledCardContent onClick={() => onToggle(!value)}>
|
{parameters.map((parameter, index) => (
|
||||||
{cardMedia}
|
<StyledCardContent
|
||||||
<StyledTitle>{title}</StyledTitle>
|
key={index}
|
||||||
<Toggle value={value} onChange={onToggle} />
|
divider={index < parameters.length - 1}
|
||||||
</StyledCardContent>
|
onClick={() => parameter.onToggle(!parameter.value)}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<StyledTitle>{parameter.title}</StyledTitle>
|
||||||
|
<StyledDescription>{parameter.description}</StyledDescription>
|
||||||
|
</div>
|
||||||
|
<StyledToggle value={parameter.value} onChange={parameter.onToggle} />
|
||||||
|
</StyledCardContent>
|
||||||
|
))}
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { SettingsAccountsCardMedia } from '@/settings/accounts/components/Settin
|
|||||||
|
|
||||||
type VisibilityElementState = 'active' | 'inactive';
|
type VisibilityElementState = 'active' | 'inactive';
|
||||||
|
|
||||||
type SettingsAccountsVisibilitySettingCardMediaProps = {
|
type SettingsAccountsVisibilityIconProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
metadata?: VisibilityElementState;
|
metadata?: VisibilityElementState;
|
||||||
subject?: VisibilityElementState;
|
subject?: VisibilityElementState;
|
||||||
@ -31,12 +31,12 @@ const StyledBodySkeleton = styled(StyledSubjectSkeleton)`
|
|||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const SettingsAccountsVisibilitySettingCardMedia = ({
|
export const SettingsAccountsVisibilityIcon = ({
|
||||||
className,
|
className,
|
||||||
metadata,
|
metadata,
|
||||||
subject,
|
subject,
|
||||||
body,
|
body,
|
||||||
}: SettingsAccountsVisibilitySettingCardMediaProps) => (
|
}: SettingsAccountsVisibilityIconProps) => (
|
||||||
<StyledCardMedia className={className}>
|
<StyledCardMedia className={className}>
|
||||||
{!!metadata && <StyledMetadataSkeleton isActive={metadata === 'active'} />}
|
{!!metadata && <StyledMetadataSkeleton isActive={metadata === 'active'} />}
|
||||||
{!!subject && <StyledSubjectSkeleton isActive={subject === 'active'} />}
|
{!!subject && <StyledSubjectSkeleton isActive={subject === 'active'} />}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import { Meta, StoryObj } from '@storybook/react';
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
import { ComponentDecorator } from 'twenty-ui';
|
import { ComponentDecorator } from 'twenty-ui';
|
||||||
|
|
||||||
|
import { MessageChannelContactAutoCreationPolicy } from '@/accounts/types/MessageChannel';
|
||||||
import { SettingsAccountsMessageChannelDetails } from '@/settings/accounts/components/SettingsAccountsMessageChannelDetails';
|
import { SettingsAccountsMessageChannelDetails } from '@/settings/accounts/components/SettingsAccountsMessageChannelDetails';
|
||||||
import { MessageChannelVisibility } from '~/generated/graphql';
|
import { MessageChannelVisibility } from '~/generated/graphql';
|
||||||
|
|
||||||
@ -12,7 +13,9 @@ const meta: Meta<typeof SettingsAccountsMessageChannelDetails> = {
|
|||||||
args: {
|
args: {
|
||||||
messageChannel: {
|
messageChannel: {
|
||||||
id: '20202020-ef5a-4822-9e08-ce6e6a4dcb6a',
|
id: '20202020-ef5a-4822-9e08-ce6e6a4dcb6a',
|
||||||
isContactAutoCreationEnabled: true,
|
contactAutoCreationPolicy: MessageChannelContactAutoCreationPolicy.SENT,
|
||||||
|
excludeNonProfessionalEmails: true,
|
||||||
|
excludeGroupEmails: false,
|
||||||
isSyncEnabled: true,
|
isSyncEnabled: true,
|
||||||
visibility: MessageChannelVisibility.ShareEverything,
|
visibility: MessageChannelVisibility.ShareEverything,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user