Add dedicated bot, workspace and user settings pages
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
export type SettingsRecordKind = "bots" | "workspaces" | "users";
|
||||
|
||||
export type SettingsRecordPath = {
|
||||
kind: SettingsRecordKind;
|
||||
id: string;
|
||||
};
|
||||
|
||||
type Params = {
|
||||
pathname?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* The record a nested settings page manages, e.g.
|
||||
* `/admin/settings/bots/3` -> `{ kind: "bots", id: "3" }`. Null on the
|
||||
* settings list pages and everywhere else.
|
||||
*/
|
||||
export default function parseSettingsRecordPath({
|
||||
pathname,
|
||||
}: Params): SettingsRecordPath | null {
|
||||
if (!pathname) return null;
|
||||
|
||||
const match = pathname
|
||||
.replace(/\/$/, "")
|
||||
.match(/^\/admin\/settings\/(bots|workspaces|users)\/([^/]+)$/);
|
||||
|
||||
if (!match) return null;
|
||||
|
||||
return {
|
||||
kind: match[1] as SettingsRecordKind,
|
||||
id: match[2]!,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user