Unverified Commit e0be48a5 authored by palash-signoz's avatar palash-signoz Committed by GitHub
Browse files

refactor(frontend): Sidebar is updated (#276)

parent 4143e313
develop 1244-edit-alert 1725-expection 24-may-2022-testing 414-uri alertmanager-discovery ankit01-oss-patch-1 bug/synk-security-fixes bump-json-iterator bump-prometheus ch-connection-exit ch-index-changes change-sample-alert chore-telemetry chore/analytics chore/change-validation-message chore/improve-metrics-perf chore/improve-perf-remote-read chore/install-script-update chore/migration-0.8.0 chore/migration-file-path chore/moving-to-clickhouse-v2 chore/remove-query-service-codeowners chore/update-otelcollector-0.43.0 clickhouse-helm clickhouse-persistence crud-dashboards custom_metrics dashboarad-vars dashboard-bug-fix debug-dep debug-dep-migrate docker-swarm effgo enable-alerts feat-doc-contribute feat-statsd-receiver feat/addHasErrorColumn feat/amol-ee feat/clickhouse-db-optimizations feat/custom-func-getSubTreeSpans feat/dynamic-tooltip feat/ee feat/exclude-filter-support feat/featureFlagging feat/fields-compression feat/gRPC-code-method feat/getFilteredSpans feat/getSpanFilters feat/gh-bot feat/newTraceFilter feat/searchTraceId feat/support-custom-events feat/support-error-tab-page feat/support-events feat/tagValueSuggestion feat/trace-detail feat/trace-resource-attributes feat/udf-function-getSubTreeSpans feat/usage feat/usage-reporting filter-set fix-ami-linux-docker fix-cors-put fix-double-client fix-filtered-spans fix-husky fix-user fix/414-error-trace-filter-APIs fix/aggregate fix/error-exception-page-typo fix/error-exception-sql-issue fix/errorDetailURL fix/exceptionPageOptimization fix/exclude-operation fix/null-values fix/serviceMapDependencies fix/setTTLapis fix/telemetry-bug hostmetrics infra-metrics issue-1228 issue-1252 issue-1293 issue-1294 issue-1442 issue-1485-develop issue-1511 issue-1583 issue-618 issue-pod-687 labels_object main makeavish-patch-1 makeavish-patch-2 metric-suggest-apis-chv2 metrics-builder-all metrics-table new-metrics new-metrics-enums palashgdev-patch-1 palashgdev-patch-2 perf/trace-detail-page playwright pranay01-patch-1 pranshuchittora/feat/dynamic-step-size prashant/add-codeowners prashant/add-deploy-docs prashant/ci-k3s-enchancements prashant/contributing-docs prashant/docker-data-path prashant/e2e-k3s-changes prashant/frontend-docker prashant/hotrod-log-options prashant/hotrod-template prashant/hotrod-yaml prashant/install-script-changes prashant/integrate-behaviorbot prashant/migrate-helm-charts prashant/minor-k3s-changes prashant/nginx-cache-improvement prashant/remove-ports prashant/rename-config prashant/single-hotrod-manifest prashant/two-compose-yaml prashant/version-ping-mini-css-extract-plugin prashant/versioning prod-feedback release/v0.10 release/v0.10.0 release/v0.10.1 release/v0.10.2 release/v0.11 release/v0.11.0 release/v0.11.1 release/v0.11.2 release/v0.11.3 release/v0.6 release/v0.6.0 release/v0.6.1 release/v0.6.2 release/v0.7 release/v0.7.0 release/v0.7.1 release/v0.7.2 release/v0.7.3 release/v0.7.4 release/v0.7.5 release/v0.8 release/v0.8.0 release/v0.8.1 release/v0.8.2 release/v0.9 release/v0.9.0 release/v0.9.1 release/v0.9.2 revert-310-snyk-fix-d368e29b07323337ebe6ba0e289d85e7 revert-382-fix-eslint-error revert-386-remove-package revert-456-storybook revert-628-chore/migration-file-path revert-770-trace-styles revert-814-release/v0.7.0 revert-835-pc/feat/shared-styles-for-styled-components snyk-fix-0c242a73fc20c472e37f0b59a7c93a5a snyk-fix-194ab2b3455dd9e2099068fc3ac5f20f snyk-fix-3d7b28e56a36018c4b5cf8438365ff27 snyk-fix-4ef12a6988dec7696867e0b2accb8289 snyk-fix-634b756aa5179844cafb3a54d707b934 snyk-fix-7ee2560cd9d67a9821899135c05c1175 snyk-fix-8f3a2f55a70c214b57d1a3b3bce7d0cf snyk-fix-a7789225303bf723cc0665d987e0bf24 snyk-fix-badf8cd7fc1f284699352ace871e5075 snyk-fix-d1c97e9d4144298a9396308ed03ebd9e snyk-fix-d368e29b07323337ebe6ba0e289d85e7 snyk-fix-d5e919722918d14db890a368b9964203 span-metrics trace-search troubleshoot ttl-get-int ttl-plus uuid-server wip-release-0.11.1 v0.11.3 v0.11.3-rc.1 v0.11.2 v0.11.2-rc.3 v0.11.2-rc.2 v0.11.2-rc.1 v0.11.1 v0.11.1-rc.1 v0.11.0 v0.11.0-rc.1 v0.11 v0.10.2 v0.10.1 v0.10.1-rc.1 v0.10.0 v0.10.0-rc2 v0.10.0-rc1 v0.10 v0.9.2 v0.9.2-rc1 v0.9.1 v0.9.0 v0.9.0-rc2 v0.9.0-rc1 v0.9 v0.8.2 v0.8.1 v0.8.1-rc5 v0.8.1-rc4 v0.8.1-rc3 v0.8.1-rc2 v0.8.1-rc1 v0.8.0 v0.8.0-rc6 v0.8.0-rc5 v0.8.0-rc4 v0.8.0-rc3 v0.8.0-rc2 v0.8.0-rc1 v0.8 v0.7.5 v0.7.5-rc2 v0.7.5-rc1 v0.7.4 v0.7.4-rc2 v0.7.4-rc1 v0.7.3 v0.7.2 v0.7.2-rc1 v0.7.1 v0.7.0 v0.7 v0.6.2 v0.6.1 v0.6.0 v0.6 v0.5.4 v0.5.3 v0.5.2 v0.5.1 v0.5.0 v0.4.5 v0.4.4 v0.4.3 v0.4.2 v0.4.1 v0.4.0
No related merge requests found
Showing with 125 additions and 125 deletions
+125 -125
import React, { useState, useCallback } from "react";
import { Layout, Menu, Switch as ToggleButton } from "antd";
import { NavLink } from "react-router-dom";
import { useThemeSwitcher } from "react-css-theme-switcher";
import { useLocation } from "react-router-dom";
import ROUTES from "constants/routes";
import { ThemeSwitcherWrapper, Logo } from "./styles";
const { Sider } = Layout;
import menus from "./menuItems";
const SideNav = (): JSX.Element => {
const { switcher, currentTheme, themes } = useThemeSwitcher();
const [collapsed, setCollapsed] = useState<boolean>(false);
const { pathname } = useLocation();
const toggleTheme = useCallback((isChecked: boolean) => {
switcher({ theme: isChecked ? themes.dark : themes.light });
}, []);
const onCollapse = useCallback(() => {
setCollapsed((collapsed) => !collapsed);
}, []);
return (
<Sider collapsible collapsed={collapsed} onCollapse={onCollapse} width={160}>
<ThemeSwitcherWrapper>
<ToggleButton
checked={currentTheme === themes.dark}
onChange={toggleTheme}
/>
</ThemeSwitcherWrapper>
<NavLink to="/">
<Logo src={"/signoz.svg"} alt="SigNoz" collapsed={collapsed} />
</NavLink>
<Menu
theme="dark"
defaultSelectedKeys={[ROUTES.APPLICATION]}
selectedKeys={[pathname]}
mode="inline"
>
{menus.map(({ to, Icon, name }) => (
<Menu.Item key={to} icon={<Icon />}>
<NavLink to={to} style={{ fontSize: 12, textDecoration: "none" }}>
{name}
</NavLink>
</Menu.Item>
))}
</Menu>
</Sider>
);
};
export default SideNav;
import {
BarChartOutlined,
AlignLeftOutlined,
DeploymentUnitOutlined,
LineChartOutlined,
SettingOutlined,
ApiOutlined,
} from "@ant-design/icons";
import ROUTES from "constants/routes";
const menus: SidebarMenu[] = [
{
Icon: BarChartOutlined,
to: ROUTES.APPLICATION,
name: "Metrics",
},
{
Icon: AlignLeftOutlined,
to: ROUTES.TRACES,
name: "Traces",
},
{
to: ROUTES.SERVICE_MAP,
name: "Service Map",
Icon: DeploymentUnitOutlined,
},
{
Icon: LineChartOutlined,
to: ROUTES.USAGE_EXPLORER,
name: "Usage Explorer",
},
{
Icon: SettingOutlined,
to: ROUTES.SETTINGS,
name: "Settings",
},
{
Icon: ApiOutlined,
to: ROUTES.INSTRUMENTATION,
name: "Add instrumentation",
},
];
interface SidebarMenu {
to: string;
name: string;
Icon: typeof ApiOutlined;
}
export default menus;
import styled from 'styled-components';
import styled from "styled-components";
export const ThemeSwitcherWrapper = styled.div`
display: flex;
......@@ -6,3 +6,13 @@ export const ThemeSwitcherWrapper = styled.div`
margin-top: 24px;
margin-bottom: 16px;
`;
export const Logo = styled.img<LogoProps>`
width: 100px;
margin: 5%;
display: ${({ collapsed }) => (!collapsed ? "block" : "none")};
`;
interface LogoProps {
collapsed: boolean;
}
......@@ -2,7 +2,7 @@ import { Layout } from 'antd';
import React, { ReactNode, useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import SideNav from './Nav/SideNav';
import SideNav from 'components/SideNav';
import TopNav from './Nav/TopNav';
import { useRoute } from './RouteProvider';
......
import {
AlignLeftOutlined,
ApiOutlined,
BarChartOutlined,
DeploymentUnitOutlined,
LineChartOutlined,
SettingOutlined,
} from '@ant-design/icons';
import { Layout, Menu, Switch as ToggleButton } from 'antd';
import ROUTES from 'constants/routes';
import React, { useEffect,useState } from 'react';
import { useThemeSwitcher } from 'react-css-theme-switcher';
import { NavLink } from 'react-router-dom';
import { useLocation } from 'react-router-dom';
import { ThemeSwitcherWrapper } from './styles';
const { Sider } = Layout;
const SideNav = () => {
const { switcher, currentTheme, status, themes } = useThemeSwitcher();
const [collapsed, setCollapsed] = useState<boolean>(false);
const [selectedKeys, setSelectedKeys] = useState<string[]>([
ROUTES.APPLICATION,
]);
const location = useLocation();
useEffect(() => {
const newRoute = location.pathname.split('/')[1];
setSelectedKeys([`/${newRoute}`]);
}, [location.pathname]);
if (status === 'loading' || location.pathname === ROUTES.SIGN_UP) {
return null;
}
const toggleTheme = (isChecked: boolean) => {
switcher({ theme: isChecked ? themes.dark : themes.light });
};
const onCollapse = (): void => {
setCollapsed(!collapsed);
};
return (
<Sider collapsible collapsed={collapsed} onCollapse={onCollapse} width={160}>
<div className="logo">
<ThemeSwitcherWrapper>
<ToggleButton
checked={currentTheme === themes.dark}
onChange={toggleTheme}
/>
</ThemeSwitcherWrapper>
<NavLink to="/">
<img
src={'/signoz.svg'}
alt={'SigNoz'}
style={{
margin: '5%',
width: 100,
display: !collapsed ? 'block' : 'none',
}}
/>
</NavLink>
</div>
<Menu
theme="dark"
defaultSelectedKeys={[ROUTES.APPLICATION]}
selectedKeys={selectedKeys}
mode="inline"
>
<Menu.Item key={ROUTES.APPLICATION} icon={<BarChartOutlined />}>
<NavLink
to={ROUTES.APPLICATION}
style={{ fontSize: 12, textDecoration: 'none' }}
>
Metrics
</NavLink>
</Menu.Item>
<Menu.Item key={ROUTES.TRACES} icon={<AlignLeftOutlined />}>
<NavLink
to={ROUTES.TRACES}
style={{ fontSize: 12, textDecoration: 'none' }}
>
Traces
</NavLink>
</Menu.Item>
<Menu.Item key={ROUTES.SERVICE_MAP} icon={<DeploymentUnitOutlined />}>
<NavLink
to={ROUTES.SERVICE_MAP}
style={{ fontSize: 12, textDecoration: 'none' }}
>
Service Map
</NavLink>
</Menu.Item>
<Menu.Item key={ROUTES.USAGE_EXPLORER} icon={<LineChartOutlined />}>
<NavLink
to={ROUTES.USAGE_EXPLORER}
style={{ fontSize: 12, textDecoration: 'none' }}
>
Usage Explorer
</NavLink>
</Menu.Item>
<Menu.Item key={ROUTES.SETTINGS} icon={<SettingOutlined />}>
<NavLink
to={ROUTES.SETTINGS}
style={{ fontSize: 12, textDecoration: 'none' }}
>
Settings
</NavLink>
</Menu.Item>
<Menu.Item key={ROUTES.INSTRUMENTATION} icon={<ApiOutlined />}>
<NavLink
to={ROUTES.INSTRUMENTATION}
style={{ fontSize: 12, textDecoration: 'none' }}
>
Add instrumentation
</NavLink>
</Menu.Item>
</Menu>
</Sider>
);
};
export default SideNav;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment