u
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useRef, useEffect, Suspense } from 'react';
|
import { useState, useRef, useEffect, Suspense } from 'react';
|
||||||
import { Outlet, useLocation } from 'react-router-dom';
|
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import CircularProgress from '@mui/material/CircularProgress';
|
import CircularProgress from '@mui/material/CircularProgress';
|
||||||
import Popover from '@mui/material/Popover';
|
import Popover from '@mui/material/Popover';
|
||||||
@@ -13,7 +13,9 @@ import SettingsIcon from '@mui/icons-material/Settings';
|
|||||||
import { enqueueSnackbar } from 'notistack';
|
import { enqueueSnackbar } from 'notistack';
|
||||||
import PageLayout from './PageLayout';
|
import PageLayout from './PageLayout';
|
||||||
import { NAV_ITEMS, SUB_NAV, resolveActiveSub } from '../nav';
|
import { NAV_ITEMS, SUB_NAV, resolveActiveSub } from '../nav';
|
||||||
import { isKategorienPath } from './category/categoryRoute';
|
import { isKategorienPath, buildCategoryPath, KATEGORIEN_BASE } from './category/categoryRoute';
|
||||||
|
import CategoryBreadcrumbs from './category/CategoryBreadcrumbs';
|
||||||
|
import { getCategoryBreadcrumbs, resolveCategoryIdFromSlugPath } from '../utils/categoryUtils';
|
||||||
import categoryAutomat from '../automats/categoryAutomat';
|
import categoryAutomat from '../automats/categoryAutomat';
|
||||||
import { ActionElevatedPill, ToggleElevatedPill } from 'dashgui/ElevatedPill';
|
import { ActionElevatedPill, ToggleElevatedPill } from 'dashgui/ElevatedPill';
|
||||||
import { article, category } from '../api';
|
import { article, category } from '../api';
|
||||||
@@ -41,6 +43,7 @@ function selectCatSlice(s) {
|
|||||||
|
|
||||||
export default function SectionLayout({ sectionPath }) {
|
export default function SectionLayout({ sectionPath }) {
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
const importInputRef = useRef(null);
|
const importInputRef = useRef(null);
|
||||||
const [extrasAnchor, setExtrasAnchor] = useState(null);
|
const [extrasAnchor, setExtrasAnchor] = useState(null);
|
||||||
const [importing, setImporting] = useState(false);
|
const [importing, setImporting] = useState(false);
|
||||||
@@ -141,18 +144,39 @@ export default function SectionLayout({ sectionPath }) {
|
|||||||
importInputRef.current?.click();
|
importInputRef.current?.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let crumbs = [];
|
||||||
|
if (showsRenameSwitch && categories && rootCategoryId != null) {
|
||||||
|
const slugPath = pathname
|
||||||
|
.slice(KATEGORIEN_BASE.length)
|
||||||
|
.split('/')
|
||||||
|
.filter(Boolean)
|
||||||
|
.map((seg) => {
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(seg);
|
||||||
|
} catch {
|
||||||
|
return seg;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.join('/');
|
||||||
|
const catId = resolveCategoryIdFromSlugPath(categories, rootCategoryId, slugPath);
|
||||||
|
if (catId != null) crumbs = getCategoryBreadcrumbs(categories, catId, rootCategoryId);
|
||||||
|
}
|
||||||
|
|
||||||
const titleAction = showsRenameSwitch ? (
|
const titleAction = showsRenameSwitch ? (
|
||||||
<Box sx={{ display: 'inline-flex', gap: 1 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, flex: 1, minWidth: 0 }}>
|
||||||
<ToggleElevatedPill
|
<CategoryBreadcrumbs
|
||||||
label="Edit"
|
crumbs={crumbs}
|
||||||
checked={renameMode}
|
variant="h6"
|
||||||
onToggle={(checked) => categoryAutomat.actions.setRenameMode(checked)}
|
sx={{ m: 0, minWidth: 0 }}
|
||||||
/>
|
onNavigate={(id) => navigate(buildCategoryPath(categories, rootCategoryId, id))}
|
||||||
<ActionElevatedPill
|
|
||||||
label="Extras"
|
|
||||||
icon={<SettingsIcon sx={{ fontSize: 18 }} />}
|
|
||||||
onClick={(event) => setExtrasAnchor(event.currentTarget)}
|
|
||||||
/>
|
/>
|
||||||
|
<Box sx={{ ml: 'auto', display: 'inline-flex' }}>
|
||||||
|
<ToggleElevatedPill
|
||||||
|
label="Edit"
|
||||||
|
checked={renameMode}
|
||||||
|
onToggle={(checked) => categoryAutomat.actions.setRenameMode(checked)}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
<input
|
<input
|
||||||
ref={importInputRef}
|
ref={importInputRef}
|
||||||
type="file"
|
type="file"
|
||||||
@@ -195,8 +219,9 @@ export default function SectionLayout({ sectionPath }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<PageLayout
|
<PageLayout
|
||||||
title={pageTitle}
|
title={showsRenameSwitch ? '' : pageTitle}
|
||||||
showTitle={!isArticleDetail}
|
showTitle={!isArticleDetail}
|
||||||
|
titleWide={showsRenameSwitch ? 99 : undefined}
|
||||||
titleAction={titleAction}
|
titleAction={titleAction}
|
||||||
>
|
>
|
||||||
<Suspense
|
<Suspense
|
||||||
|
|||||||
@@ -8,18 +8,18 @@ class CategoryBreadcrumbs extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { crumbs } = this.props;
|
const { crumbs, sx, variant = 'body2' } = this.props;
|
||||||
const visible = (crumbs ?? []).filter((crumb) => crumb.name);
|
const visible = (crumbs ?? []).filter((crumb) => crumb.name);
|
||||||
if (visible.length === 0) return null;
|
if (visible.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Breadcrumbs sx={{ mb: 2 }} aria-label="Kategoriepfad">
|
<Breadcrumbs sx={sx ?? { mb: 2 }} aria-label="Kategoriepfad">
|
||||||
{visible.map((crumb, index) => (
|
{visible.map((crumb, index) => (
|
||||||
<Link
|
<Link
|
||||||
key={crumb.id}
|
key={crumb.id}
|
||||||
component="button"
|
component="button"
|
||||||
type="button"
|
type="button"
|
||||||
variant="body2"
|
variant={variant}
|
||||||
underline="always"
|
underline="always"
|
||||||
color="inherit"
|
color="inherit"
|
||||||
aria-current={index === visible.length - 1 ? 'page' : undefined}
|
aria-current={index === visible.length - 1 ? 'page' : undefined}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { enqueueSnackbar } from 'notistack';
|
|||||||
import BackendError from '../../components/BackendError';
|
import BackendError from '../../components/BackendError';
|
||||||
import CategorySortable from '../../components/category/CategorySortable';
|
import CategorySortable from '../../components/category/CategorySortable';
|
||||||
import CategoryPickerDialog from '../../components/article/CategoryPickerDialog';
|
import CategoryPickerDialog from '../../components/article/CategoryPickerDialog';
|
||||||
import { NewCategoryTile, CategoryBreadcrumbs } from '../../components/category';
|
import { NewCategoryTile } from '../../components/category';
|
||||||
import { NewArticleTile } from '../../components/article';
|
import { NewArticleTile } from '../../components/article';
|
||||||
import { notifyError } from '../../utils/notify';
|
import { notifyError } from '../../utils/notify';
|
||||||
import { prepareArticlePhoto } from '../../utils/prepareArticlePhoto';
|
import { prepareArticlePhoto } from '../../utils/prepareArticlePhoto';
|
||||||
@@ -430,11 +430,6 @@ class ArtikelKategorienPage extends PureComponent {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CategoryBreadcrumbs
|
|
||||||
crumbs={breadcrumbs}
|
|
||||||
onNavigate={this.navigateToCategoryById}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{routeError && (
|
{routeError && (
|
||||||
<BackendError
|
<BackendError
|
||||||
error={routeError}
|
error={routeError}
|
||||||
|
|||||||
Reference in New Issue
Block a user