@perses-dev/plugin-system 0.55.0-beta.9 → 0.55.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +0 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts.map +1 -1
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +2 -7
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPProxyOAuthPassthroughEditor.d.ts +11 -0
- package/dist/components/HTTPSettingsEditor/HTTPProxyOAuthPassthroughEditor.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPProxyOAuthPassthroughEditor.js +62 -0
- package/dist/components/HTTPSettingsEditor/HTTPProxyOAuthPassthroughEditor.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPProxyTimeoutEditor.d.ts +11 -0
- package/dist/components/HTTPSettingsEditor/HTTPProxyTimeoutEditor.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPProxyTimeoutEditor.js +58 -0
- package/dist/components/HTTPSettingsEditor/HTTPProxyTimeoutEditor.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +44 -15
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +7 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.js +5 -0
- package/dist/components/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +16 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +4 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +7 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +54 -41
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +14 -0
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +187 -23
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +72 -7
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +6 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +6 -2
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +0 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +7 -2
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/model/datasource.d.ts +3 -0
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/plugin-loading.d.ts +1 -0
- package/dist/model/plugin-loading.d.ts.map +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +11 -0
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -1
- package/dist/remote/PluginLoaderComponent.js +28 -15
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +32 -24
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +1 -0
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +21 -15
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +23 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts +3 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js +2 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +7 -9
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +24 -20
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/alerts-queries.d.ts.map +1 -1
- package/dist/runtime/alerts-queries.js +6 -2
- package/dist/runtime/alerts-queries.js.map +1 -1
- package/dist/runtime/annotations.d.ts +8 -0
- package/dist/runtime/annotations.d.ts.map +1 -1
- package/dist/runtime/annotations.js +47 -83
- package/dist/runtime/annotations.js.map +1 -1
- package/dist/runtime/datasources.d.ts +4 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +4 -3
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/log-queries.d.ts.map +1 -1
- package/dist/runtime/log-queries.js +3 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +23 -8
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +52 -16
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.d.ts.map +1 -1
- package/dist/runtime/profile-queries.js +3 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts.map +1 -1
- package/dist/runtime/silences-queries.js +6 -2
- package/dist/runtime/silences-queries.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +10 -3
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +6 -2
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/variables.d.ts +6 -0
- package/dist/runtime/variables.d.ts.map +1 -1
- package/dist/runtime/variables.js +17 -1
- package/dist/runtime/variables.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/plugin-versions.d.ts +18 -0
- package/dist/utils/plugin-versions.d.ts.map +1 -0
- package/dist/utils/plugin-versions.js +52 -0
- package/dist/utils/plugin-versions.js.map +1 -0
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatasourceSelect.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceSelect/DatasourceSelect.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAEV,yBAAyB,EACzB,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAQvB,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAWzD,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,kBAAkB,IAAI,CAAC,GAAG,YAAY,CAAC;AAE7E,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IACjH,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAChD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"DatasourceSelect.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceSelect/DatasourceSelect.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;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,EAAE,GAAG,SAAS,KAClE,kBAAkB,GAAG,SA4BvB,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACtC,qBAAqB,wBACN,MAAM,KAC3B,kBAQF,CAAC"}
|
|
@@ -95,7 +95,6 @@ const emptyDatasourceOption = {
|
|
|
95
95
|
// We use a fake action event when we click on the action of the chip (hijack the "delete" feature).
|
|
96
96
|
// This is because the href link action is on the `deleteIcon` property already, but the `onDelete` property
|
|
97
97
|
// controls its visibility.
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
99
98
|
const fakeActionEvent = ()=>{};
|
|
100
99
|
return /*#__PURE__*/ _jsx(Autocomplete, {
|
|
101
100
|
readOnly: readOnly,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DatasourceSelect/DatasourceSelect.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { OutlinedSelectProps, BaseSelectProps } from '@mui/material';\nimport { Stack, ListItemText, Chip, IconButton, Box, Autocomplete, TextField } from '@mui/material';\nimport type { DatasourceSelector, VariableName } from '@perses-dev/spec';\nimport OpenInNewIcon from 'mdi-material-ui/OpenInNew';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type {\n DatasourceSelectItem,\n DatasourceSelectItemGroup,\n DatasourceSelectItemSelector,\n VariableStateMap,\n} from '../../runtime';\nimport { useListDatasourceSelectItems, useVariableValues } from '../../runtime';\nimport { parseVariables } from '../../utils';\n\nconst DATASOURCE_VARIABLE_VALUE_PREFIX = '__DATASOURCE_VARIABLE_VALUE__';\nconst VARIABLE_IDENTIFIER = '$';\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\ntype DataSourceOption = {\n groupEditLink?: string;\n groupLabel?: string;\n value: string;\n} & Omit<DatasourceSelectItem, 'selector'> &\n Omit<DatasourceSelectItem['selector'], 'kind'>;\n\nconst emptyDatasourceOption: DataSourceOption = { name: '', value: '' };\n\nexport type DatasourceSelectValue<T = DatasourceSelector> = T | VariableName;\n\nexport interface DatasourceSelectProps extends Omit<OutlinedSelectProps & BaseSelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelectValue;\n onChange: (next: DatasourceSelectValue) => void;\n datasourcePluginKind: string;\n project?: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps): ReactElement {\n const { datasourcePluginKind, value, project, readOnly, onChange, ...others } = props;\n const { data, isLoading } = useListDatasourceSelectItems(datasourcePluginKind, project);\n const variables = useVariableValues();\n\n const defaultValue = useMemo<VariableName | DatasourceSelectItemSelector>(() => {\n if (isVariableDatasource(value)) {\n return value;\n }\n\n const group = (data ?? [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((item) => {\n return value.kind === item.selector.kind && value.name === item.selector.name && !item.overridden;\n })?.selector.group;\n return { ...value, group };\n }, [value, data]);\n\n const options = useMemo<DataSourceOption[]>(() => {\n const datasourceOptions = (data || []).flatMap<DataSourceOption>((itemGroup) =>\n itemGroup.items.map<DataSourceOption>((item) => ({\n groupLabel: itemGroup.group,\n groupEditLink: itemGroup.editLink,\n name: item.name,\n overriding: item.overriding,\n overridden: item.overridden,\n saved: item.saved ?? true,\n group: item.selector.group,\n value: selectorToOptionValue(item.selector),\n })),\n );\n\n const datasourceOptionsMap = new Map(datasourceOptions.map((option) => [option.name, option]));\n\n const variableOptions = Object.entries(variables).flatMap<DataSourceOption>(([name, variable]) => {\n if (Array.isArray(variable.value)) return [];\n\n const associatedDatasource = datasourceOptionsMap.get(variable.value ?? '');\n if (!associatedDatasource) return [];\n\n return {\n groupLabel: 'Variables',\n name: `${VARIABLE_IDENTIFIER}${name}`,\n saved: true,\n value: `${DATASOURCE_VARIABLE_VALUE_PREFIX}${VARIABLE_IDENTIFIER}${name}`,\n };\n });\n\n return [...datasourceOptions, ...variableOptions];\n }, [data, variables]);\n\n // While loading available values, just use an empty datasource option so MUI select doesn't warn about values out of range\n const optionValue = isLoading\n ? emptyDatasourceOption\n : options.find((option) => option.value === selectorToOptionValue(defaultValue));\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange = (selectedOption: DataSourceOption | null): void => {\n if (selectedOption) {\n const next = optionValueToSelector(selectedOption?.value || '');\n onChange(next);\n } else {\n onChange({ kind: datasourcePluginKind });\n }\n };\n\n // We use a fake action event when we click on the action of the chip (hijack the \"delete\" feature).\n // This is because the href link action is on the `deleteIcon` property already, but the `onDelete` property\n // controls its visibility.\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const fakeActionEvent = (): void => {};\n\n return (\n <Autocomplete<DataSourceOption>\n readOnly={readOnly}\n options={options}\n renderInput={(params) => <TextField {...params} label={others.label} placeholder=\"\" />}\n groupBy={(option) => option.groupLabel || 'No group'}\n getOptionLabel={(option) => {\n return option.name;\n }}\n onChange={(_, v) => handleChange(v)}\n value={optionValue}\n renderOption={(props, option) => {\n return (\n <li {...props} key={option.value}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\">\n <ListItemText>\n <DatasourceName name={option.name} overridden={option.overridden} overriding={option.overriding} />\n </ListItemText>\n {!option.saved && <ListItemText>Save the dashboard to enable this datasource</ListItemText>}\n <ListItemText style={{ textAlign: 'right' }}>\n {option.groupLabel && option.groupLabel.length > 0 && (\n <Chip\n disabled={false}\n label={option.groupLabel}\n size=\"small\"\n onDelete={option.groupEditLink ? fakeActionEvent : undefined}\n deleteIcon={\n option.groupEditLink ? (\n <IconButton href={option.groupEditLink} target=\"_blank\">\n <OpenInNewIcon fontSize=\"small\" />\n </IconButton>\n ) : undefined\n }\n />\n )}\n </ListItemText>\n </Stack>\n </li>\n );\n }}\n />\n );\n}\n\nexport function DatasourceName(props: { name: string; overridden?: boolean; overriding?: boolean }): ReactElement {\n const { name, overridden, overriding } = props;\n return (\n <>\n {`${name} `}\n {!overridden && overriding && (\n <Box display=\"inline\" fontWeight=\"normal\" color={(theme) => theme.palette.primary.main}>\n (overriding)\n </Box>\n )}\n {overridden && '(overridden)'}\n </>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n/**\n * Given a DatasourceSelectItemSelector,\n * returns a string value like `{kind}_____{group}_____{name}` that can be used as a Select input value.\n * @param selector\n */\nexport function selectorToOptionValue(selector: DatasourceSelectItemSelector | VariableName): string {\n if (isVariableDatasource(selector)) {\n return `${DATASOURCE_VARIABLE_VALUE_PREFIX}${selector}`;\n }\n return [selector.kind, selector.group ?? '', selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n/**\n * Given an option value name like `{kind}_____{group}_____{name}`,\n * returns a DatasourceSelector to be used by the query data model.\n * @param optionValue\n */\nexport function optionValueToSelector(optionValue: string): DatasourceSelectValue {\n if (optionValue.startsWith(DATASOURCE_VARIABLE_VALUE_PREFIX)) {\n return optionValue.split(DATASOURCE_VARIABLE_VALUE_PREFIX)[1]!;\n }\n\n const words = optionValue.split(OPTION_VALUE_DELIMITER);\n const kind = words[0];\n const name = words[2];\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n\nexport function isVariableDatasource(value: DatasourceSelectValue | undefined): value is VariableName {\n return typeof value === 'string' && value.startsWith(VARIABLE_IDENTIFIER);\n}\n\nexport const datasourceSelectValueToSelector = (\n value: DatasourceSelectValue | undefined,\n variables: VariableStateMap,\n datasourceSelectItemGroups: DatasourceSelectItemGroup[] | undefined,\n): DatasourceSelector | undefined => {\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n const [variableName] = parseVariables(value);\n const variable = variables[variableName ?? ''];\n\n // If the variable is not defined or if its value is an array, we cannot determine a selector and return undefined\n if (!variable || Array.isArray(variable.value)) {\n return undefined;\n }\n\n const associatedDatasource = (datasourceSelectItemGroups || [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((datasource) => datasource.name === variable.value);\n\n // If the variable value is not a datasource, we cannot determine a selector and return undefined\n if (associatedDatasource === undefined) {\n return undefined;\n }\n\n const datasourceSelector: DatasourceSelector = {\n kind: associatedDatasource.selector.kind,\n name: associatedDatasource.selector.name,\n };\n\n return datasourceSelector;\n};\n\nexport const useDatasourceSelectValueToSelector = (\n value: DatasourceSelectValue,\n datasourcePluginKind: string,\n): DatasourceSelector => {\n const { data } = useListDatasourceSelectItems(datasourcePluginKind);\n const variables = useVariableValues();\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n return datasourceSelectValueToSelector(value, variables, data) ?? { kind: datasourcePluginKind };\n};\n"],"names":["Stack","ListItemText","Chip","IconButton","Box","Autocomplete","TextField","OpenInNewIcon","useMemo","useListDatasourceSelectItems","useVariableValues","parseVariables","DATASOURCE_VARIABLE_VALUE_PREFIX","VARIABLE_IDENTIFIER","emptyDatasourceOption","name","value","DatasourceSelect","props","datasourcePluginKind","project","readOnly","onChange","others","data","isLoading","variables","defaultValue","isVariableDatasource","group","flatMap","itemGroup","items","find","item","kind","selector","overridden","options","datasourceOptions","map","groupLabel","groupEditLink","editLink","overriding","saved","selectorToOptionValue","datasourceOptionsMap","Map","option","variableOptions","Object","entries","variable","Array","isArray","associatedDatasource","get","optionValue","handleChange","selectedOption","next","optionValueToSelector","fakeActionEvent","renderInput","params","label","placeholder","groupBy","getOptionLabel","_","v","renderOption","li","key","direction","alignItems","justifyContent","width","DatasourceName","style","textAlign","length","disabled","size","onDelete","undefined","deleteIcon","href","target","fontSize","display","fontWeight","color","theme","palette","primary","main","OPTION_VALUE_DELIMITER","join","startsWith","split","words","Error","datasourceSelectValueToSelector","datasourceSelectItemGroups","variableName","datasource","datasourceSelector","useDatasourceSelectValueToSelector"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAGjC,SAASA,KAAK,EAAEC,YAAY,EAAEC,IAAI,EAAEC,UAAU,EAAEC,GAAG,EAAEC,YAAY,EAAEC,SAAS,QAAQ,gBAAgB;AAEpG,OAAOC,mBAAmB,4BAA4B;AAEtD,SAASC,OAAO,QAAQ,QAAQ;AAQhC,SAASC,4BAA4B,EAAEC,iBAAiB,QAAQ,yBAAgB;AAChF,SAASC,cAAc,QAAQ,uBAAc;AAE7C,MAAMC,mCAAmC;AACzC,MAAMC,sBAAsB;AAY5B,MAAMC,wBAA0C;IAAEC,MAAM;IAAIC,OAAO;AAAG;AAWtE;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EAAEC,oBAAoB,EAAEH,KAAK,EAAEI,OAAO,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGC,QAAQ,GAAGL;IAChF,MAAM,EAAEM,IAAI,EAAEC,SAAS,EAAE,GAAGhB,6BAA6BU,sBAAsBC;IAC/E,MAAMM,YAAYhB;IAElB,MAAMiB,eAAenB,QAAqD;QACxE,IAAIoB,qBAAqBZ,QAAQ;YAC/B,OAAOA;QACT;QAEA,MAAMa,QAAQ,AAACL,CAAAA,QAAQ,EAAE,AAAD,EACrBM,OAAO,CAAC,CAACC,YAAcA,UAAUC,KAAK,EACtCC,IAAI,CAAC,CAACC;YACL,OAAOlB,MAAMmB,IAAI,KAAKD,KAAKE,QAAQ,CAACD,IAAI,IAAInB,MAAMD,IAAI,KAAK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qBZ,KAAwC;IAC3E,OAAO,OAAOA,UAAU,YAAYA,MAAMoF,UAAU,CAACvF;AACvD;AAEA,OAAO,MAAM2F,kCAAkC,CAC7CxF,OACAU,WACA+E;IAEA,IAAI,CAAC7E,qBAAqBZ,QAAQ;QAChC,OAAOA;IACT;IAEA,MAAM,CAAC0F,aAAa,GAAG/F,eAAeK;IACtC,MAAMqC,WAAW3B,SAAS,CAACgF,gBAAgB,GAAG;IAE9C,kHAAkH;IAClH,IAAI,CAACrD,YAAYC,MAAMC,OAAO,CAACF,SAASrC,KAAK,GAAG;QAC9C,OAAOsE;IACT;IAEA,MAAM9B,uBAAuB,AAACiD,CAAAA,8BAA8B,EAAE,AAAD,EAC1D3E,OAAO,CAAC,CAACC,YAAcA,UAAUC,KAAK,EACtCC,IAAI,CAAC,CAAC0E,aAAeA,WAAW5F,IAAI,KAAKsC,SAASrC,KAAK;IAE1D,iGAAiG;IACjG,IAAIwC,yBAAyB8B,WAAW;QACtC,OAAOA;IACT;IAEA,MAAMsB,qBAAyC;QAC7CzE,MAAMqB,qBAAqBpB,QAAQ,CAACD,IAAI;QACxCpB,MAAMyC,qBAAqBpB,QAAQ,CAACrB,IAAI;IAC1C;IAEA,OAAO6F;AACT,EAAE;AAEF,OAAO,MAAMC,qCAAqC,CAChD7F,OACAG;IAEA,MAAM,EAAEK,IAAI,EAAE,GAAGf,6BAA6BU;IAC9C,MAAMO,YAAYhB;IAClB,IAAI,CAACkB,qBAAqBZ,QAAQ;QAChC,OAAOA;IACT;IAEA,OAAOwF,gCAAgCxF,OAAOU,WAAWF,SAAS;QAAEW,MAAMhB;IAAqB;AACjG,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DatasourceSelect/DatasourceSelect.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { OutlinedSelectProps, BaseSelectProps } from '@mui/material';\nimport { Stack, ListItemText, Chip, IconButton, Box, Autocomplete, TextField } from '@mui/material';\nimport type { DatasourceSelector, VariableName } from '@perses-dev/spec';\nimport OpenInNewIcon from 'mdi-material-ui/OpenInNew';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type {\n DatasourceSelectItem,\n DatasourceSelectItemGroup,\n DatasourceSelectItemSelector,\n VariableStateMap,\n} from '../../runtime';\nimport { useListDatasourceSelectItems, useVariableValues } from '../../runtime';\nimport { parseVariables } from '../../utils';\n\nconst DATASOURCE_VARIABLE_VALUE_PREFIX = '__DATASOURCE_VARIABLE_VALUE__';\nconst VARIABLE_IDENTIFIER = '$';\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\ntype DataSourceOption = {\n groupEditLink?: string;\n groupLabel?: string;\n value: string;\n} & Omit<DatasourceSelectItem, 'selector'> &\n Omit<DatasourceSelectItem['selector'], 'kind'>;\n\nconst emptyDatasourceOption: DataSourceOption = { name: '', value: '' };\n\nexport type DatasourceSelectValue<T = DatasourceSelector> = T | VariableName;\n\nexport interface DatasourceSelectProps extends Omit<OutlinedSelectProps & BaseSelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelectValue;\n onChange: (next: DatasourceSelectValue) => void;\n datasourcePluginKind: string;\n project?: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps): ReactElement {\n const { datasourcePluginKind, value, project, readOnly, onChange, ...others } = props;\n const { data, isLoading } = useListDatasourceSelectItems(datasourcePluginKind, project);\n const variables = useVariableValues();\n\n const defaultValue = useMemo<VariableName | DatasourceSelectItemSelector>(() => {\n if (isVariableDatasource(value)) {\n return value;\n }\n\n const group = (data ?? [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((item) => {\n return value.kind === item.selector.kind && value.name === item.selector.name && !item.overridden;\n })?.selector.group;\n return { ...value, group };\n }, [value, data]);\n\n const options = useMemo<DataSourceOption[]>(() => {\n const datasourceOptions = (data || []).flatMap<DataSourceOption>((itemGroup) =>\n itemGroup.items.map<DataSourceOption>((item) => ({\n groupLabel: itemGroup.group,\n groupEditLink: itemGroup.editLink,\n name: item.name,\n overriding: item.overriding,\n overridden: item.overridden,\n saved: item.saved ?? true,\n group: item.selector.group,\n value: selectorToOptionValue(item.selector),\n })),\n );\n\n const datasourceOptionsMap = new Map(datasourceOptions.map((option) => [option.name, option]));\n\n const variableOptions = Object.entries(variables).flatMap<DataSourceOption>(([name, variable]) => {\n if (Array.isArray(variable.value)) return [];\n\n const associatedDatasource = datasourceOptionsMap.get(variable.value ?? '');\n if (!associatedDatasource) return [];\n\n return {\n groupLabel: 'Variables',\n name: `${VARIABLE_IDENTIFIER}${name}`,\n saved: true,\n value: `${DATASOURCE_VARIABLE_VALUE_PREFIX}${VARIABLE_IDENTIFIER}${name}`,\n };\n });\n\n return [...datasourceOptions, ...variableOptions];\n }, [data, variables]);\n\n // While loading available values, just use an empty datasource option so MUI select doesn't warn about values out of range\n const optionValue = isLoading\n ? emptyDatasourceOption\n : options.find((option) => option.value === selectorToOptionValue(defaultValue));\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange = (selectedOption: DataSourceOption | null): void => {\n if (selectedOption) {\n const next = optionValueToSelector(selectedOption?.value || '');\n onChange(next);\n } else {\n onChange({ kind: datasourcePluginKind });\n }\n };\n\n // We use a fake action event when we click on the action of the chip (hijack the \"delete\" feature).\n // This is because the href link action is on the `deleteIcon` property already, but the `onDelete` property\n // controls its visibility.\n const fakeActionEvent = (): void => {};\n\n return (\n <Autocomplete<DataSourceOption>\n readOnly={readOnly}\n options={options}\n renderInput={(params) => <TextField {...params} label={others.label} placeholder=\"\" />}\n groupBy={(option) => option.groupLabel || 'No group'}\n getOptionLabel={(option) => {\n return option.name;\n }}\n onChange={(_, v) => handleChange(v)}\n value={optionValue}\n renderOption={(props, option) => {\n return (\n <li {...props} key={option.value}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\">\n <ListItemText>\n <DatasourceName name={option.name} overridden={option.overridden} overriding={option.overriding} />\n </ListItemText>\n {!option.saved && <ListItemText>Save the dashboard to enable this datasource</ListItemText>}\n <ListItemText style={{ textAlign: 'right' }}>\n {option.groupLabel && option.groupLabel.length > 0 && (\n <Chip\n disabled={false}\n label={option.groupLabel}\n size=\"small\"\n onDelete={option.groupEditLink ? fakeActionEvent : undefined}\n deleteIcon={\n option.groupEditLink ? (\n <IconButton href={option.groupEditLink} target=\"_blank\">\n <OpenInNewIcon fontSize=\"small\" />\n </IconButton>\n ) : undefined\n }\n />\n )}\n </ListItemText>\n </Stack>\n </li>\n );\n }}\n />\n );\n}\n\nexport function DatasourceName(props: { name: string; overridden?: boolean; overriding?: boolean }): ReactElement {\n const { name, overridden, overriding } = props;\n return (\n <>\n {`${name} `}\n {!overridden && overriding && (\n <Box display=\"inline\" fontWeight=\"normal\" color={(theme) => theme.palette.primary.main}>\n (overriding)\n </Box>\n )}\n {overridden && '(overridden)'}\n </>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n/**\n * Given a DatasourceSelectItemSelector,\n * returns a string value like `{kind}_____{group}_____{name}` that can be used as a Select input value.\n * @param selector\n */\nexport function selectorToOptionValue(selector: DatasourceSelectItemSelector | VariableName): string {\n if (isVariableDatasource(selector)) {\n return `${DATASOURCE_VARIABLE_VALUE_PREFIX}${selector}`;\n }\n return [selector.kind, selector.group ?? '', selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n/**\n * Given an option value name like `{kind}_____{group}_____{name}`,\n * returns a DatasourceSelector to be used by the query data model.\n * @param optionValue\n */\nexport function optionValueToSelector(optionValue: string): DatasourceSelectValue {\n if (optionValue.startsWith(DATASOURCE_VARIABLE_VALUE_PREFIX)) {\n return optionValue.split(DATASOURCE_VARIABLE_VALUE_PREFIX)[1]!;\n }\n\n const words = optionValue.split(OPTION_VALUE_DELIMITER);\n const kind = words[0];\n const name = words[2];\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n\nexport function isVariableDatasource(value: DatasourceSelectValue | undefined): value is VariableName {\n return typeof value === 'string' && value.startsWith(VARIABLE_IDENTIFIER);\n}\n\nexport const datasourceSelectValueToSelector = (\n value: DatasourceSelectValue | undefined,\n variables: VariableStateMap,\n datasourceSelectItemGroups: DatasourceSelectItemGroup[] | undefined,\n): DatasourceSelector | undefined => {\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n const [variableName] = parseVariables(value);\n const variable = variables[variableName ?? ''];\n\n // If the variable is not defined or if its value is an array, we cannot determine a selector and return undefined\n if (!variable || Array.isArray(variable.value)) {\n return undefined;\n }\n\n const associatedDatasource = (datasourceSelectItemGroups || [])\n .flatMap((itemGroup) => itemGroup.items)\n .find((datasource) => datasource.name === variable.value);\n\n // If the variable value is not a datasource, we cannot determine a selector and return undefined\n if (associatedDatasource === undefined) {\n return undefined;\n }\n\n const datasourceSelector: DatasourceSelector = {\n kind: associatedDatasource.selector.kind,\n name: associatedDatasource.selector.name,\n };\n\n return datasourceSelector;\n};\n\nexport const useDatasourceSelectValueToSelector = (\n value: DatasourceSelectValue,\n datasourcePluginKind: string,\n): DatasourceSelector => {\n const { data } = useListDatasourceSelectItems(datasourcePluginKind);\n const variables = useVariableValues();\n if (!isVariableDatasource(value)) {\n return value;\n }\n\n return datasourceSelectValueToSelector(value, variables, data) ?? { kind: datasourcePluginKind };\n};\n"],"names":["Stack","ListItemText","Chip","IconButton","Box","Autocomplete","TextField","OpenInNewIcon","useMemo","useListDatasourceSelectItems","useVariableValues","parseVariables","DATASOURCE_VARIABLE_VALUE_PREFIX","VARIABLE_IDENTIFIER","emptyDatasourceOption","name","value","DatasourceSelect","props","datasourcePluginKind","project","readOnly","onChange","others","data","isLoading","variables","defaultValue","isVariableDatasource","group","flatMap","itemGroup","items","find","item","kind","selector","overridden","options","datasourceOptions","map","groupLabel","groupEditLink","editLink","overriding","saved","selectorToOptionValue","datasourceOptionsMap","Map","option","variableOptions","Object","entries","variable","Array","isArray","associatedDatasource","get","optionValue","handleChange","selectedOption","next","optionValueToSelector","fakeActionEvent","renderInput","params","label","placeholder","groupBy","getOptionLabel","_","v","renderOption","li","key","direction","alignItems","justifyContent","width","DatasourceName","style","textAlign","length","disabled","size","onDelete","undefined","deleteIcon","href","target","fontSize","display","fontWeight","color","theme","palette","primary","main","OPTION_VALUE_DELIMITER","join","startsWith","split","words","Error","datasourceSelectValueToSelector","datasourceSelectItemGroups","variableName","datasource","datasourceSelector","useDatasourceSelectValueToSelector"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAGjC,SAASA,KAAK,EAAEC,YAAY,EAAEC,IAAI,EAAEC,UAAU,EAAEC,GAAG,EAAEC,YAAY,EAAEC,SAAS,QAAQ,gBAAgB;AAEpG,OAAOC,mBAAmB,4BAA4B;AAEtD,SAASC,OAAO,QAAQ,QAAQ;AAQhC,SAASC,4BAA4B,EAAEC,iBAAiB,QAAQ,yBAAgB;AAChF,SAASC,cAAc,QAAQ,uBAAc;AAE7C,MAAMC,mCAAmC;AACzC,MAAMC,sBAAsB;AAY5B,MAAMC,wBAA0C;IAAEC,MAAM;IAAIC,OAAO;AAAG;AAWtE;;;CAGC,GACD,OA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,CAACrB,IAAI;IAC1C;IAEA,OAAO6F;AACT,EAAE;AAEF,OAAO,MAAMC,qCAAqC,CAChD7F,OACAG;IAEA,MAAM,EAAEK,IAAI,EAAE,GAAGf,6BAA6BU;IAC9C,MAAMO,YAAYhB;IAClB,IAAI,CAACkB,qBAAqBZ,QAAQ;QAChC,OAAOA;IACT;IAEA,OAAOwF,gCAAgCxF,OAAOU,WAAWF,SAAS;QAAEW,MAAMhB;IAAqB;AACjG,EAAE"}
|
package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatasourceTestConnectionButton.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,KAAK,mCAAmC,GAAG;IACzC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAEjC,eAAO,MAAM,8BAA8B,iDAIxC,mCAAmC,KAAG,
|
|
1
|
+
{"version":3,"file":"DatasourceTestConnectionButton.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,KAAK,mCAAmC,GAAG;IACzC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAEjC,eAAO,MAAM,8BAA8B,iDAIxC,mCAAmC,KAAG,YAoBxC,CAAC"}
|
|
@@ -19,14 +19,9 @@ export const DatasourceTestConnectionButton = ({ testConnection, disabled, ...bu
|
|
|
19
19
|
const [isTesting, setIsTesting] = useState(false);
|
|
20
20
|
const handleClick = useCallback(async ()=>{
|
|
21
21
|
setIsTesting(true);
|
|
22
|
-
|
|
23
|
-
await testConnection();
|
|
24
|
-
successSnackbar('Datasource is healthy');
|
|
25
|
-
} catch (e) {
|
|
22
|
+
await Promise.resolve().then(()=>testConnection()).then(()=>successSnackbar('Datasource is healthy')).catch((e)=>{
|
|
26
23
|
exceptionSnackbar(e instanceof Error ? e : new Error('Datasource is not healthy'));
|
|
27
|
-
}
|
|
28
|
-
setIsTesting(false);
|
|
29
|
-
}
|
|
24
|
+
}).finally(()=>setIsTesting(false));
|
|
30
25
|
}, [
|
|
31
26
|
testConnection,
|
|
32
27
|
successSnackbar,
|
package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { ButtonProps } from '@mui/material';\nimport { Button } from '@mui/material';\nimport { useSnackbar } from '@perses-dev/components';\nimport type { ReactElement } from 'react';\nimport { useCallback, useState } from 'react';\n\ntype DatasourceTestConnectionButtonProps = {\n testConnection: () => Promise<void>;\n} & Omit<ButtonProps, 'onClick'>;\n\nexport const DatasourceTestConnectionButton = ({\n testConnection,\n disabled,\n ...buttonProps\n}: DatasourceTestConnectionButtonProps): ReactElement => {\n const { successSnackbar, exceptionSnackbar } = useSnackbar();\n const [isTesting, setIsTesting] = useState(false);\n\n const handleClick = useCallback(async (): Promise<void> => {\n setIsTesting(true);\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { ButtonProps } from '@mui/material';\nimport { Button } from '@mui/material';\nimport { useSnackbar } from '@perses-dev/components';\nimport type { ReactElement } from 'react';\nimport { useCallback, useState } from 'react';\n\ntype DatasourceTestConnectionButtonProps = {\n testConnection: () => Promise<void>;\n} & Omit<ButtonProps, 'onClick'>;\n\nexport const DatasourceTestConnectionButton = ({\n testConnection,\n disabled,\n ...buttonProps\n}: DatasourceTestConnectionButtonProps): ReactElement => {\n const { successSnackbar, exceptionSnackbar } = useSnackbar();\n const [isTesting, setIsTesting] = useState(false);\n\n const handleClick = useCallback(async (): Promise<void> => {\n setIsTesting(true);\n await Promise.resolve()\n .then(() => testConnection())\n .then(() => successSnackbar('Datasource is healthy'))\n .catch((e: unknown) => {\n exceptionSnackbar(e instanceof Error ? e : new Error('Datasource is not healthy'));\n })\n .finally(() => setIsTesting(false));\n }, [testConnection, successSnackbar, exceptionSnackbar]);\n\n return (\n <Button onClick={handleClick} color=\"info\" variant=\"outlined\" disabled={disabled || isTesting} {...buttonProps}>\n Test Connection\n </Button>\n );\n};\n"],"names":["Button","useSnackbar","useCallback","useState","DatasourceTestConnectionButton","testConnection","disabled","buttonProps","successSnackbar","exceptionSnackbar","isTesting","setIsTesting","handleClick","Promise","resolve","then","catch","e","Error","finally","onClick","color","variant"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,MAAM,QAAQ,gBAAgB;AACvC,SAASC,WAAW,QAAQ,yBAAyB;AAErD,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAM9C,OAAO,MAAMC,iCAAiC,CAAC,EAC7CC,cAAc,EACdC,QAAQ,EACR,GAAGC,aACiC;IACpC,MAAM,EAAEC,eAAe,EAAEC,iBAAiB,EAAE,GAAGR;IAC/C,MAAM,CAACS,WAAWC,aAAa,GAAGR,SAAS;IAE3C,MAAMS,cAAcV,YAAY;QAC9BS,aAAa;QACb,MAAME,QAAQC,OAAO,GAClBC,IAAI,CAAC,IAAMV,kBACXU,IAAI,CAAC,IAAMP,gBAAgB,0BAC3BQ,KAAK,CAAC,CAACC;YACNR,kBAAkBQ,aAAaC,QAAQD,IAAI,IAAIC,MAAM;QACvD,GACCC,OAAO,CAAC,IAAMR,aAAa;IAChC,GAAG;QAACN;QAAgBG;QAAiBC;KAAkB;IAEvD,qBACE,KAACT;QAAOoB,SAASR;QAAaS,OAAM;QAAOC,SAAQ;QAAWhB,UAAUA,YAAYI;QAAY,GAAGH,WAAW;kBAAE;;AAIpH,EAAE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HTTPProxySpec } from '@perses-dev/spec';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
interface HTTPProxyOAuthPassthroughEditorProps {
|
|
4
|
+
value: HTTPProxySpec;
|
|
5
|
+
onChange: (next: HTTPProxySpec) => void;
|
|
6
|
+
isReadonly?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Toggles forwarding of the logged-in user's OAuth/OIDC access token to the datasource. Disabling it unsets the field. */
|
|
9
|
+
export declare function HTTPProxyOAuthPassthroughEditor({ value, onChange, isReadonly, }: HTTPProxyOAuthPassthroughEditorProps): ReactElement;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=HTTPProxyOAuthPassthroughEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTTPProxyOAuthPassthroughEditor.d.ts","sourceRoot":"","sources":["../../../src/components/HTTPSettingsEditor/HTTPProxyOAuthPassthroughEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,UAAU,oCAAoC;IAC5C,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,2HAA2H;AAC3H,wBAAgB,+BAA+B,CAAC,EAC9C,KAAK,EACL,QAAQ,EACR,UAAU,GACX,EAAE,oCAAoC,GAAG,YAAY,CA4BrD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { FormControlLabel, Stack, Switch, Typography } from "@mui/material";
|
|
15
|
+
import { useCallback, useId, useMemo } from "react";
|
|
16
|
+
/** Toggles forwarding of the logged-in user's OAuth/OIDC access token to the datasource. Disabling it unsets the field. */ export function HTTPProxyOAuthPassthroughEditor({ value, onChange, isReadonly }) {
|
|
17
|
+
const descriptionId = useId();
|
|
18
|
+
const checked = value.oauthPassthrough ?? false;
|
|
19
|
+
const handleChange = useCallback((_, nextChecked)=>{
|
|
20
|
+
// The readOnly attribute does not prevent a checkbox from being toggled.
|
|
21
|
+
if (isReadonly) return;
|
|
22
|
+
onChange({
|
|
23
|
+
...value,
|
|
24
|
+
oauthPassthrough: nextChecked ? true : undefined
|
|
25
|
+
});
|
|
26
|
+
}, [
|
|
27
|
+
isReadonly,
|
|
28
|
+
value,
|
|
29
|
+
onChange
|
|
30
|
+
]);
|
|
31
|
+
const inputProps = useMemo(()=>({
|
|
32
|
+
'aria-describedby': descriptionId
|
|
33
|
+
}), [
|
|
34
|
+
descriptionId
|
|
35
|
+
]);
|
|
36
|
+
const control = useMemo(()=>/*#__PURE__*/ _jsx(Switch, {
|
|
37
|
+
checked: checked,
|
|
38
|
+
readOnly: isReadonly,
|
|
39
|
+
inputProps: inputProps,
|
|
40
|
+
onChange: handleChange
|
|
41
|
+
}), [
|
|
42
|
+
checked,
|
|
43
|
+
isReadonly,
|
|
44
|
+
inputProps,
|
|
45
|
+
handleChange
|
|
46
|
+
]);
|
|
47
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
48
|
+
children: [
|
|
49
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
50
|
+
label: "Forward OAuth identity",
|
|
51
|
+
control: control
|
|
52
|
+
}),
|
|
53
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
54
|
+
id: descriptionId,
|
|
55
|
+
variant: "caption",
|
|
56
|
+
children: "Forward the OAuth/OIDC access token of the logged-in user to the datasource. Users must be signed in through an OAuth or OIDC provider. When enabled, the authentication settings of the secret are ignored, but its TLS settings still apply."
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=HTTPProxyOAuthPassthroughEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/HTTPSettingsEditor/HTTPProxyOAuthPassthroughEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { SwitchProps } from '@mui/material';\nimport { FormControlLabel, Stack, Switch, Typography } from '@mui/material';\nimport type { HTTPProxySpec } from '@perses-dev/spec';\nimport type { ReactElement } from 'react';\nimport { useCallback, useId, useMemo } from 'react';\n\ninterface HTTPProxyOAuthPassthroughEditorProps {\n value: HTTPProxySpec;\n onChange: (next: HTTPProxySpec) => void;\n isReadonly?: boolean;\n}\n\n/** Toggles forwarding of the logged-in user's OAuth/OIDC access token to the datasource. Disabling it unsets the field. */\nexport function HTTPProxyOAuthPassthroughEditor({\n value,\n onChange,\n isReadonly,\n}: HTTPProxyOAuthPassthroughEditorProps): ReactElement {\n const descriptionId = useId();\n const checked = value.oauthPassthrough ?? false;\n\n const handleChange = useCallback<NonNullable<SwitchProps['onChange']>>(\n (_, nextChecked) => {\n // The readOnly attribute does not prevent a checkbox from being toggled.\n if (isReadonly) return;\n onChange({ ...value, oauthPassthrough: nextChecked ? true : undefined });\n },\n [isReadonly, value, onChange],\n );\n const inputProps = useMemo(() => ({ 'aria-describedby': descriptionId }), [descriptionId]);\n const control = useMemo(\n () => <Switch checked={checked} readOnly={isReadonly} inputProps={inputProps} onChange={handleChange} />,\n [checked, isReadonly, inputProps, handleChange],\n );\n\n return (\n <Stack>\n <FormControlLabel label=\"Forward OAuth identity\" control={control} />\n <Typography id={descriptionId} variant=\"caption\">\n Forward the OAuth/OIDC access token of the logged-in user to the datasource. Users must be signed in through an\n OAuth or OIDC provider. When enabled, the authentication settings of the secret are ignored, but its TLS\n settings still apply.\n </Typography>\n </Stack>\n );\n}\n"],"names":["FormControlLabel","Stack","Switch","Typography","useCallback","useId","useMemo","HTTPProxyOAuthPassthroughEditor","value","onChange","isReadonly","descriptionId","checked","oauthPassthrough","handleChange","_","nextChecked","undefined","inputProps","control","readOnly","label","id","variant"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,gBAAgB,EAAEC,KAAK,EAAEC,MAAM,EAAEC,UAAU,QAAQ,gBAAgB;AAG5E,SAASC,WAAW,EAAEC,KAAK,EAAEC,OAAO,QAAQ,QAAQ;AAQpD,yHAAyH,GACzH,OAAO,SAASC,gCAAgC,EAC9CC,KAAK,EACLC,QAAQ,EACRC,UAAU,EAC2B;IACrC,MAAMC,gBAAgBN;IACtB,MAAMO,UAAUJ,MAAMK,gBAAgB,IAAI;IAE1C,MAAMC,eAAeV,YACnB,CAACW,GAAGC;QACF,yEAAyE;QACzE,IAAIN,YAAY;QAChBD,SAAS;YAAE,GAAGD,KAAK;YAAEK,kBAAkBG,cAAc,OAAOC;QAAU;IACxE,GACA;QAACP;QAAYF;QAAOC;KAAS;IAE/B,MAAMS,aAAaZ,QAAQ,IAAO,CAAA;YAAE,oBAAoBK;QAAc,CAAA,GAAI;QAACA;KAAc;IACzF,MAAMQ,UAAUb,QACd,kBAAM,KAACJ;YAAOU,SAASA;YAASQ,UAAUV;YAAYQ,YAAYA;YAAYT,UAAUK;YACxF;QAACF;QAASF;QAAYQ;QAAYJ;KAAa;IAGjD,qBACE,MAACb;;0BACC,KAACD;gBAAiBqB,OAAM;gBAAyBF,SAASA;;0BAC1D,KAAChB;gBAAWmB,IAAIX;gBAAeY,SAAQ;0BAAU;;;;AAOvD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HTTPProxySpec } from '@perses-dev/spec';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
interface HTTPProxyTimeoutEditorProps {
|
|
4
|
+
value: HTTPProxySpec;
|
|
5
|
+
onChange: (next: HTTPProxySpec) => void;
|
|
6
|
+
isReadonly?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Edits the optional connection timeout of an HTTP proxy. An empty value unsets the timeout. */
|
|
9
|
+
export declare function HTTPProxyTimeoutEditor({ value, onChange, isReadonly }: HTTPProxyTimeoutEditorProps): ReactElement;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=HTTPProxyTimeoutEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTTPProxyTimeoutEditor.d.ts","sourceRoot":"","sources":["../../../src/components/HTTPSettingsEditor/HTTPProxyTimeoutEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,OAAO,CAAC;AAKvD,UAAU,2BAA2B;IACnC,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,iGAAiG;AACjG,wBAAgB,sBAAsB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,2BAA2B,GAAG,YAAY,CAiCjH"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { TextField } from "@mui/material";
|
|
15
|
+
import { isDurationString } from "@perses-dev/spec";
|
|
16
|
+
import { useCallback, useMemo } from "react";
|
|
17
|
+
const timeoutFieldSx = {
|
|
18
|
+
mb: 2
|
|
19
|
+
};
|
|
20
|
+
/** Edits the optional connection timeout of an HTTP proxy. An empty value unsets the timeout. */ export function HTTPProxyTimeoutEditor({ value, onChange, isReadonly }) {
|
|
21
|
+
const timeout = value.timeout ?? '';
|
|
22
|
+
// TODO this thing should be handled by a form schema.
|
|
23
|
+
const isInvalid = timeout !== '' && !isDurationString(timeout);
|
|
24
|
+
const handleChange = useCallback((e)=>{
|
|
25
|
+
const nextTimeout = e.target.value;
|
|
26
|
+
onChange({
|
|
27
|
+
...value,
|
|
28
|
+
timeout: nextTimeout === '' ? undefined : nextTimeout
|
|
29
|
+
});
|
|
30
|
+
}, [
|
|
31
|
+
value,
|
|
32
|
+
onChange
|
|
33
|
+
]);
|
|
34
|
+
const inputProps = useMemo(()=>({
|
|
35
|
+
readOnly: isReadonly
|
|
36
|
+
}), [
|
|
37
|
+
isReadonly
|
|
38
|
+
]);
|
|
39
|
+
const inputLabelProps = useMemo(()=>({
|
|
40
|
+
shrink: isReadonly ? true : undefined
|
|
41
|
+
}), [
|
|
42
|
+
isReadonly
|
|
43
|
+
]);
|
|
44
|
+
return /*#__PURE__*/ _jsx(TextField, {
|
|
45
|
+
fullWidth: true,
|
|
46
|
+
label: "Timeout",
|
|
47
|
+
placeholder: "e.g. 30s, 1m30s",
|
|
48
|
+
value: timeout,
|
|
49
|
+
error: isInvalid,
|
|
50
|
+
helperText: isInvalid ? 'Must be a valid duration string (e.g. 30s, 1m30s)' : 'Maximum time allowed to establish a connection to the datasource. Leave empty or set to 0s to use the Perses server default.',
|
|
51
|
+
InputProps: inputProps,
|
|
52
|
+
InputLabelProps: inputLabelProps,
|
|
53
|
+
onChange: handleChange,
|
|
54
|
+
sx: timeoutFieldSx
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=HTTPProxyTimeoutEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/HTTPSettingsEditor/HTTPProxyTimeoutEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { TextField } from '@mui/material';\nimport type { DurationString, HTTPProxySpec } from '@perses-dev/spec';\nimport { isDurationString } from '@perses-dev/spec';\nimport type { ChangeEvent, ReactElement } from 'react';\nimport { useCallback, useMemo } from 'react';\n\nconst timeoutFieldSx = { mb: 2 };\n\ninterface HTTPProxyTimeoutEditorProps {\n value: HTTPProxySpec;\n onChange: (next: HTTPProxySpec) => void;\n isReadonly?: boolean;\n}\n\n/** Edits the optional connection timeout of an HTTP proxy. An empty value unsets the timeout. */\nexport function HTTPProxyTimeoutEditor({ value, onChange, isReadonly }: HTTPProxyTimeoutEditorProps): ReactElement {\n const timeout = value.timeout ?? '';\n // TODO this thing should be handled by a form schema.\n const isInvalid = timeout !== '' && !isDurationString(timeout);\n\n const handleChange = useCallback(\n (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {\n const nextTimeout = e.target.value;\n onChange({ ...value, timeout: nextTimeout === '' ? undefined : (nextTimeout as DurationString) });\n },\n [value, onChange],\n );\n const inputProps = useMemo(() => ({ readOnly: isReadonly }), [isReadonly]);\n const inputLabelProps = useMemo(() => ({ shrink: isReadonly ? true : undefined }), [isReadonly]);\n\n return (\n <TextField\n fullWidth\n label=\"Timeout\"\n placeholder=\"e.g. 30s, 1m30s\"\n value={timeout}\n error={isInvalid}\n helperText={\n isInvalid\n ? 'Must be a valid duration string (e.g. 30s, 1m30s)'\n : 'Maximum time allowed to establish a connection to the datasource. Leave empty or set to 0s to use the Perses server default.'\n }\n InputProps={inputProps}\n InputLabelProps={inputLabelProps}\n onChange={handleChange}\n sx={timeoutFieldSx}\n />\n );\n}\n"],"names":["TextField","isDurationString","useCallback","useMemo","timeoutFieldSx","mb","HTTPProxyTimeoutEditor","value","onChange","isReadonly","timeout","isInvalid","handleChange","e","nextTimeout","target","undefined","inputProps","readOnly","inputLabelProps","shrink","fullWidth","label","placeholder","error","helperText","InputProps","InputLabelProps","sx"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,SAAS,QAAQ,gBAAgB;AAE1C,SAASC,gBAAgB,QAAQ,mBAAmB;AAEpD,SAASC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAE7C,MAAMC,iBAAiB;IAAEC,IAAI;AAAE;AAQ/B,+FAA+F,GAC/F,OAAO,SAASC,uBAAuB,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAA+B;IACjG,MAAMC,UAAUH,MAAMG,OAAO,IAAI;IACjC,sDAAsD;IACtD,MAAMC,YAAYD,YAAY,MAAM,CAACT,iBAAiBS;IAEtD,MAAME,eAAeV,YACnB,CAACW;QACC,MAAMC,cAAcD,EAAEE,MAAM,CAACR,KAAK;QAClCC,SAAS;YAAE,GAAGD,KAAK;YAAEG,SAASI,gBAAgB,KAAKE,YAAaF;QAA+B;IACjG,GACA;QAACP;QAAOC;KAAS;IAEnB,MAAMS,aAAad,QAAQ,IAAO,CAAA;YAAEe,UAAUT;QAAW,CAAA,GAAI;QAACA;KAAW;IACzE,MAAMU,kBAAkBhB,QAAQ,IAAO,CAAA;YAAEiB,QAAQX,aAAa,OAAOO;QAAU,CAAA,GAAI;QAACP;KAAW;IAE/F,qBACE,KAACT;QACCqB,SAAS;QACTC,OAAM;QACNC,aAAY;QACZhB,OAAOG;QACPc,OAAOb;QACPc,YACEd,YACI,sDACA;QAENe,YAAYT;QACZU,iBAAiBR;QACjBX,UAAUI;QACVgB,IAAIxB;;AAGV"}
|
|
@@ -8,6 +8,6 @@ export interface HTTPSettingsEditor {
|
|
|
8
8
|
initialSpecProxy: HTTPDatasourceSpec;
|
|
9
9
|
testConnection?: () => Promise<void>;
|
|
10
10
|
}
|
|
11
|
-
/** Edits direct URLs and proxy settings, including mutually exclusive allow/drop request header lists. */
|
|
11
|
+
/** Edits direct URLs and proxy settings, including the connection timeout, mutually exclusive allow/drop request header lists, and OAuth identity forwarding. */
|
|
12
12
|
export declare function HTTPSettingsEditor(props: HTTPSettingsEditor): ReactElement;
|
|
13
13
|
//# sourceMappingURL=HTTPSettingsEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTTPSettingsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,kBAAkB,CAAC;AAI1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"HTTPSettingsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,kBAAkB,CAAC;AAI1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAsB1C,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,gBAAgB,EAAE,kBAAkB,CAAC;IACrC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAED,iKAAiK;AACjK,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAkf1E"}
|
|
@@ -15,21 +15,39 @@ import { Box, Grid, IconButton, MenuItem, Stack, TextField, Typography } from "@
|
|
|
15
15
|
import { produce } from "immer";
|
|
16
16
|
import MinusIcon from "mdi-material-ui/Minus";
|
|
17
17
|
import PlusIcon from "mdi-material-ui/Plus";
|
|
18
|
-
import React, { Fragment, useCallback, useState } from "react";
|
|
19
|
-
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
|
18
|
+
import React, { Fragment, useCallback, useEffect, useMemo, useState } from "react";
|
|
19
|
+
import { Controller, useFieldArray, useForm, useWatch } from "react-hook-form";
|
|
20
20
|
import { z } from "zod";
|
|
21
21
|
import { DatasourceTestConnectionButton } from "../DatasourceTestConnectionButton/index.js";
|
|
22
22
|
import { OptionsEditorRadios } from "../OptionsEditorRadios/index.js";
|
|
23
23
|
import { HTTPHeaderPolicyEditor } from "./HTTPHeaderPolicyEditor.js";
|
|
24
|
+
import { HTTPProxyOAuthPassthroughEditor } from "./HTTPProxyOAuthPassthroughEditor.js";
|
|
25
|
+
import { HTTPProxyTimeoutEditor } from "./HTTPProxyTimeoutEditor.js";
|
|
24
26
|
const urlSchema = z.string().url();
|
|
25
|
-
/** Edits direct URLs and proxy settings, including mutually exclusive allow/drop request header lists. */ export function HTTPSettingsEditor(props) {
|
|
26
|
-
const { value, onChange, isReadonly, initialSpecDirect, initialSpecProxy, testConnection } = props;
|
|
27
|
+
/** Edits direct URLs and proxy settings, including the connection timeout, mutually exclusive allow/drop request header lists, and OAuth identity forwarding. */ export function HTTPSettingsEditor(props) {
|
|
28
|
+
const { value: providedValue, onChange, isReadonly, initialSpecDirect, initialSpecProxy, testConnection } = props;
|
|
27
29
|
const strDirect = 'Direct access';
|
|
28
30
|
const strProxy = 'Proxy';
|
|
29
|
-
// Initialize
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
// Initialize proxy mode without mutating the caller's datasource definition.
|
|
32
|
+
const value = useMemo(()=>{
|
|
33
|
+
if (providedValue.directUrl === undefined && providedValue.proxy === undefined) {
|
|
34
|
+
return {
|
|
35
|
+
...providedValue,
|
|
36
|
+
...initialSpecProxy
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return providedValue;
|
|
40
|
+
}, [
|
|
41
|
+
providedValue,
|
|
42
|
+
initialSpecProxy
|
|
43
|
+
]);
|
|
44
|
+
useEffect(()=>{
|
|
45
|
+
if (value !== providedValue) onChange(value);
|
|
46
|
+
}, [
|
|
47
|
+
value,
|
|
48
|
+
providedValue,
|
|
49
|
+
onChange
|
|
50
|
+
]);
|
|
33
51
|
// Use local state to maintain an array of header entries during editing, instead of
|
|
34
52
|
// manipulating a map directly which causes weird UX.
|
|
35
53
|
const headersForm = useForm({
|
|
@@ -45,7 +63,10 @@ const urlSchema = z.string().url();
|
|
|
45
63
|
name: 'headers'
|
|
46
64
|
});
|
|
47
65
|
// Watch the headers array for changes to detect duplicates
|
|
48
|
-
const watchedHeaders =
|
|
66
|
+
const watchedHeaders = useWatch({
|
|
67
|
+
control: headersForm.control,
|
|
68
|
+
name: 'headers'
|
|
69
|
+
});
|
|
49
70
|
// Check for duplicate header names
|
|
50
71
|
// TODO: duplication detection logic to be replaced by proper zod schema validation in the future
|
|
51
72
|
// ref https://github.com/perses/perses/issues/3014
|
|
@@ -75,7 +96,7 @@ const urlSchema = z.string().url();
|
|
|
75
96
|
}
|
|
76
97
|
}));
|
|
77
98
|
};
|
|
78
|
-
const
|
|
99
|
+
const handleProxySpecChange = useCallback((next)=>{
|
|
79
100
|
onChange(produce(value, (draft)=>{
|
|
80
101
|
if (draft.proxy !== undefined) {
|
|
81
102
|
draft.proxy.spec = next;
|
|
@@ -127,6 +148,11 @@ const urlSchema = z.string().url();
|
|
|
127
148
|
disabled: !urlSchema.safeParse(value.proxy?.spec.url).success
|
|
128
149
|
})
|
|
129
150
|
}),
|
|
151
|
+
value.proxy && /*#__PURE__*/ _jsx(HTTPProxyTimeoutEditor, {
|
|
152
|
+
value: value.proxy.spec,
|
|
153
|
+
isReadonly: isReadonly,
|
|
154
|
+
onChange: handleProxySpecChange
|
|
155
|
+
}),
|
|
130
156
|
/*#__PURE__*/ _jsx(Typography, {
|
|
131
157
|
variant: "h5",
|
|
132
158
|
mb: 2,
|
|
@@ -433,7 +459,7 @@ const urlSchema = z.string().url();
|
|
|
433
459
|
value.proxy && /*#__PURE__*/ _jsx(HTTPHeaderPolicyEditor, {
|
|
434
460
|
value: value.proxy.spec,
|
|
435
461
|
isReadonly: isReadonly,
|
|
436
|
-
onChange:
|
|
462
|
+
onChange: handleProxySpecChange
|
|
437
463
|
}),
|
|
438
464
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
439
465
|
spacing: 1,
|
|
@@ -466,6 +492,11 @@ const urlSchema = z.string().url();
|
|
|
466
492
|
}));
|
|
467
493
|
}
|
|
468
494
|
})
|
|
495
|
+
}),
|
|
496
|
+
value.proxy && /*#__PURE__*/ _jsx(HTTPProxyOAuthPassthroughEditor, {
|
|
497
|
+
value: value.proxy.spec,
|
|
498
|
+
isReadonly: isReadonly,
|
|
499
|
+
onChange: handleProxySpecChange
|
|
469
500
|
})
|
|
470
501
|
]
|
|
471
502
|
})
|
|
@@ -527,8 +558,7 @@ const urlSchema = z.string().url();
|
|
|
527
558
|
if (tabs[v]?.label === strDirect) {
|
|
528
559
|
setPreviousSpecProxy(value);
|
|
529
560
|
// Copy all settings (for example, scrapeInterval), except 'proxy'
|
|
530
|
-
|
|
531
|
-
const { proxy, ...newValue } = value;
|
|
561
|
+
const { proxy: _proxy, ...newValue } = value;
|
|
532
562
|
onChange({
|
|
533
563
|
...newValue,
|
|
534
564
|
directUrl: previousSpecDirect.directUrl
|
|
@@ -536,8 +566,7 @@ const urlSchema = z.string().url();
|
|
|
536
566
|
} else if (tabs[v]?.label === strProxy) {
|
|
537
567
|
setPreviousSpecDirect(value);
|
|
538
568
|
// Copy all settings (for example, scrapeInterval), except 'directUrl'
|
|
539
|
-
|
|
540
|
-
const { directUrl, ...newValue } = value;
|
|
569
|
+
const { directUrl: _directUrl, ...newValue } = value;
|
|
541
570
|
onChange({
|
|
542
571
|
...newValue,
|
|
543
572
|
proxy: previousSpecProxy.proxy
|