Skip to content

Commit

Permalink
created feature-flag for statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktoriiaNakoryk committed Feb 22, 2024
1 parent ca14457 commit f4809ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
19 changes: 12 additions & 7 deletions src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styles from "./sidebar.module.css";
import { ChatHistory, type ChatHistoryProps } from "../ChatHistory";
import { Settings } from "./Settings";
import { Statistic } from "../../features/Statistic";
import { useConfig } from "../../contexts/config-context";

export const Sidebar: React.FC<
{
Expand All @@ -15,6 +16,8 @@ export const Sidebar: React.FC<
const handleCloseStatistic = () => {
setIsOpenedStatistic(false);
};
const { features } = useConfig();

return (
<Box className={styles.sidebar}>
{isOpenedStatistic ? (
Expand Down Expand Up @@ -47,13 +50,15 @@ export const Sidebar: React.FC<
/>
<Flex ml="3" gap="1">
<Settings />
<IconButton
variant="outline"
title="Bar Chart"
onClick={() => setIsOpenedStatistic(true)}
>
<BarChartIcon />
</IconButton>
{features.statistics && (
<IconButton
variant="outline"
title="Bar Chart"
onClick={() => setIsOpenedStatistic(true)}
>
<BarChartIcon />
</IconButton>
)}
</Flex>
</Flex>
)}
Expand Down
8 changes: 7 additions & 1 deletion src/contexts/config-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ export type Config = {
lspUrl?: string;
dev?: boolean;
themeProps?: ThemeProps;
features: {
statistics: boolean;
};
};

const ConfigContext = createContext<Config>({ host: "web" });
const ConfigContext = createContext<Config>({
host: "web",
features: { statistics: false },
});

// TODO: add theme props, and configure vscode to grey
const ConfigProvider: React.FC<{
Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import { render } from "./lib";
const element = document.getElementById("refact-chat");

if (element) {
render(element, { host: "web" });
render(element, { host: "web", features: { statistics: false } });
}

0 comments on commit f4809ef

Please sign in to comment.