mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-11-22 17:49:29 +00:00
feat: preserve links to packages
This changes url handling in status page. Firstly, instead of using hash for repository, now they are handled by query parameter. Secondly, it adds a query parameter for package base. And lastly, it changes behaviour for clicking on the package link, now it opens status page, which allows to e.g. open a tab in background
This commit is contained in:
1 parent
eafa1b417a
commit
f776b33310
4 files changed
+87
-21
No files matched your search
@@ -19,6 +19,8 @@
|
||||
*/
|
||||
import type { GridFilterModel } from "@mui/x-data-grid";
|
||||
import { useLocalStorage } from "hooks/useLocalStorage";
|
||||
import { navigate, packageHref, useLocationQuery } from "hooks/useLocationQuery";
|
||||
import { useRepository } from "hooks/useRepository";
|
||||
import { useState } from "react";
|
||||
|
||||
export type DialogType = "dashboard" | "add" | "rebuild" | "keyImport";
|
||||
@@ -43,7 +45,14 @@ export interface UseTableStateResult {
|
||||
export function useTableState(): UseTableStateResult {
|
||||
const [selectionModel, setSelectionModel] = useState<string[]>([]);
|
||||
const [dialogOpen, setDialogOpen] = useState<DialogType | null>(null);
|
||||
const [selectedPackage, setSelectedPackage] = useState<string | null>(null);
|
||||
const { currentRepository } = useRepository();
|
||||
const packageBase = new URLSearchParams(useLocationQuery()).get("package");
|
||||
const selectedPackage = currentRepository && packageBase ? packageBase : null;
|
||||
const setSelectedPackage = (base: string | null): void => {
|
||||
if (currentRepository) {
|
||||
navigate(packageHref(currentRepository.key, base));
|
||||
}
|
||||
};
|
||||
const [searchText, setSearchText] = useState("");
|
||||
|
||||
const [paginationModel, setPaginationModel] = useLocalStorage("ahriman-packages-pagination", {
|
||||
|
||||
Reference in new issue
Block a user