mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +09:00
Keep users instance filter and icon search in the URL (#1185)
The instance picker on the users page and the search box on the icon reference page held their value in component state, so leaving the page and coming back with the browser history reset them. Both now go through useTableQueryState like the table filters do, as user.instance and icon.search. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b0fb43d678
commit
c6867de13d
2 files changed
+21
-4
No files matched your search
@@ -20,6 +20,7 @@ import PageLayout from "./PageLayout";
|
||||
import PluginExtra from "./PluginExtra";
|
||||
import UsersTable from "./UsersTable";
|
||||
import { InputInstanceWithAll } from "./InputInstance";
|
||||
import useTableQueryState from "../util/useTableQueryState";
|
||||
|
||||
function CreateUserButton() {
|
||||
let control = useContext(ControlContext);
|
||||
@@ -368,7 +369,10 @@ function BulkUserActionButton() {
|
||||
|
||||
export default function UsersPage() {
|
||||
const account = useAccount();
|
||||
const [instanceId, setInstanceId] = useState<number | null>(null);
|
||||
// Kept in the URL with the users table state so back/forward restores it
|
||||
const tableState = useTableQueryState<lib.UserDetails>({ namespace: "user" });
|
||||
const instanceParam = Number(tableState.filteredValue("instance")?.[0]);
|
||||
const instanceId = Number.isInteger(instanceParam) ? instanceParam : null;
|
||||
|
||||
return <PageLayout nav={[{ name: "Users" }]}>
|
||||
<PageHeader
|
||||
@@ -377,7 +381,9 @@ export default function UsersPage() {
|
||||
{account.hasAllPermission("core.instance.list", "core.instance.subscribe")
|
||||
&& <InputInstanceWithAll
|
||||
value={instanceId}
|
||||
onChange={value => setInstanceId(value as number)}
|
||||
onChange={value => tableState.commitFilter(
|
||||
"instance", value === null ? null : [String(value)]
|
||||
)}
|
||||
fieldDefinition={{ optional: true } as any}
|
||||
disabled={false}
|
||||
/>}
|
||||
|
||||
Reference in new issue
Block a user