* fix(player): fix initial visual offset jump check * change(ui): add empty feature flags page * change(ui): add empty feature flags page * fix(ui): some more fixes * change(ui): add subrouting for sessions tab * change(ui): more fixes for routing * change(ui): add flag creation page, flags list table, flag store/type * change(tracker): flags in tracker * change(tracker): return all flags * feat(ui): add API and types connector * feat(ui): split components to prevent rerendering * feat(ui): add icon, fix redirect.path crashlooping * feat(ui): add conditions and stuff, add flags class to tracker to handle stuff * feat(ui): add condition state and filters * feat(ui): fix flag creation with api change * feat(ui): fix flag editing (api changes); simplify new/edit flag component * feat(ui): add filters, make table pretty :insert_magic_emoji: * feat(ui): remove rollout percentage from list, remove console logs * feat(ui): multivar toggler * feat(tracker): add more methods to tracker * feat(tracker): more type coverage * feat(tracker): add tests * fix(ui): some fixes for multivar * feat(ui): multivar api support * fix(ui):start adding tests for fflags * fix(ui): rm not working file.. * fix(ui): rm unused packages * fix(ui): remove name field, fix some api and type names * fix(ui): fix crash * fix(tracker/ui): keep flags in sessionStorage, support API errors in feature flags storage * fix(tracker/ui): clear unused things, fix url handling, fix icons rendering etc
89 lines
2.9 KiB
TypeScript
89 lines
2.9 KiB
TypeScript
import React from 'react';
|
|
import { SideMenuitem } from 'UI';
|
|
import { connect } from 'react-redux';
|
|
import { setActiveTab } from 'Duck/search';
|
|
import { withRouter, RouteComponentProps } from 'react-router-dom';
|
|
import { sessions, fflags, withSiteId, notes } from "App/routes";
|
|
|
|
interface Props {
|
|
setActiveTab: (tab: any) => void;
|
|
activeTab: string;
|
|
isEnterprise: boolean;
|
|
}
|
|
|
|
const TabToUrlMap = {
|
|
all: sessions() as '/sessions',
|
|
bookmark: sessions() as '/sessions',
|
|
notes: notes() as '/notes',
|
|
flags: fflags() as '/feature-flags',
|
|
}
|
|
|
|
function OverviewMenu(props: Props & RouteComponentProps) {
|
|
// @ts-ignore
|
|
const { activeTab, isEnterprise, history, match: { params: { siteId } }, location } = props;
|
|
|
|
React.useEffect(() => {
|
|
const currentLocation = location.pathname;
|
|
const tab = Object.keys(TabToUrlMap).find((tab: keyof typeof TabToUrlMap) => currentLocation.includes(TabToUrlMap[tab]));
|
|
if (tab && tab !== activeTab) {
|
|
props.setActiveTab({ type: tab })
|
|
}
|
|
}, [location.pathname])
|
|
return (
|
|
<div className={"flex flex-col gap-2 w-full"}>
|
|
<div className="w-full">
|
|
<SideMenuitem
|
|
active={activeTab === 'all'}
|
|
id="menu-sessions"
|
|
title="Sessions"
|
|
iconName="play-circle-bold"
|
|
onClick={() => {
|
|
props.setActiveTab({ type: 'all' })
|
|
!location.pathname.includes(sessions()) && history.push(withSiteId(sessions(), siteId))
|
|
}}
|
|
/>
|
|
</div>
|
|
<div className="w-full">
|
|
<SideMenuitem
|
|
active={activeTab === 'bookmark'}
|
|
id="menu-bookmarks"
|
|
title={`${isEnterprise ? 'Vault' : 'Bookmarks'}`}
|
|
iconName={ isEnterprise ? "safe" : "star" }
|
|
onClick={() => {
|
|
props.setActiveTab({ type: 'bookmark' })
|
|
!location.pathname.includes(sessions()) && history.push(withSiteId(sessions(), siteId))
|
|
}}
|
|
/>
|
|
</div>
|
|
<div className="w-full">
|
|
<SideMenuitem
|
|
active={activeTab === 'notes'}
|
|
id="menu-notes"
|
|
title="Notes"
|
|
iconName="stickies"
|
|
onClick={() => {
|
|
props.setActiveTab({ type: 'notes' })
|
|
!location.pathname.includes(notes()) && history.push(withSiteId(notes(), siteId))
|
|
}}
|
|
/>
|
|
</div>
|
|
<div className="w-full">
|
|
<SideMenuitem
|
|
active={activeTab === 'flags'}
|
|
id="menu-flags"
|
|
title="Feature Flags"
|
|
iconName="toggles"
|
|
onClick={() => {
|
|
props.setActiveTab({ type: 'flags' })
|
|
!location.pathname.includes(fflags()) && history.push(withSiteId(fflags(), siteId))
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default connect((state: any) => ({
|
|
activeTab: state.getIn(['search', 'activeTab', 'type']),
|
|
isEnterprise: state.getIn(['user', 'account', 'edition']) === 'ee',
|
|
}), { setActiveTab })(withRouter(OverviewMenu));
|