Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
features
/
variables
/
shared
/
File Content:
multiOptions.ts
import { VariableOption } from 'app/features/variables/types'; export const alignCurrentWithMulti = (current: VariableOption, value: boolean): VariableOption => { if (!current) { return current; } if (value && !Array.isArray(current.value)) { return { ...current, value: convertToMulti(current.value), text: convertToMulti(current.text), }; } if (!value && Array.isArray(current.value)) { return { ...current, value: convertToSingle(current.value), text: convertToSingle(current.text), }; } return current; }; const convertToSingle = (value: string | string[]): string => { if (!Array.isArray(value)) { return value; } if (value.length > 0) { return value[0]; } return ''; }; const convertToMulti = (value: string | string[]): string[] => { if (Array.isArray(value)) { return value; } return [value]; };
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
testing
---
0755
formatVariable.ts
618 bytes
0644
multiOptions.test.ts
1884 bytes
0644
multiOptions.ts
910 bytes
0644
N4ST4R_ID | Naxtarrr