feat: add Show Page Emails tab (#2962)
* feat: add Show Page Emails tab Closes #2926, Closes #2927 * feat: review - disable Emails tab if messaging not enabled * refactor: review - add FeatureFlagKey type --------- Co-authored-by: Thais GUIGON <thaisguigon@macbook-pro.home>
This commit is contained in:
@ -0,0 +1,38 @@
|
|||||||
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
|
import {
|
||||||
|
H1Title,
|
||||||
|
H1TitleFontColor,
|
||||||
|
} from '@/ui/display/typography/components/H1Title';
|
||||||
|
import { Section } from '@/ui/layout/section/components/Section';
|
||||||
|
|
||||||
|
const StyledContainer = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: ${({ theme }) => theme.spacing(6)};
|
||||||
|
padding: ${({ theme }) => theme.spacing(6, 6, 2)};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledH1Title = styled(H1Title)`
|
||||||
|
display: flex;
|
||||||
|
gap: ${({ theme }) => theme.spacing(2)};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledEmailCount = styled.span`
|
||||||
|
color: ${({ theme }) => theme.font.color.light};
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Emails = () => (
|
||||||
|
<StyledContainer>
|
||||||
|
<Section>
|
||||||
|
<StyledH1Title
|
||||||
|
title={
|
||||||
|
<>
|
||||||
|
Inbox <StyledEmailCount>2</StyledEmailCount>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
fontColor={H1TitleFontColor.Primary}
|
||||||
|
/>
|
||||||
|
</Section>
|
||||||
|
</StyledContainer>
|
||||||
|
);
|
||||||
@ -1,7 +1,8 @@
|
|||||||
|
import { ReactNode } from 'react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
type H1TitleProps = {
|
type H1TitleProps = {
|
||||||
title: string;
|
title: ReactNode;
|
||||||
fontColor?: H1TitleFontColor;
|
fontColor?: H1TitleFontColor;
|
||||||
className?: string;
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
|
import { Emails } from '@/activities/emails/components/Emails';
|
||||||
import { Attachments } from '@/activities/files/components/Attachments';
|
import { Attachments } from '@/activities/files/components/Attachments';
|
||||||
import { Notes } from '@/activities/notes/components/Notes';
|
import { Notes } from '@/activities/notes/components/Notes';
|
||||||
import { EntityTasks } from '@/activities/tasks/components/EntityTasks';
|
import { EntityTasks } from '@/activities/tasks/components/EntityTasks';
|
||||||
@ -16,6 +17,7 @@ import { TabList } from '@/ui/layout/tab/components/TabList';
|
|||||||
import { activeTabIdScopedState } from '@/ui/layout/tab/states/activeTabIdScopedState';
|
import { activeTabIdScopedState } from '@/ui/layout/tab/states/activeTabIdScopedState';
|
||||||
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
|
||||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||||
|
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
|
||||||
|
|
||||||
import { ShowPageRecoilScopeContext } from '../../states/ShowPageRecoilScopeContext';
|
import { ShowPageRecoilScopeContext } from '../../states/ShowPageRecoilScopeContext';
|
||||||
|
|
||||||
@ -52,6 +54,8 @@ export const ShowPageRightContainer = ({
|
|||||||
notes,
|
notes,
|
||||||
emails,
|
emails,
|
||||||
}: ShowPageRightContainerProps) => {
|
}: ShowPageRightContainerProps) => {
|
||||||
|
const isMessagingEnabled = useIsFeatureEnabled('IS_MESSAGING_ENABLED');
|
||||||
|
|
||||||
const TASK_TABS = [
|
const TASK_TABS = [
|
||||||
{
|
{
|
||||||
id: 'timeline',
|
id: 'timeline',
|
||||||
@ -86,7 +90,7 @@ export const ShowPageRightContainer = ({
|
|||||||
title: 'Emails',
|
title: 'Emails',
|
||||||
Icon: IconMail,
|
Icon: IconMail,
|
||||||
hide: !emails,
|
hide: !emails,
|
||||||
disabled: true,
|
disabled: !isMessagingEnabled || entity.type === 'Custom',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -104,6 +108,7 @@ export const ShowPageRightContainer = ({
|
|||||||
{activeTabId === 'tasks' && <EntityTasks entity={entity} />}
|
{activeTabId === 'tasks' && <EntityTasks entity={entity} />}
|
||||||
{activeTabId === 'notes' && <Notes entity={entity} />}
|
{activeTabId === 'notes' && <Notes entity={entity} />}
|
||||||
{activeTabId === 'files' && <Attachments targetableEntity={entity} />}
|
{activeTabId === 'files' && <Attachments targetableEntity={entity} />}
|
||||||
|
{activeTabId === 'emails' && <Emails />}
|
||||||
</StyledShowPageRightContainer>
|
</StyledShowPageRightContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,17 +1,14 @@
|
|||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
|
|
||||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||||
|
import { FeatureFlagKey } from '@/workspace/types/FeatureFlagKey';
|
||||||
|
|
||||||
export const useIsFeatureEnabled = (featureKey: string): boolean => {
|
export const useIsFeatureEnabled = (featureKey: FeatureFlagKey) => {
|
||||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||||
|
|
||||||
const featureFlag = currentWorkspace?.featureFlags?.find(
|
const featureFlag = currentWorkspace?.featureFlags?.find(
|
||||||
(flag) => flag.key === featureKey,
|
(flag) => flag.key === featureKey,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!featureFlag) {
|
return !!featureFlag?.value;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return featureFlag.value;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
export type FeatureFlagKey =
|
||||||
|
| 'IS_MESSAGING_ENABLED'
|
||||||
|
| 'IS_NOTE_CREATE_IMAGES_ENABLED'
|
||||||
|
| 'IS_RELATION_FIELD_TYPE_ENABLED';
|
||||||
Reference in New Issue
Block a user