Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/layout/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"languageSwitcher": {
"switchTo": "Zu {{ lang }} wechseln"
},
"tools": {
"login": "Anmelden",
"logout": "Abmelden"
},
"contenttypes": {
"common": {
"size": "Größe:"
Expand Down
4 changes: 4 additions & 0 deletions packages/layout/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"languageSwitcher": {
"switchTo": "Switch to {{ lang }}"
},
"tools": {
"login": "Log in",
"logout": "Log out"
},
"contenttypes": {
"common": {
"size": "Size:"
Expand Down
4 changes: 4 additions & 0 deletions packages/layout/locales/it/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"languageSwitcher": {
"switchTo": "Passa a {{ lang }}"
},
"tools": {
"login": "Accedi",
"logout": "Esci"
},
"contenttypes": {
"common": {
"size": "Dimensione:"
Expand Down
1 change: 1 addition & 0 deletions packages/layout/news/+header-tools-auth.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show only the login or logout header tool based on authentication state instead of always rendering both in development. @aryan7081
44 changes: 18 additions & 26 deletions packages/layout/slots/Tools.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
import { Link } from 'react-aria-components';
import { useTranslation } from 'react-i18next';
import { Link } from '@plone/components';
import { useRouteLoaderData } from 'react-router';
import type { RootLoader } from '@plone/aurora/app/root';

const HeaderTools = () => {
const links = [
{
id: '1',
label: 'login',
icon: '🔧',
url: '/login',
},
{
id: '2',
label: 'logout',
icon: '🔨',
url: '/logout',
},
];
// Inline styles since this is temporary during seven development
return import.meta.env.DEV ? (
<div style={{ display: 'flex', gap: '16px' }}>
{links.map((tool) => (
<Link key={tool.id} href={tool.url}>
<span>{tool.icon}</span>
<span>{tool.label}</span>
</Link>
))}
</div>
) : null;
const { t } = useTranslation();
const rootData = useRouteLoaderData<RootLoader>('root');
const isAuthenticated = rootData?.isAuthenticated ?? false;

// Convenience auth links while developing Plone Aurora.
if (!import.meta.env.DEV) {
return null;
}

return isAuthenticated ? (
<Link href="/logout">{t('layout.tools.logout', 'Log out')}</Link>
) : (
<Link href="/login">{t('layout.tools.login', 'Log in')}</Link>
);
};

export default HeaderTools;
Loading