Skip to content

Commit

Permalink
feat(frontend): add flag to toggle the analytics page (#3122)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Sep 5, 2023
1 parent a784025 commit 2334662
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
Expand Up @@ -11,14 +11,14 @@ export const BodyFieldContainer = styled.div<{$isDisplaying: boolean}>`
border-radius: 2px;
font-size: ${({theme}) => theme.size.md};
outline: 1px solid grey;
font-family: SFPro, serif;
font-family: SFPro, Inter, serif;
}
.cm-line {
padding: 0;
span {
font-family: SFPro, serif;
font-family: SFPro, Inter, serif;
}
}
}
Expand Down
Expand Up @@ -6,10 +6,11 @@ interface IProps {
}

const getComponent = <T,>(id: string, fallback: React.ComponentType<T>) => fallback;
const getFlag = () => true;
const getIsAllowed = () => true;

const CustomizationWrapper = ({children}: IProps) => {
const customizationProviderValue = useMemo(() => ({getComponent, getIsAllowed}), []);
const customizationProviderValue = useMemo(() => ({getComponent, getFlag, getIsAllowed}), []);

return <CustomizationProvider value={customizationProviderValue}>{children}</CustomizationProvider>;
};
Expand Down
2 changes: 1 addition & 1 deletion web/src/constants/Theme.constants.ts
Expand Up @@ -29,7 +29,7 @@ export const theme: DefaultTheme = {
xxxl: '24px',
},
font: {
family: 'SFPro',
family: 'SFPro, Inter',
},
notification: {
success: {
Expand Down
10 changes: 7 additions & 3 deletions web/src/pages/Settings/Content.tsx
Expand Up @@ -7,6 +7,7 @@ import Linter from 'components/Settings/Linter';
import Polling from 'components/Settings/Polling';
import TestRunner from 'components/Settings/TestRunner';
import BetaBadge from 'components/BetaBadge/BetaBadge';
import {Flag, useCustomization} from 'providers/Customization';
import * as S from './Settings.styled';

const TabsKeys = {
Expand All @@ -19,6 +20,7 @@ const TabsKeys = {
};

const Content = () => {
const {getFlag} = useCustomization();
const [query, setQuery] = useSearchParams();

return (
Expand All @@ -38,9 +40,11 @@ const Content = () => {
<Tabs.TabPane key={TabsKeys.DataStore} tab="Configure Data Store">
<DataStore />
</Tabs.TabPane>
<Tabs.TabPane key={TabsKeys.Analytics} tab="Analytics">
<Analytics />
</Tabs.TabPane>
{getFlag(Flag.IsAnalyticsPageEnabled) && (
<Tabs.TabPane key={TabsKeys.Analytics} tab="Analytics">
<Analytics />
</Tabs.TabPane>
)}
<Tabs.TabPane key={TabsKeys.Polling} tab="Trace Polling">
<Polling />
</Tabs.TabPane>
Expand Down
6 changes: 6 additions & 0 deletions web/src/providers/Customization/Customization.provider.tsx
Expand Up @@ -6,13 +6,19 @@ export enum Operation {
View = 'view',
}

export enum Flag {
IsAnalyticsPageEnabled = 'isAnalyticsPageEnabled',
}

interface IContext {
getComponent<T>(name: string, fallback: React.ComponentType<T>): React.ComponentType<T>;
getFlag(flag: Flag): boolean;
getIsAllowed(operation: Operation): boolean;
}

export const Context = createContext<IContext>({
getComponent: (name, fallback) => fallback,
getFlag: () => true,
getIsAllowed: () => true,
});

Expand Down
2 changes: 1 addition & 1 deletion web/src/providers/Customization/index.ts
@@ -1,3 +1,3 @@
// eslint-disable-next-line no-restricted-exports
export {default, useCustomization, Operation} from './Customization.provider';
export {default, useCustomization, Flag, Operation} from './Customization.provider';
export {default as withCustomization} from './WithCustomization';

0 comments on commit 2334662

Please sign in to comment.