-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
84 lines (63 loc) · 1.91 KB
/
types.d.ts
File metadata and controls
84 lines (63 loc) · 1.91 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Scripts export a LoadFunction named load
type LoadFunction = (args: LoadFunctionArgs) => void
interface LoadFunctionArgs {
// Lets scripts run commands that are whitelisted on the server/backend in .cmd files alongside the script's .js file
runCommand(cmd: string, ...args: string[]): Promise<string>
// Settings that have been set by the user (e.g. show/hide a column)
settings: Settings,
// Used by scripts to display data
setData(data: Data | Data[]): void
// Scripts can show modal data
showModal(data: Data): void
// Scripts can set clipboard, e.g. with commands after a button click (e.g. kubectl delete ...)
// (FIXME TODO: is this dangerous? should user give consent?)
setClipboard(str: string): void
// logging outputs
debug(...args: any): void
warn(...args: any): void
error(...args: any): void
}
interface Data {
title?: string
text?: string
json?: unknown
/* Tables */
// fields are table columns
fields?: FieldInfo[]
// these are sub-colu,ms
fields2?: FieldInfo[]
fieldColSpans?: number[]
rows?: RowData[]
// buttons to show above tables
buttons?: ButtonInfo[]
// settings that users can change, along with defaults
defaultSettings?: Settings
}
type FieldInfo = string | {
text: string
tooltip: string
}
interface RowData {
cells: (DataCell | undefined)[]
key: string
// called when users click on a row
getExpandedDetail?: LoadFunction
}
type DataCell = string | number | boolean | CellInfo
interface CellInfo {
text?: string
url?: string
tooltip?: string
sortKey?: string | number | (() => (string | number))
warning?: boolean
bold?: boolean
icon?: string
color?: string
}
interface ButtonInfo {
text: string
onClicked: (showTooltip?: (text: string) => void) => void;
}
interface Settings {
[name: string]: boolean | number | string
}