Skip to content

Commit

Permalink
conditionally hide live tail for https protocol (#177)
Browse files Browse the repository at this point in the history
Co-authored-by: nativ-labs <[email protected]>
  • Loading branch information
balaji-jr and nativ-labs authored Jan 17, 2024
1 parent 8044675 commit e87fee2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ import Cookies from 'js-cookie';
import { NAVBAR_WIDTH } from '@/constants/theme';
const baseURL = import.meta.env.VITE_PARSEABLE_URL ?? '/';

const isSecureConnection = window.location.protocol === 'https:';
const links = [
{ icon: IconZoomCode, label: 'SQL', pathname: '/query', requiredAccess: ['Query', 'GetSchema'] },
{ icon: IconTableShortcut, label: 'Explore', pathname: '/logs', requiredAccess: ['Query', 'GetSchema'] },
{ icon: IconTimelineEvent, label: 'Live tail', pathname: '/live-tail', requiredAccess: ['GetLiveTail'] },
...(!isSecureConnection ? [{ icon: IconTimelineEvent, label: 'Live tail', pathname: '/live-tail', requiredAccess: ['GetLiveTail'] }] : []),
{ icon: IconReportAnalytics, label: 'Stats', pathname: '/stats', requiredAccess: ['GetStats'] },
{ icon: IconSettings, label: 'Config', pathname: '/config', requiredAccess: ['PutAlert'] },
];
Expand Down
11 changes: 6 additions & 5 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import AccessSpecificRoute from './AccessSpecificRoute';
import OIDCNotConFigured from '@/pages/Errors/OIDC';

const AppRouter: FC = () => {
const isSecureConnection = window.location.protocol === 'https:';
return (
<FullPageLayout>
<Routes>
Expand All @@ -47,11 +48,11 @@ const AppRouter: FC = () => {
<Route path={LOGS_ROUTE} element={<LogsElement />} />
<Route path={QUERY_ROUTE} element={<QueryElement />} />
</Route>

<Route element={<AccessSpecificRoute accessRequired={['GetLiveTail']} />}>
<Route path={LIVE_TAIL_ROUTE} element={<LiveTailElement />} />
</Route>

{!isSecureConnection && (
<Route element={<AccessSpecificRoute accessRequired={['GetLiveTail']} />}>
<Route path={LIVE_TAIL_ROUTE} element={<LiveTailElement />} />
</Route>
)}
<Route element={<AccessSpecificRoute accessRequired={['GetStats']} />}>
<Route path={STATS_ROUTE} element={<StatsElement />} />
</Route>
Expand Down

0 comments on commit e87fee2

Please sign in to comment.