Skip to content

Commit

Permalink
chore(auth): allow access to dev section for unauthenticated users
Browse files Browse the repository at this point in the history
This will allow to access following functionalities:
- Define as compromised run
- Dev section of bublik for import/tasks

Restrictions should be forced on backend currently

Signed-off-by: Danil Kostromin <[email protected]>
  • Loading branch information
Danil Kostromin committed Jan 17, 2024
1 parent 5bd5778 commit f90f704
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 51 deletions.
7 changes: 4 additions & 3 deletions apps/bublik/src/pages/developers-page/developers-page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* SPDX-FileCopyrightText: 2021-2023 OKTET Labs Ltd. */
import { IframeToOldBublik } from '@/shared/tailwind-ui';
import { Outlet } from 'react-router-dom';

import { config } from '@/bublik/config';
import { useDocumentTitle } from '@/shared/hooks';
import { PrivateRouteLayoutOutlet } from '@/bublik/features/auth';
import { IframeToOldBublik } from '@/shared/tailwind-ui';

export const FlowerFeature = () => {
useDocumentTitle('Flower - Bublik');
Expand All @@ -20,5 +21,5 @@ export const FlowerFeature = () => {
export const DevelopersLayout = () => {
useDocumentTitle('Dev - Bublik');

return <PrivateRouteLayoutOutlet />;
return <Outlet />;
};
76 changes: 31 additions & 45 deletions apps/bublik/src/pages/run-page/run-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@
import { useState } from 'react';
import { Link, useParams } from 'react-router-dom';

import { RunPageParams } from '@/shared/types';
import { useCopyToClipboard } from '@/shared/hooks';
import { DefineCompromiseContainer } from '@/bublik/features/compromised-form';
import { LinkToSourceContainer } from '@/bublik/features/link-to-source';
import { RunTableContainer } from '@/bublik/features/run';
import { RunDetailsContainer } from '@/bublik/features/run-details';
import { DiffFormContainer } from '@/bublik/features/run-diff';
import { routes } from '@/router';
import { usePrefetchLogPage } from '@/services/bublik-api';
import { useCopyToClipboard } from '@/shared/hooks';
import {
RunModeToggle,
ButtonTw,
CardHeader,
Icon,
RunModeToggle,
ScrollToTopPage,
toast,
Icon,
Tooltip,
ButtonTw
Tooltip
} from '@/shared/tailwind-ui';
import { DiffFormContainer } from '@/bublik/features/run-diff';
import { DefineCompromiseContainer } from '@/bublik/features/compromised-form';
import { LinkToSourceContainer } from '@/bublik/features/link-to-source';
import { RunDetailsContainer } from '@/bublik/features/run-details';
import { RunTableContainer } from '@/bublik/features/run';
import { usePrefetchLogPage } from '@/services/bublik-api';
import { useAuth } from '@/bublik/features/auth';
import { RunPageParams } from '@/shared/types';

export interface RunHeaderProps {
runId: string;
Expand All @@ -35,45 +34,32 @@ const RunHeader = ({ runId }: RunHeaderProps) => {
onError: () =>
toast.error('Failed to copy run ID', { position: 'top-center' })
});
const { isLoading, isAdmin } = useAuth();

const handleCopyRunId = () => copy(runId);

return (
<header className="flex flex-col bg-white rounded min-h-[260px]">
<CardHeader label="Info">
<div className="flex h-full gap-3">
{isLoading ? null : (
<>
<RunModeToggle
isFullMode={isModeFull}
onToggleClick={() => setIsModeFull(!isModeFull)}
/>
<Tooltip content="Copy identifier for comparison">
<ButtonTw
variant="secondary"
size="xss"
onClick={handleCopyRunId}
>
<Icon
name="PaperStack"
size={16}
className="mr-1 text-primary"
/>
Copy ID
</ButtonTw>
</Tooltip>
<DiffFormContainer defaultValues={{ leftRunId: Number(runId) }} />
{isAdmin ? <DefineCompromiseContainer runId={runId} /> : null}
<LinkToSourceContainer runId={runId} />
<ButtonTw asChild variant="secondary" size="xss">
<Link to={routes.log({ runId })}>
<Icon name="BoxArrowRight" className="mr-1.5" />
Log
</Link>
</ButtonTw>
</>
)}
<RunModeToggle
isFullMode={isModeFull}
onToggleClick={() => setIsModeFull(!isModeFull)}
/>
<Tooltip content="Copy identifier for comparison">
<ButtonTw variant="secondary" size="xss" onClick={handleCopyRunId}>
<Icon name="PaperStack" size={16} className="mr-1 text-primary" />
Copy ID
</ButtonTw>
</Tooltip>
<DiffFormContainer defaultValues={{ leftRunId: Number(runId) }} />
<DefineCompromiseContainer runId={runId} />
<LinkToSourceContainer runId={runId} />
<ButtonTw asChild variant="secondary" size="xss">
<Link to={routes.log({ runId })}>
<Icon name="BoxArrowRight" className="mr-1.5" />
Log
</Link>
</ButtonTw>
</div>
</CardHeader>
<RunDetailsContainer runId={runId} isFullMode={isModeFull} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ const getNavSections = (isAdmin: boolean) => {
}
];

if (isAdmin) return [devSection, ...bottomNav];

return bottomNav;
return [devSection, ...bottomNav];
};

export const BottomNavigation = () => {
Expand Down

0 comments on commit f90f704

Please sign in to comment.