Implement routes and transitions
This commit is contained in:
23
packages/sshecret-frontend/src/api/paths.ts
Normal file
23
packages/sshecret-frontend/src/api/paths.ts
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
/*
|
||||
* Split a path like /foo/bar/baz into ['foo', 'bar', 'baz']
|
||||
*/
|
||||
export function splitPath(path: string): string[] {
|
||||
if (path.startsWith('/')) {
|
||||
const newPath = path.substring(1)
|
||||
return newPath.split("/")
|
||||
}
|
||||
return path.split("/")
|
||||
}
|
||||
|
||||
/*
|
||||
* Reassemble a path array like ['foo', 'bar', 'baz'] into /foo/bar/baz
|
||||
*/
|
||||
export function reassemblePath(segments: string[]): string {
|
||||
const elements = segments.join('/')
|
||||
return '/' + elements
|
||||
}
|
||||
|
||||
export function idKey(id: string): string {
|
||||
return 'id:' + id
|
||||
}
|
||||
@ -8,6 +8,7 @@ export enum SshecretObjectType {
|
||||
Client = "Client",
|
||||
ClientSecret = "ClientSecret",
|
||||
SecretGroup = "SecretGroup",
|
||||
Audit = "Audit", // Not technically an object, but added for navigational purposes.
|
||||
}
|
||||
|
||||
export type SshecretObject = {
|
||||
@ -71,3 +72,8 @@ export const SUBSYSTEM = [
|
||||
'sshd',
|
||||
'backend',
|
||||
] as const
|
||||
|
||||
export interface PageState {
|
||||
activePane: 'clients' | 'secrets' | 'audit',
|
||||
selectedObject?: string,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user