feat: preserve full-page launch context
This commit is contained in:
@@ -13,6 +13,9 @@ import {
|
||||
DismissibleAlert,
|
||||
IconButton,
|
||||
LoadingFrame,
|
||||
dispatchQuickAccessResult,
|
||||
quickAccessLaunchState,
|
||||
useGuardedNavigate,
|
||||
usePlatformLanguage,
|
||||
usePlatformUiCapabilities,
|
||||
type QuickAccessRailProps,
|
||||
@@ -32,7 +35,7 @@ const iconByCategory: Record<string, LucideIcon> = {
|
||||
files: Files
|
||||
};
|
||||
|
||||
export default function QuickAccessRail({ settings, auth, tools }: QuickAccessRailProps) {
|
||||
export default function QuickAccessRail({ settings, auth, tools, launchContext }: QuickAccessRailProps) {
|
||||
const [effective, setEffective] = useState<EffectiveQuickAccess | null>(null);
|
||||
const [activeCategoryId, setActiveCategoryId] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -40,6 +43,7 @@ export default function QuickAccessRail({ settings, auth, tools }: QuickAccessRa
|
||||
const drawerRef = useRef<HTMLDivElement>(null);
|
||||
const triggerRef = useRef<HTMLButtonElement | null>(null);
|
||||
const location = useLocation();
|
||||
const navigate = useGuardedNavigate();
|
||||
const contributions = usePlatformUiCapabilities<QuickAccessToolsUiCapability>("quickAccess.tools");
|
||||
const { translateText } = usePlatformLanguage();
|
||||
const renderers = useMemo(
|
||||
@@ -125,6 +129,11 @@ export default function QuickAccessRail({ settings, auth, tools }: QuickAccessRa
|
||||
setActiveCategoryId(category.id);
|
||||
}
|
||||
|
||||
function openFullPage(path: string) {
|
||||
closeDrawer(false);
|
||||
navigate(path, { state: quickAccessLaunchState(launchContext) });
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<aside className="quick-access-rail" aria-label="i18n:govoplan-quick-access.quick_access">
|
||||
@@ -187,10 +196,28 @@ export default function QuickAccessRail({ settings, auth, tools }: QuickAccessRa
|
||||
<strong>{translateText(tool.label)}</strong>
|
||||
{tool.description ? <small>{translateText(tool.description)}</small> : null}
|
||||
</div>
|
||||
{tool.full_page_path ? <Link to={tool.full_page_path} onClick={() => closeDrawer(false)}>i18n:govoplan-quick-access.open_full_page</Link> : null}
|
||||
{tool.full_page_path ? (
|
||||
<button
|
||||
type="button"
|
||||
className="quick-access-full-page-link"
|
||||
onClick={() => openFullPage(tool.full_page_path!)}
|
||||
>
|
||||
i18n:govoplan-quick-access.open_full_page
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
{renderer
|
||||
? renderer.render({ settings, auth, close: () => closeDrawer(), active: true })
|
||||
? renderer.render({
|
||||
settings,
|
||||
auth,
|
||||
close: () => closeDrawer(),
|
||||
active: true,
|
||||
launchContext,
|
||||
complete: (result) => {
|
||||
dispatchQuickAccessResult(tool.id, launchContext, result);
|
||||
closeDrawer();
|
||||
}
|
||||
})
|
||||
: <p className="quick-access-tool-unavailable">i18n:govoplan-quick-access.compact_view_unavailable</p>}
|
||||
</section>
|
||||
);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--muted);
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
@@ -61,7 +61,7 @@
|
||||
margin: 11px auto;
|
||||
border: 2px solid var(--border);
|
||||
border-top-color: var(--accent);
|
||||
border-radius: 50%;
|
||||
border-radius: var(--radius-round);
|
||||
animation: quick-access-spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-left: var(--border-line);
|
||||
box-shadow: -12px 0 30px rgb(0 0 0 / 18%);
|
||||
box-shadow: var(--shadow-drawer-side);
|
||||
background: var(--panel);
|
||||
}
|
||||
|
||||
@@ -141,12 +141,25 @@
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.quick-access-tool-heading > a {
|
||||
.quick-access-tool-heading > a,
|
||||
.quick-access-full-page-link {
|
||||
flex: 0 0 auto;
|
||||
color: var(--accent);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.quick-access-full-page-link {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-weight: 700;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.quick-access-full-page-link:hover,
|
||||
.quick-access-full-page-link:focus-visible { text-decoration: underline; }
|
||||
|
||||
.quick-access-settings {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
@@ -250,7 +263,7 @@
|
||||
height: min(70vh, 680px);
|
||||
border-top: var(--border-line);
|
||||
border-left: 0;
|
||||
box-shadow: 0 -12px 30px rgb(0 0 0 / 18%);
|
||||
box-shadow: var(--shadow-drawer-bottom);
|
||||
}
|
||||
|
||||
.quick-access-preference-row {
|
||||
|
||||
Reference in New Issue
Block a user