Skip to content

Commit

Permalink
feat(ui): conditionally display "New Note" button based on authentica…
Browse files Browse the repository at this point in the history
…tion status (#379)
  • Loading branch information
CorentinTh authored Dec 29, 2024
1 parent 1fe0190 commit dbc52a6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/app-client/src/modules/ui/layouts/app.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export const Navbar: Component = () => {
navigate('/');
};

// Only show the "New Note" button if the user is authenticated or if authentication is not required
const getShouldShowNewNoteButton = () => config.isAuthenticationRequired ? authStore.getIsAuthenticated() : true;

return (
<div class="border-b border-border bg-surface">
<div class="flex items-center justify-between px-6 py-3 mx-auto max-w-1200px">
Expand All @@ -96,10 +99,13 @@ export const Navbar: Component = () => {
</div>

<div class="flex gap-2 items-center">
<Button variant="secondary" onClick={newNoteClicked}>
<div class="i-tabler-plus mr-1 text-muted-foreground"></div>
{t('navbar.new-note')}
</Button>

{getShouldShowNewNoteButton() && (
<Button variant="secondary" onClick={newNoteClicked}>
<div class="i-tabler-plus mr-1 text-muted-foreground"></div>
{t('navbar.new-note')}
</Button>
)}

<Button variant="ghost" class="text-lg px-0 size-9 hidden md:inline-flex" as={A} href="https://github.com/CorentinTh/enclosed" target="_blank" rel="noopener noreferrer" aria-label={t('navbar.github-repository')}>
<div class="i-tabler-brand-github"></div>
Expand Down

0 comments on commit dbc52a6

Please sign in to comment.