feat: remove sidebar dock option (#6083)

* feat: remove sidebar doc option

* feat: remove all references of sidebar collapse
This commit is contained in:
Yunus M 2024-09-27 12:08:25 +05:30 committed by GitHub
parent e4d1452f5f
commit 717545e14c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 43 additions and 212 deletions

View File

@ -6,7 +6,6 @@ export const AUTH0_REDIRECT_PATH = '/redirect';
export const DEFAULT_AUTH0_APP_REDIRECTION_PATH = ROUTES.APPLICATION; export const DEFAULT_AUTH0_APP_REDIRECTION_PATH = ROUTES.APPLICATION;
export const IS_SIDEBAR_COLLAPSED = 'isSideBarCollapsed';
export const INVITE_MEMBERS_HASH = '#invite-team-members'; export const INVITE_MEMBERS_HASH = '#invite-team-members';
export const SIGNOZ_UPGRADE_PLAN_URL = export const SIGNOZ_UPGRADE_PLAN_URL =

View File

@ -1,8 +1,4 @@
import { getUserOperatingSystem, UserOperatingSystem } from 'utils/getUserOS';
const userOS = getUserOperatingSystem();
export const GlobalShortcuts = { export const GlobalShortcuts = {
SidebarCollapse: '\\+meta',
NavigateToServices: 's+shift', NavigateToServices: 's+shift',
NavigateToTraces: 't+shift', NavigateToTraces: 't+shift',
NavigateToLogs: 'l+shift', NavigateToLogs: 'l+shift',
@ -13,7 +9,6 @@ export const GlobalShortcuts = {
}; };
export const GlobalShortcutsName = { export const GlobalShortcutsName = {
SidebarCollapse: `${userOS === UserOperatingSystem.MACOS ? 'cmd' : 'ctrl'}+\\`,
NavigateToServices: 'shift+s', NavigateToServices: 'shift+s',
NavigateToTraces: 'shift+t', NavigateToTraces: 'shift+t',
NavigateToLogs: 'shift+l', NavigateToLogs: 'shift+l',
@ -24,7 +19,6 @@ export const GlobalShortcutsName = {
}; };
export const GlobalShortcutsDescription = { export const GlobalShortcutsDescription = {
SidebarCollapse: 'Collpase the sidebar',
NavigateToServices: 'Navigate to Services page', NavigateToServices: 'Navigate to Services page',
NavigateToTraces: 'Navigate to Traces page', NavigateToTraces: 'Navigate to Traces page',
NavigateToLogs: 'Navigate to logs page', NavigateToLogs: 'Navigate to logs page',

View File

@ -16,12 +16,6 @@
width: 100%; width: 100%;
} }
} }
&.docked {
.app-content {
width: calc(100% - 240px);
}
}
} }
.chat-support-gateway { .chat-support-gateway {

View File

@ -5,13 +5,11 @@ import './AppLayout.styles.scss';
import * as Sentry from '@sentry/react'; import * as Sentry from '@sentry/react';
import { Flex } from 'antd'; import { Flex } from 'antd';
import getLocalStorageKey from 'api/browser/localstorage/get';
import getUserLatestVersion from 'api/user/getLatestVersion'; import getUserLatestVersion from 'api/user/getLatestVersion';
import getUserVersion from 'api/user/getVersion'; import getUserVersion from 'api/user/getVersion';
import cx from 'classnames'; import cx from 'classnames';
import ChatSupportGateway from 'components/ChatSupportGateway/ChatSupportGateway'; import ChatSupportGateway from 'components/ChatSupportGateway/ChatSupportGateway';
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar'; import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
import { IS_SIDEBAR_COLLAPSED } from 'constants/app';
import { FeatureKeys } from 'constants/features'; import { FeatureKeys } from 'constants/features';
import ROUTES from 'constants/routes'; import ROUTES from 'constants/routes';
import SideNav from 'container/SideNav'; import SideNav from 'container/SideNav';
@ -22,22 +20,13 @@ import useLicense from 'hooks/useLicense';
import { useNotifications } from 'hooks/useNotifications'; import { useNotifications } from 'hooks/useNotifications';
import history from 'lib/history'; import history from 'lib/history';
import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback'; import ErrorBoundaryFallback from 'pages/ErrorBoundaryFallback/ErrorBoundaryFallback';
import { import { ReactNode, useEffect, useMemo, useRef, useState } from 'react';
ReactNode,
useCallback,
useEffect,
useLayoutEffect,
useMemo,
useRef,
useState,
} from 'react';
import { Helmet } from 'react-helmet-async'; import { Helmet } from 'react-helmet-async';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useQueries } from 'react-query'; import { useQueries } from 'react-query';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { Dispatch } from 'redux'; import { Dispatch } from 'redux';
import { sideBarCollapse } from 'store/actions';
import { AppState } from 'store/reducers'; import { AppState } from 'store/reducers';
import AppActions from 'types/actions'; import AppActions from 'types/actions';
import { import {
@ -59,10 +48,6 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
(state) => state.app, (state) => state.app,
); );
const [collapsed, setCollapsed] = useState<boolean>(
getLocalStorageKey(IS_SIDEBAR_COLLAPSED) === 'true',
);
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const isDarkMode = useIsDarkMode(); const isDarkMode = useIsDarkMode();
@ -117,14 +102,6 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
const latestCurrentCounter = useRef(0); const latestCurrentCounter = useRef(0);
const latestVersionCounter = useRef(0); const latestVersionCounter = useRef(0);
const onCollapse = useCallback(() => {
setCollapsed((collapsed) => !collapsed);
}, []);
useLayoutEffect(() => {
dispatch(sideBarCollapse(collapsed));
}, [collapsed, dispatch]);
useEffect(() => { useEffect(() => {
if ( if (
getUserLatestVersionResponse.isFetched && getUserLatestVersionResponse.isFetched &&
@ -279,23 +256,8 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
} }
}, [isDarkMode]); }, [isDarkMode]);
const isSideNavCollapsed = getLocalStorageKey(IS_SIDEBAR_COLLAPSED);
/**
* Note: Right now we don't have a page-level method to pass the sidebar collapse state.
* Since the use case for overriding is not widely needed, we are setting it here
* so that the workspace locked page will have an expanded sidebar regardless of how users
* have set it or what is stored in localStorage. This will not affect the localStorage config.
*/
const isWorkspaceLocked = pathname === ROUTES.WORKSPACE_LOCKED;
return ( return (
<Layout <Layout className={cx(isDarkMode ? 'darkMode' : 'lightMode')}>
className={cx(
isDarkMode ? 'darkMode' : 'lightMode',
isSideNavCollapsed ? 'sidebarCollapsed' : '',
)}
>
<Helmet> <Helmet>
<title>{pageTitle}</title> <title>{pageTitle}</title>
</Helmet> </Helmet>
@ -321,25 +283,11 @@ function AppLayout(props: AppLayoutProps): JSX.Element {
</div> </div>
)} )}
<Flex <Flex className={cx('app-layout', isDarkMode ? 'darkMode' : 'lightMode')}>
className={cx(
'app-layout',
isDarkMode ? 'darkMode' : 'lightMode',
!collapsed && !renderFullScreen ? 'docked' : '',
)}
>
{isToDisplayLayout && !renderFullScreen && ( {isToDisplayLayout && !renderFullScreen && (
<SideNav <SideNav licenseData={licenseData} isFetching={isFetching} />
licenseData={licenseData}
isFetching={isFetching}
onCollapse={onCollapse}
collapsed={isWorkspaceLocked ? false : collapsed}
/>
)} )}
<div <div className="app-content" data-overlayscrollbars-initialize>
className={cx('app-content', collapsed ? 'collapsed' : '')}
data-overlayscrollbars-initialize
>
<Sentry.ErrorBoundary fallback={<ErrorBoundaryFallback />}> <Sentry.ErrorBoundary fallback={<ErrorBoundaryFallback />}>
<LayoutContent data-overlayscrollbars-initialize> <LayoutContent data-overlayscrollbars-initialize>
<OverlayScrollbar> <OverlayScrollbar>

View File

@ -3,10 +3,6 @@
height: 100%; height: 100%;
position: relative; position: relative;
z-index: 1; z-index: 1;
&.docked {
width: 240px;
}
} }
.sideNav { .sideNav {
@ -229,39 +225,6 @@
display: block; display: block;
} }
} }
&.docked {
flex: 0 0 240px;
max-width: 240px;
min-width: 240px;
width: 240px;
.secondary-nav-items {
width: 240px;
}
.brand {
justify-content: space-between;
}
.get-started-nav-items {
.get-started-btn {
justify-content: flex-start;
}
}
.collapse-expand-handlers {
display: block;
}
.nav-item-label {
display: block;
}
.nav-item-beta {
display: block;
}
}
} }
.lightMode { .lightMode {

View File

@ -3,7 +3,7 @@
import './SideNav.styles.scss'; import './SideNav.styles.scss';
import { Color } from '@signozhq/design-tokens'; import { Color } from '@signozhq/design-tokens';
import { Button, Tooltip } from 'antd'; import { Button } from 'antd';
import logEvent from 'api/common/logEvent'; import logEvent from 'api/common/logEvent';
import cx from 'classnames'; import cx from 'classnames';
import { FeatureKeys } from 'constants/features'; import { FeatureKeys } from 'constants/features';
@ -16,9 +16,6 @@ import history from 'lib/history';
import { import {
AlertTriangle, AlertTriangle,
CheckSquare, CheckSquare,
ChevronLeftCircle,
ChevronRightCircle,
PanelRight,
RocketIcon, RocketIcon,
UserCircle, UserCircle,
} from 'lucide-react'; } from 'lucide-react';
@ -55,13 +52,9 @@ interface UserManagementMenuItems {
function SideNav({ function SideNav({
licenseData, licenseData,
isFetching, isFetching,
onCollapse,
collapsed,
}: { }: {
licenseData: any; licenseData: any;
isFetching: boolean; isFetching: boolean;
onCollapse: () => void;
collapsed: boolean;
}): JSX.Element { }): JSX.Element {
const [menuItems, setMenuItems] = useState(defaultMenuItems); const [menuItems, setMenuItems] = useState(defaultMenuItems);
@ -330,8 +323,6 @@ function SideNav({
}; };
useEffect(() => { useEffect(() => {
registerShortcut(GlobalShortcuts.SidebarCollapse, onCollapse);
registerShortcut(GlobalShortcuts.NavigateToServices, () => registerShortcut(GlobalShortcuts.NavigateToServices, () =>
onClickHandler(ROUTES.APPLICATION, null), onClickHandler(ROUTES.APPLICATION, null),
); );
@ -359,7 +350,6 @@ function SideNav({
); );
return (): void => { return (): void => {
deregisterShortcut(GlobalShortcuts.SidebarCollapse);
deregisterShortcut(GlobalShortcuts.NavigateToServices); deregisterShortcut(GlobalShortcuts.NavigateToServices);
deregisterShortcut(GlobalShortcuts.NavigateToTraces); deregisterShortcut(GlobalShortcuts.NavigateToTraces);
deregisterShortcut(GlobalShortcuts.NavigateToLogs); deregisterShortcut(GlobalShortcuts.NavigateToLogs);
@ -368,11 +358,11 @@ function SideNav({
deregisterShortcut(GlobalShortcuts.NavigateToExceptions); deregisterShortcut(GlobalShortcuts.NavigateToExceptions);
deregisterShortcut(GlobalShortcuts.NavigateToMessagingQueues); deregisterShortcut(GlobalShortcuts.NavigateToMessagingQueues);
}; };
}, [deregisterShortcut, onClickHandler, onCollapse, registerShortcut]); }, [deregisterShortcut, onClickHandler, registerShortcut]);
return ( return (
<div className={cx('sidenav-container', !collapsed ? 'docked' : '')}> <div className={cx('sidenav-container')}>
<div className={cx('sideNav', !collapsed ? 'docked' : '')}> <div className={cx('sideNav')}>
<div className="brand"> <div className="brand">
<div className="brand-company-meta"> <div className="brand-company-meta">
<div <div
@ -392,17 +382,6 @@ function SideNav({
<div className="license tag nav-item-label">{licenseTag}</div> <div className="license tag nav-item-label">{licenseTag}</div>
)} )}
</div> </div>
<Tooltip
title={collapsed ? 'Dock Sidebar' : 'Undock Sidebar'}
placement="right"
>
<Button
className="periscope-btn nav-item-label dockBtn"
icon={<PanelRight size={16} />}
onClick={onCollapse}
/>
</Tooltip>
</div> </div>
{isCloudUserVal && ( {isCloudUserVal && (
@ -504,14 +483,6 @@ function SideNav({
}} }}
/> />
)} )}
<div className="collapse-expand-handlers" onClick={onCollapse}>
{collapsed ? (
<ChevronRightCircle size={18} />
) : (
<ChevronLeftCircle size={18} />
)}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,6 +1,7 @@
.trace-explorer-header { .trace-explorer-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
.trace-explorer-run-query { .trace-explorer-run-query {
display: flex; display: flex;

View File

@ -1 +0,0 @@
export * from './sideBarCollapse';

View File

@ -1,16 +0,0 @@
import setLocalStorageKey from 'api/browser/localstorage/set';
import { IS_SIDEBAR_COLLAPSED } from 'constants/app';
import { Dispatch } from 'redux';
import AppActions from 'types/actions';
export const sideBarCollapse = (
collapseState: boolean,
): ((dispatch: Dispatch<AppActions>) => void) => {
setLocalStorageKey(IS_SIDEBAR_COLLAPSED, `${collapseState}`);
return (dispatch: Dispatch<AppActions>): void => {
dispatch({
type: 'SIDEBAR_COLLAPSE',
payload: collapseState,
});
};
};

View File

@ -1,4 +1,3 @@
export * from './app';
export * from './global'; export * from './global';
export * from './metrics'; export * from './metrics';
export * from './serviceMap'; export * from './serviceMap';

View File

@ -1,11 +1,9 @@
import getLocalStorageKey from 'api/browser/localstorage/get'; import getLocalStorageKey from 'api/browser/localstorage/get';
import { IS_SIDEBAR_COLLAPSED } from 'constants/app';
import { LOCALSTORAGE } from 'constants/localStorage'; import { LOCALSTORAGE } from 'constants/localStorage';
import { getInitialUserTokenRefreshToken } from 'store/utils'; import { getInitialUserTokenRefreshToken } from 'store/utils';
import { import {
AppAction, AppAction,
LOGGED_IN, LOGGED_IN,
SIDEBAR_COLLAPSE,
UPDATE_CONFIGS, UPDATE_CONFIGS,
UPDATE_CURRENT_ERROR, UPDATE_CURRENT_ERROR,
UPDATE_CURRENT_VERSION, UPDATE_CURRENT_VERSION,
@ -44,7 +42,6 @@ const getInitialUser = (): User | null => {
const InitialValue: InitialValueTypes = { const InitialValue: InitialValueTypes = {
isLoggedIn: getLocalStorageKey(LOCALSTORAGE.IS_LOGGED_IN) === 'true', isLoggedIn: getLocalStorageKey(LOCALSTORAGE.IS_LOGGED_IN) === 'true',
isSideBarCollapsed: getLocalStorageKey(IS_SIDEBAR_COLLAPSED) === 'true',
currentVersion: '', currentVersion: '',
latestVersion: '', latestVersion: '',
featureResponse: { featureResponse: {
@ -76,13 +73,6 @@ const appReducer = (
}; };
} }
case SIDEBAR_COLLAPSE: {
return {
...state,
isSideBarCollapsed: action.payload,
};
}
case UPDATE_FEATURE_FLAG_RESPONSE: { case UPDATE_FEATURE_FLAG_RESPONSE: {
return { return {
...state, ...state,

View File

@ -34,11 +34,6 @@ export interface LoggedInUser {
}; };
} }
export interface SideBarCollapse {
type: typeof SIDEBAR_COLLAPSE;
payload: boolean;
}
export interface UpdateAppVersion { export interface UpdateAppVersion {
type: typeof UPDATE_CURRENT_VERSION; type: typeof UPDATE_CURRENT_VERSION;
payload: { payload: {
@ -137,7 +132,6 @@ export interface UpdateFeatureFlag {
export type AppAction = export type AppAction =
| LoggedInUser | LoggedInUser
| SideBarCollapse
| UpdateAppVersion | UpdateAppVersion
| UpdateLatestVersion | UpdateLatestVersion
| UpdateVersionError | UpdateVersionError

View File

@ -17,7 +17,6 @@ export interface User {
export default interface AppReducer { export default interface AppReducer {
isLoggedIn: boolean; isLoggedIn: boolean;
isSideBarCollapsed: boolean;
currentVersion: string; currentVersion: string;
latestVersion: string; latestVersion: string;
isCurrentVersionError: boolean; isCurrentVersionError: boolean;

View File

@ -1,38 +1,34 @@
{ {
"cookies": [], "cookies": [],
"origins": [ "origins": [
{ {
"origin": "http://localhost:3301", "origin": "http://localhost:3301",
"localStorage": [ "localStorage": [
{ {
"name": "isSideBarCollapsed", "name": "metricsTimeDurations",
"value": "false" "value": "{}"
}, },
{ {
"name": "metricsTimeDurations", "name": "i18nextLng",
"value": "{}" "value": "en-US"
}, },
{ {
"name": "i18nextLng", "name": "reactQueryDevtoolsSortFn",
"value": "en-US" "value": "\"Status > Last Updated\""
}, },
{ {
"name": "reactQueryDevtoolsSortFn", "name": "AUTH_TOKEN",
"value": "\"Status > Last Updated\"" "value": "authtoken"
}, },
{ {
"name": "AUTH_TOKEN", "name": "IS_LOGGED_IN",
"value": "authtoken" "value": "true"
}, },
{ {
"name": "IS_LOGGED_IN", "name": "REFRESH_AUTH_TOKEN",
"value": "true" "value": "refreshJwt"
}, }
{ ]
"name": "REFRESH_AUTH_TOKEN", }
"value": "refreshJwt" ]
} }
]
}
]
}