/
perspectives.ts
33 lines (30 loc) · 1.36 KB
/
perspectives.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as React from 'react';
import { ExtensionK8sModel } from '../api/common-types';
import { Extension, ExtensionDeclaration, CodeRef } from '../types';
// Align type with React.lazy
type LazyComponent = { default: React.ComponentType };
/** This extension contributes a new perspective to the console which enables customization of the navigation menu. */
export type Perspective = ExtensionDeclaration<
'console.perspective',
{
/** The perspective identifier. */
id: string;
/** The perspective display name. */
name: string;
/** The perspective display icon. */
icon: CodeRef<LazyComponent>;
/** Whether the perspective is the default. There can only be one default. */
default?: boolean;
/** Default pinned resources on the nav */
defaultPins?: ExtensionK8sModel[];
/** The function to get perspective landing page URL. */
landingPageURL: CodeRef<(flags: { [key: string]: boolean }, isFirstVisit: boolean) => string>;
/** The function to get redirect URL for import flow. */
importRedirectURL: CodeRef<(namespace: string) => string>;
/** The hook to detect default perspective */
usePerspectiveDetection?: CodeRef<() => [boolean, boolean]>; // [enablePerspective: boolean, loading: boolean]
}
>;
export const isPerspective = (e: Extension): e is Perspective => {
return e.type === 'console.perspective';
};