@perses-dev/plugin-system 0.55.0-beta.14 → 0.55.0-beta.15
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/HTTPSettingsEditor.d.ts +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +36 -13
- 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/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +54 -46
- package/dist/components/PluginEditor/plugin-editor-api.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/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 +28 -21
- package/dist/remote/PluginRuntime.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/package.json +3 -3
|
@@ -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,mBAA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AAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,YAAY,CAahH;AAKD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,4BAA4B,GAAG,YAAY,GAAG,MAAM,CAKnG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,qBAAqB,CAehF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,GAAG,KAAK,IAAI,YAAY,CAEpG;AAED,eAAO,MAAM,+BAA+B,UACnC,qBAAqB,GAAG,SAAS,aAC7B,gBAAgB,8BACC,yBAAyB,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,oBA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;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;A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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"}
|
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"}
|
|
@@ -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 the connection timeout
|
|
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,22 +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";
|
|
24
25
|
import { HTTPProxyTimeoutEditor } from "./HTTPProxyTimeoutEditor.js";
|
|
25
26
|
const urlSchema = z.string().url();
|
|
26
|
-
/** Edits direct URLs and proxy settings, including the connection timeout
|
|
27
|
-
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;
|
|
28
29
|
const strDirect = 'Direct access';
|
|
29
30
|
const strProxy = 'Proxy';
|
|
30
|
-
// Initialize
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
]);
|
|
34
51
|
// Use local state to maintain an array of header entries during editing, instead of
|
|
35
52
|
// manipulating a map directly which causes weird UX.
|
|
36
53
|
const headersForm = useForm({
|
|
@@ -46,7 +63,10 @@ const urlSchema = z.string().url();
|
|
|
46
63
|
name: 'headers'
|
|
47
64
|
});
|
|
48
65
|
// Watch the headers array for changes to detect duplicates
|
|
49
|
-
const watchedHeaders =
|
|
66
|
+
const watchedHeaders = useWatch({
|
|
67
|
+
control: headersForm.control,
|
|
68
|
+
name: 'headers'
|
|
69
|
+
});
|
|
50
70
|
// Check for duplicate header names
|
|
51
71
|
// TODO: duplication detection logic to be replaced by proper zod schema validation in the future
|
|
52
72
|
// ref https://github.com/perses/perses/issues/3014
|
|
@@ -472,6 +492,11 @@ const urlSchema = z.string().url();
|
|
|
472
492
|
}));
|
|
473
493
|
}
|
|
474
494
|
})
|
|
495
|
+
}),
|
|
496
|
+
value.proxy && /*#__PURE__*/ _jsx(HTTPProxyOAuthPassthroughEditor, {
|
|
497
|
+
value: value.proxy.spec,
|
|
498
|
+
isReadonly: isReadonly,
|
|
499
|
+
onChange: handleProxySpecChange
|
|
475
500
|
})
|
|
476
501
|
]
|
|
477
502
|
})
|
|
@@ -533,8 +558,7 @@ const urlSchema = z.string().url();
|
|
|
533
558
|
if (tabs[v]?.label === strDirect) {
|
|
534
559
|
setPreviousSpecProxy(value);
|
|
535
560
|
// Copy all settings (for example, scrapeInterval), except 'proxy'
|
|
536
|
-
|
|
537
|
-
const { proxy, ...newValue } = value;
|
|
561
|
+
const { proxy: _proxy, ...newValue } = value;
|
|
538
562
|
onChange({
|
|
539
563
|
...newValue,
|
|
540
564
|
directUrl: previousSpecDirect.directUrl
|
|
@@ -542,8 +566,7 @@ const urlSchema = z.string().url();
|
|
|
542
566
|
} else if (tabs[v]?.label === strProxy) {
|
|
543
567
|
setPreviousSpecDirect(value);
|
|
544
568
|
// Copy all settings (for example, scrapeInterval), except 'directUrl'
|
|
545
|
-
|
|
546
|
-
const { directUrl, ...newValue } = value;
|
|
569
|
+
const { directUrl: _directUrl, ...newValue } = value;
|
|
547
570
|
onChange({
|
|
548
571
|
...newValue,
|
|
549
572
|
proxy: previousSpecProxy.proxy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.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 { Box, Grid, IconButton, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport type { RequestHeaders } from '@perses-dev/client';\nimport type { HTTPDatasourceSpec, HTTPProxySpec } from '@perses-dev/spec';\nimport { produce } from 'immer';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport type { ReactElement } from 'react';\nimport React, { Fragment, useCallback, useState } from 'react';\nimport { Controller, useFieldArray, useForm } from 'react-hook-form';\nimport { z } from 'zod';\n\nimport { DatasourceTestConnectionButton } from '../DatasourceTestConnectionButton';\nimport { OptionsEditorRadios } from '../OptionsEditorRadios';\nimport { HTTPHeaderPolicyEditor } from './HTTPHeaderPolicyEditor';\nimport { HTTPProxyTimeoutEditor } from './HTTPProxyTimeoutEditor';\n\nconst urlSchema = z.string().url();\n\ntype HeaderEntry = {\n name: string;\n value: string;\n};\n\ntype HeaderFormValues = {\n headers: HeaderEntry[];\n};\n\nexport interface HTTPSettingsEditor {\n value: HTTPDatasourceSpec;\n onChange: (next: HTTPDatasourceSpec) => void;\n isReadonly?: boolean;\n initialSpecDirect: HTTPDatasourceSpec;\n initialSpecProxy: HTTPDatasourceSpec;\n testConnection?: () => Promise<void>;\n}\n\n/** Edits direct URLs and proxy settings, including the connection timeout and mutually exclusive allow/drop request header lists. */\nexport function HTTPSettingsEditor(props: HTTPSettingsEditor): ReactElement {\n const { value, onChange, isReadonly, initialSpecDirect, initialSpecProxy, testConnection } = props;\n const strDirect = 'Direct access';\n const strProxy = 'Proxy';\n\n // Initialize Proxy mode by default, if neither direct nor proxy mode is selected.\n if (value.directUrl === undefined && value.proxy === undefined) {\n Object.assign(value, initialSpecProxy);\n }\n\n // Use local state to maintain an array of header entries during editing, instead of\n // manipulating a map directly which causes weird UX.\n const headersForm = useForm<HeaderFormValues>({\n defaultValues: {\n headers: Object.entries(value.proxy?.spec.headers ?? {}).map(([name, headerValue]) => ({\n name,\n value: headerValue as string,\n })),\n },\n });\n\n const { fields, append, remove } = useFieldArray({\n control: headersForm.control,\n name: 'headers',\n });\n\n // Watch the headers array for changes to detect duplicates\n const watchedHeaders = headersForm.watch('headers');\n\n // Check for duplicate header names\n // TODO: duplication detection logic to be replaced by proper zod schema validation in the future\n // ref https://github.com/perses/perses/issues/3014\n const nameMap = new Map<string, number>();\n const duplicateNames = new Set<string>();\n watchedHeaders.forEach(({ name }) => {\n if (name !== '') {\n const count = (nameMap.get(name) || 0) + 1;\n nameMap.set(name, count);\n if (count > 1) {\n duplicateNames.add(name);\n }\n }\n });\n const hasDuplicates = duplicateNames.size > 0;\n\n // Sync headers to parent\n const syncHeadersToParent = (headers: HeaderEntry[]): void => {\n const headersObject: RequestHeaders = {};\n headers.forEach(({ name, value: headerValue }) => {\n if (name !== '') {\n headersObject[name] = headerValue;\n }\n });\n\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.headers = Object.keys(headersObject).length > 0 ? headersObject : undefined;\n }\n }),\n );\n };\n\n const handleProxySpecChange = useCallback(\n (next: HTTPProxySpec): void => {\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec = next;\n }\n }),\n );\n },\n [value, onChange],\n );\n\n const tabs = [\n {\n label: strProxy,\n content: (\n <>\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.proxy?.spec.url || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.url = e.target.value;\n }\n }),\n );\n }}\n sx={{ mb: 2 }}\n />\n )}\n />\n {testConnection && (\n <Box mb={2} display=\"flex\" justifyContent=\"flex-end\">\n <DatasourceTestConnectionButton\n testConnection={testConnection}\n disabled={!urlSchema.safeParse(value.proxy?.spec.url).success}\n />\n </Box>\n )}\n {value.proxy && (\n <HTTPProxyTimeoutEditor value={value.proxy.spec} isReadonly={isReadonly} onChange={handleProxySpecChange} />\n )}\n <Typography variant=\"h5\" mb={2}>\n Allowed endpoints\n </Typography>\n <Grid container spacing={2} mb={2}>\n {value.proxy?.spec.allowedEndpoints && value.proxy?.spec.allowedEndpoints.length !== 0 ? (\n value.proxy.spec.allowedEndpoints.map(({ endpointPattern, method }, i) => {\n return (\n <Fragment key={i}>\n <Grid item xs={8}>\n <Controller\n name={`Endpoint pattern ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Endpoint pattern\"\n value={endpointPattern}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: e.target.value,\n method: item.method,\n };\n } else {\n return item;\n }\n },\n );\n }\n }),\n );\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={3}>\n <Controller\n name={`Method ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n select\n fullWidth\n label=\"Method\"\n value={method}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: item.endpointPattern,\n method: e.target.value,\n };\n } else {\n return item;\n }\n },\n );\n }\n }),\n );\n }}\n >\n <MenuItem value=\"GET\">GET</MenuItem>\n <MenuItem value=\"POST\">POST</MenuItem>\n <MenuItem value=\"PUT\">PUT</MenuItem>\n <MenuItem value=\"PATCH\">PATCH</MenuItem>\n <MenuItem value=\"DELETE\">DELETE</MenuItem>\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <Controller\n name={`Remove Endpoint ${i}`}\n render={({ field }) => (\n <IconButton\n {...field}\n disabled={isReadonly}\n // Remove the given allowed endpoint from the list\n onClick={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints?.filter((item, itemIndex) => {\n return itemIndex !== i;\n }) || []),\n ];\n }\n }),\n );\n }}\n >\n <MinusIcon />\n </IconButton>\n )}\n />\n </Grid>\n </Fragment>\n );\n })\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton\n disabled={isReadonly}\n // Add a new (empty) allowed endpoint to the list\n onClick={() =>\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints ?? []),\n { endpointPattern: '', method: '' },\n ];\n }\n }),\n )\n }\n >\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n <Typography variant=\"h5\" mb={2}>\n Request Headers\n </Typography>\n <Grid container spacing={2} mb={2}>\n {fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Grid item xs={4}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.name`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header name\"\n error={!!fieldState.error || duplicateNames.has(controllerField.value)}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: e.target.value, value: updatedHeaders[index]?.value ?? '' };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={7}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.value`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header value\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: updatedHeaders[index]?.name ?? '', value: e.target.value };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <IconButton\n disabled={isReadonly}\n aria-label={`Remove header ${watchedHeaders[index]?.name || index}`}\n onClick={() => {\n remove(index);\n const updatedHeaders = watchedHeaders.filter((_, i) => i !== index);\n syncHeadersToParent(updatedHeaders);\n }}\n >\n <MinusIcon />\n </IconButton>\n </Grid>\n </Fragment>\n ))\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n {hasDuplicates && (\n <Grid item xs={12}>\n <Typography variant=\"body2\" color=\"error\">\n Duplicate header names detected. Each header name must be unique.\n </Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton disabled={isReadonly} onClick={() => append({ name: '', value: '' })}>\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n\n {value.proxy && (\n <HTTPHeaderPolicyEditor value={value.proxy.spec} isReadonly={isReadonly} onChange={handleProxySpecChange} />\n )}\n\n <Stack spacing={1}>\n <Typography variant=\"h5\">Secret</Typography>\n <Controller\n name=\"Secret\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Secret\"\n value={value.proxy?.spec.secret || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.secret = e.target.value;\n }\n }),\n );\n }}\n />\n )}\n />\n </Stack>\n </>\n ),\n },\n {\n label: strDirect,\n content: (\n <>\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.directUrl || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n draft.directUrl = e.target.value;\n }),\n );\n }}\n />\n )}\n />\n {testConnection && (\n <Box my={2} display=\"flex\" justifyContent=\"flex-end\">\n <DatasourceTestConnectionButton\n testConnection={testConnection}\n disabled={!urlSchema.safeParse(value.directUrl).success}\n />\n </Box>\n )}\n </>\n ),\n },\n ];\n\n // Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or\n // bug in case the tabs get eventually swapped in the future.\n const directModeId = tabs.findIndex((tab) => tab.label === strDirect);\n const proxyModeId = tabs.findIndex((tab) => tab.label === strProxy);\n\n // Set defaultTab to the mode that this datasource is currently relying on.\n const defaultTab = value.proxy ? proxyModeId : directModeId;\n\n // For better user experience, save previous states in mind for both mode.\n // This avoids losing everything when the user changes their mind back.\n const [previousSpecDirect, setPreviousSpecDirect] = useState(initialSpecDirect);\n const [previousSpecProxy, setPreviousSpecProxy] = useState(initialSpecProxy);\n\n // When changing mode, remove previous mode's config + append default values for the new mode.\n const handleModeChange = (v: number): void => {\n if (tabs[v]?.label === strDirect) {\n setPreviousSpecProxy(value);\n\n // Copy all settings (for example, scrapeInterval), except 'proxy'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { proxy, ...newValue } = value;\n onChange({ ...newValue, directUrl: previousSpecDirect.directUrl });\n } else if (tabs[v]?.label === strProxy) {\n setPreviousSpecDirect(value);\n\n // Copy all settings (for example, scrapeInterval), except 'directUrl'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { directUrl, ...newValue } = value;\n onChange({ ...newValue, proxy: previousSpecProxy.proxy });\n }\n };\n\n return (\n <>\n <Typography variant=\"h4\" mt={2}>\n HTTP Settings\n </Typography>\n <OptionsEditorRadios\n isReadonly={isReadonly}\n tabs={tabs}\n defaultTab={defaultTab}\n onModeChange={handleModeChange}\n />\n </>\n );\n}\n"],"names":["Box","Grid","IconButton","MenuItem","Stack","TextField","Typography","produce","MinusIcon","PlusIcon","React","Fragment","useCallback","useState","Controller","useFieldArray","useForm","z","DatasourceTestConnectionButton","OptionsEditorRadios","HTTPHeaderPolicyEditor","HTTPProxyTimeoutEditor","urlSchema","string","url","HTTPSettingsEditor","props","value","onChange","isReadonly","initialSpecDirect","initialSpecProxy","testConnection","strDirect","strProxy","directUrl","undefined","proxy","Object","assign","headersForm","defaultValues","headers","entries","spec","map","name","headerValue","fields","append","remove","control","watchedHeaders","watch","nameMap","Map","duplicateNames","Set","forEach","count","get","set","add","hasDuplicates","size","syncHeadersToParent","headersObject","draft","keys","length","handleProxySpecChange","next","tabs","label","content","render","field","fieldState","fullWidth","error","helperText","message","InputProps","readOnly","InputLabelProps","shrink","e","target","sx","mb","display","justifyContent","disabled","safeParse","success","variant","container","spacing","allowedEndpoints","endpointPattern","method","i","item","xs","itemIndex","select","onClick","filter","fontStyle","paddingTop","paddingLeft","index","controllerField","has","updatedHeaders","aria-label","_","id","color","secret","my","directModeId","findIndex","tab","proxyModeId","defaultTab","previousSpecDirect","setPreviousSpecDirect","previousSpecProxy","setPreviousSpecProxy","handleModeChange","v","newValue","mt","onModeChange"],"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,GAAG,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAG9F,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,cAAc,uBAAuB;AAE5C,OAAOC,SAASC,QAAQ,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAC/D,SAASC,UAAU,EAAEC,aAAa,EAAEC,OAAO,QAAQ,kBAAkB;AACrE,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,8BAA8B,QAAQ,6CAAoC;AACnF,SAASC,mBAAmB,QAAQ,kCAAyB;AAC7D,SAASC,sBAAsB,QAAQ,8BAA2B;AAClE,SAASC,sBAAsB,QAAQ,8BAA2B;AAElE,MAAMC,YAAYL,EAAEM,MAAM,GAAGC,GAAG;AAoBhC,mIAAmI,GACnI,OAAO,SAASC,mBAAmBC,KAAyB;IAC1D,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAEC,cAAc,EAAE,GAAGN;IAC7F,MAAMO,YAAY;IAClB,MAAMC,WAAW;IAEjB,kFAAkF;IAClF,IAAIP,MAAMQ,SAAS,KAAKC,aAAaT,MAAMU,KAAK,KAAKD,WAAW;QAC9DE,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,"sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.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 { Box, Grid, IconButton, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport type { RequestHeaders } from '@perses-dev/client';\nimport type { HTTPDatasourceSpec, HTTPProxySpec } from '@perses-dev/spec';\nimport { produce } from 'immer';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport type { ReactElement } from 'react';\nimport React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';\nimport { Controller, useFieldArray, useForm, useWatch } from 'react-hook-form';\nimport { z } from 'zod';\n\nimport { DatasourceTestConnectionButton } from '../DatasourceTestConnectionButton';\nimport { OptionsEditorRadios } from '../OptionsEditorRadios';\nimport { HTTPHeaderPolicyEditor } from './HTTPHeaderPolicyEditor';\nimport { HTTPProxyOAuthPassthroughEditor } from './HTTPProxyOAuthPassthroughEditor';\nimport { HTTPProxyTimeoutEditor } from './HTTPProxyTimeoutEditor';\n\nconst urlSchema = z.string().url();\n\ntype HeaderEntry = {\n name: string;\n value: string;\n};\n\ntype HeaderFormValues = {\n headers: HeaderEntry[];\n};\n\nexport interface HTTPSettingsEditor {\n value: HTTPDatasourceSpec;\n onChange: (next: HTTPDatasourceSpec) => void;\n isReadonly?: boolean;\n initialSpecDirect: HTTPDatasourceSpec;\n initialSpecProxy: HTTPDatasourceSpec;\n testConnection?: () => Promise<void>;\n}\n\n/** Edits direct URLs and proxy settings, including the connection timeout, mutually exclusive allow/drop request header lists, and OAuth identity forwarding. */\nexport function HTTPSettingsEditor(props: HTTPSettingsEditor): ReactElement {\n const { value: providedValue, onChange, isReadonly, initialSpecDirect, initialSpecProxy, testConnection } = props;\n const strDirect = 'Direct access';\n const strProxy = 'Proxy';\n\n // Initialize proxy mode without mutating the caller's datasource definition.\n const value = useMemo(() => {\n if (providedValue.directUrl === undefined && providedValue.proxy === undefined) {\n return { ...providedValue, ...initialSpecProxy };\n }\n return providedValue;\n }, [providedValue, initialSpecProxy]);\n useEffect(() => {\n if (value !== providedValue) onChange(value);\n }, [value, providedValue, onChange]);\n\n // Use local state to maintain an array of header entries during editing, instead of\n // manipulating a map directly which causes weird UX.\n const headersForm = useForm<HeaderFormValues>({\n defaultValues: {\n headers: Object.entries(value.proxy?.spec.headers ?? {}).map(([name, headerValue]) => ({\n name,\n value: headerValue as string,\n })),\n },\n });\n\n const { fields, append, remove } = useFieldArray({\n control: headersForm.control,\n name: 'headers',\n });\n\n // Watch the headers array for changes to detect duplicates\n const watchedHeaders = useWatch({ control: headersForm.control, name: 'headers' });\n\n // Check for duplicate header names\n // TODO: duplication detection logic to be replaced by proper zod schema validation in the future\n // ref https://github.com/perses/perses/issues/3014\n const nameMap = new Map<string, number>();\n const duplicateNames = new Set<string>();\n watchedHeaders.forEach(({ name }) => {\n if (name !== '') {\n const count = (nameMap.get(name) || 0) + 1;\n nameMap.set(name, count);\n if (count > 1) {\n duplicateNames.add(name);\n }\n }\n });\n const hasDuplicates = duplicateNames.size > 0;\n\n // Sync headers to parent\n const syncHeadersToParent = (headers: HeaderEntry[]): void => {\n const headersObject: RequestHeaders = {};\n headers.forEach(({ name, value: headerValue }) => {\n if (name !== '') {\n headersObject[name] = headerValue;\n }\n });\n\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.headers = Object.keys(headersObject).length > 0 ? headersObject : undefined;\n }\n }),\n );\n };\n\n const handleProxySpecChange = useCallback(\n (next: HTTPProxySpec): void => {\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec = next;\n }\n }),\n );\n },\n [value, onChange],\n );\n\n const tabs = [\n {\n label: strProxy,\n content: (\n <>\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.proxy?.spec.url || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.url = e.target.value;\n }\n }),\n );\n }}\n sx={{ mb: 2 }}\n />\n )}\n />\n {testConnection && (\n <Box mb={2} display=\"flex\" justifyContent=\"flex-end\">\n <DatasourceTestConnectionButton\n testConnection={testConnection}\n disabled={!urlSchema.safeParse(value.proxy?.spec.url).success}\n />\n </Box>\n )}\n {value.proxy && (\n <HTTPProxyTimeoutEditor value={value.proxy.spec} isReadonly={isReadonly} onChange={handleProxySpecChange} />\n )}\n <Typography variant=\"h5\" mb={2}>\n Allowed endpoints\n </Typography>\n <Grid container spacing={2} mb={2}>\n {value.proxy?.spec.allowedEndpoints && value.proxy?.spec.allowedEndpoints.length !== 0 ? (\n value.proxy.spec.allowedEndpoints.map(({ endpointPattern, method }, i) => {\n return (\n <Fragment key={i}>\n <Grid item xs={8}>\n <Controller\n name={`Endpoint pattern ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Endpoint pattern\"\n value={endpointPattern}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: e.target.value,\n method: item.method,\n };\n } else {\n return item;\n }\n },\n );\n }\n }),\n );\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={3}>\n <Controller\n name={`Method ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n select\n fullWidth\n label=\"Method\"\n value={method}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: item.endpointPattern,\n method: e.target.value,\n };\n } else {\n return item;\n }\n },\n );\n }\n }),\n );\n }}\n >\n <MenuItem value=\"GET\">GET</MenuItem>\n <MenuItem value=\"POST\">POST</MenuItem>\n <MenuItem value=\"PUT\">PUT</MenuItem>\n <MenuItem value=\"PATCH\">PATCH</MenuItem>\n <MenuItem value=\"DELETE\">DELETE</MenuItem>\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <Controller\n name={`Remove Endpoint ${i}`}\n render={({ field }) => (\n <IconButton\n {...field}\n disabled={isReadonly}\n // Remove the given allowed endpoint from the list\n onClick={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints?.filter((item, itemIndex) => {\n return itemIndex !== i;\n }) || []),\n ];\n }\n }),\n );\n }}\n >\n <MinusIcon />\n </IconButton>\n )}\n />\n </Grid>\n </Fragment>\n );\n })\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton\n disabled={isReadonly}\n // Add a new (empty) allowed endpoint to the list\n onClick={() =>\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints ?? []),\n { endpointPattern: '', method: '' },\n ];\n }\n }),\n )\n }\n >\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n <Typography variant=\"h5\" mb={2}>\n Request Headers\n </Typography>\n <Grid container spacing={2} mb={2}>\n {fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Grid item xs={4}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.name`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header name\"\n error={!!fieldState.error || duplicateNames.has(controllerField.value)}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: e.target.value, value: updatedHeaders[index]?.value ?? '' };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={7}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.value`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header value\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: updatedHeaders[index]?.name ?? '', value: e.target.value };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <IconButton\n disabled={isReadonly}\n aria-label={`Remove header ${watchedHeaders[index]?.name || index}`}\n onClick={() => {\n remove(index);\n const updatedHeaders = watchedHeaders.filter((_, i) => i !== index);\n syncHeadersToParent(updatedHeaders);\n }}\n >\n <MinusIcon />\n </IconButton>\n </Grid>\n </Fragment>\n ))\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n {hasDuplicates && (\n <Grid item xs={12}>\n <Typography variant=\"body2\" color=\"error\">\n Duplicate header names detected. Each header name must be unique.\n </Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton disabled={isReadonly} onClick={() => append({ name: '', value: '' })}>\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n\n {value.proxy && (\n <HTTPHeaderPolicyEditor value={value.proxy.spec} isReadonly={isReadonly} onChange={handleProxySpecChange} />\n )}\n\n <Stack spacing={1}>\n <Typography variant=\"h5\">Secret</Typography>\n <Controller\n name=\"Secret\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Secret\"\n value={value.proxy?.spec.secret || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.secret = e.target.value;\n }\n }),\n );\n }}\n />\n )}\n />\n {value.proxy && (\n <HTTPProxyOAuthPassthroughEditor\n value={value.proxy.spec}\n isReadonly={isReadonly}\n onChange={handleProxySpecChange}\n />\n )}\n </Stack>\n </>\n ),\n },\n {\n label: strDirect,\n content: (\n <>\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.directUrl || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n draft.directUrl = e.target.value;\n }),\n );\n }}\n />\n )}\n />\n {testConnection && (\n <Box my={2} display=\"flex\" justifyContent=\"flex-end\">\n <DatasourceTestConnectionButton\n testConnection={testConnection}\n disabled={!urlSchema.safeParse(value.directUrl).success}\n />\n </Box>\n )}\n </>\n ),\n },\n ];\n\n // Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or\n // bug in case the tabs get eventually swapped in the future.\n const directModeId = tabs.findIndex((tab) => tab.label === strDirect);\n const proxyModeId = tabs.findIndex((tab) => tab.label === strProxy);\n\n // Set defaultTab to the mode that this datasource is currently relying on.\n const defaultTab = value.proxy ? proxyModeId : directModeId;\n\n // For better user experience, save previous states in mind for both mode.\n // This avoids losing everything when the user changes their mind back.\n const [previousSpecDirect, setPreviousSpecDirect] = useState(initialSpecDirect);\n const [previousSpecProxy, setPreviousSpecProxy] = useState(initialSpecProxy);\n\n // When changing mode, remove previous mode's config + append default values for the new mode.\n const handleModeChange = (v: number): void => {\n if (tabs[v]?.label === strDirect) {\n setPreviousSpecProxy(value);\n\n // Copy all settings (for example, scrapeInterval), except 'proxy'\n const { proxy: _proxy, ...newValue } = value;\n onChange({ ...newValue, directUrl: previousSpecDirect.directUrl });\n } else if (tabs[v]?.label === strProxy) {\n setPreviousSpecDirect(value);\n\n // Copy all settings (for example, scrapeInterval), except 'directUrl'\n const { directUrl: _directUrl, ...newValue } = value;\n onChange({ ...newValue, proxy: previousSpecProxy.proxy });\n }\n };\n\n return (\n <>\n <Typography variant=\"h4\" mt={2}>\n HTTP Settings\n </Typography>\n <OptionsEditorRadios\n isReadonly={isReadonly}\n tabs={tabs}\n defaultTab={defaultTab}\n onModeChange={handleModeChange}\n />\n </>\n );\n}\n"],"names":["Box","Grid","IconButton","MenuItem","Stack","TextField","Typography","produce","MinusIcon","PlusIcon","React","Fragment","useCallback","useEffect","useMemo","useState","Controller","useFieldArray","useForm","useWatch","z","DatasourceTestConnectionButton","OptionsEditorRadios","HTTPHeaderPolicyEditor","HTTPProxyOAuthPassthroughEditor","HTTPProxyTimeoutEditor","urlSchema","string","url","HTTPSettingsEditor","props","value","providedValue","onChange","isReadonly","initialSpecDirect","initialSpecProxy","testConnection","strDirect","strProxy","directUrl","undefined","proxy","headersForm","defaultValues","headers","Object","entries","spec","map","name","headerValue","fields","append","remove","control","watchedHeaders","nameMap","Map","duplicateNames","Set","forEach","count","get","set","add","hasDuplicates","size","syncHeadersToParent","headersObject","draft","keys","length","handleProxySpecChange","next","tabs","label","content","render","field","fieldState","fullWidth","error","helperText","message","InputProps","readOnly","InputLabelProps","shrink","e","target","sx","mb","display","justifyContent","disabled","safeParse","success","variant","container","spacing","allowedEndpoints","endpointPattern","method","i","item","xs","itemIndex","select","onClick","filter","fontStyle","paddingTop","paddingLeft","index","controllerField","has","updatedHeaders","aria-label","_","id","color","secret","my","directModeId","findIndex","tab","proxyModeId","defaultTab","previousSpecDirect","setPreviousSpecDirect","previousSpecProxy","setPreviousSpecProxy","handleModeChange","v","_proxy","newValue","_directUrl","mt","onModeChange"],"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,GAAG,EAAEC,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAG9F,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,cAAc,uBAAuB;AAE5C,OAAOC,SAASC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACnF,SAASC,UAAU,EAAEC,aAAa,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,kBAAkB;AAC/E,SAASC,CAAC,QAAQ,MAAM;AAExB,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K,GAAGqF,cAAcH;IAE/C,0EAA0E;IAC1E,uEAAuE;IACvE,MAAM,CAACK,oBAAoBC,sBAAsB,GAAGnH,SAASoB;IAC7D,MAAM,CAACgG,mBAAmBC,qBAAqB,GAAGrH,SAASqB;IAE3D,8FAA8F;IAC9F,MAAMiG,mBAAmB,CAACC;QACxB,IAAI3D,IAAI,CAAC2D,EAAE,EAAE1D,UAAUtC,WAAW;YAChC8F,qBAAqBrG;YAErB,kEAAkE;YAClE,MAAM,EAAEW,OAAO6F,MAAM,EAAE,GAAGC,UAAU,GAAGzG;YACvCE,SAAS;gBAAE,GAAGuG,QAAQ;gBAAEhG,WAAWyF,mBAAmBzF,SAAS;YAAC;QAClE,OAAO,IAAImC,IAAI,CAAC2D,EAAE,EAAE1D,UAAUrC,UAAU;YACtC2F,sBAAsBnG;YAEtB,sEAAsE;YACtE,MAAM,EAAES,WAAWiG,UAAU,EAAE,GAAGD,UAAU,GAAGzG;YAC/CE,SAAS;gBAAE,GAAGuG,QAAQ;gBAAE9F,OAAOyF,kBAAkBzF,KAAK;YAAC;QACzD;IACF;IAEA,qBACE;;0BACE,KAACpC;gBAAW4F,SAAQ;gBAAKwC,IAAI;0BAAG;;0BAGhC,KAACpH;gBACCY,YAAYA;gBACZyC,MAAMA;gBACNqD,YAAYA;gBACZW,cAAcN;;;;AAItB"}
|
package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSelectionActionsOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.tsx"],"names":[],"mappings":"AAoEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,OAAO,GACP,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,UAAU,GACV,QAAQ,G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;AAED,MAAM,WAAW,+BAA+B;IAC9C,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACnD,iBAAiB,EAAE,CAAC,SAAS,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC3D;AAeD,2DAA2D;AAC3D,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAkBxF,CAAC;
|
|
1
|
+
{"version":3,"file":"ItemSelectionActionsOptionsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.tsx"],"names":[],"mappings":"AAoEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,OAAO,GACP,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,UAAU,GACV,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,MAAM,GACN,UAAU,GACV,MAAM,GACN,MAAM,GACN,cAAc,GACd,QAAQ,CAAC;AAEb,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,MAAM,MAAM,SAAS,GAAG,O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AClB,EAAE,+BAA+B,GAAG,YAAY,CAoIhD"}
|
package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js
CHANGED
|
@@ -33,7 +33,7 @@ import SendIcon from "mdi-material-ui/Send";
|
|
|
33
33
|
import StopIcon from "mdi-material-ui/Stop";
|
|
34
34
|
import SyncIcon from "mdi-material-ui/Sync";
|
|
35
35
|
import UploadIcon from "mdi-material-ui/Upload";
|
|
36
|
-
import { useCallback, useMemo, useState } from "react";
|
|
36
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
37
37
|
const HTTP_METHODS = [
|
|
38
38
|
'GET',
|
|
39
39
|
'POST',
|
|
@@ -266,6 +266,7 @@ function InterpolationHelper({ batchMode }) {
|
|
|
266
266
|
}
|
|
267
267
|
function EventActionEditor({ action, index, onChange, onRemove, onMoveDown, onMoveUp }) {
|
|
268
268
|
const eventAction = action;
|
|
269
|
+
const dragHandleRef = useRef(null);
|
|
269
270
|
const [isCollapsed, setIsCollapsed] = useState(true);
|
|
270
271
|
const hasBodyTemplate = (eventAction.bodyTemplate ?? '').trim().length > 0;
|
|
271
272
|
const handleIncludesTemplateChange = useCallback((event)=>{
|
|
@@ -303,6 +304,7 @@ function EventActionEditor({ action, index, onChange, onRemove, onMoveDown, onMo
|
|
|
303
304
|
]);
|
|
304
305
|
return /*#__PURE__*/ _jsxs(DragAndDropElement, {
|
|
305
306
|
data: eventAction,
|
|
307
|
+
dragHandleRef: dragHandleRef,
|
|
306
308
|
children: [
|
|
307
309
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
308
310
|
direction: "row",
|
|
@@ -360,6 +362,7 @@ function EventActionEditor({ action, index, onChange, onRemove, onMoveDown, onMo
|
|
|
360
362
|
description: "Reorder action settings",
|
|
361
363
|
placement: "top",
|
|
362
364
|
children: /*#__PURE__*/ _jsx(DragButton, {
|
|
365
|
+
ref: dragHandleRef,
|
|
363
366
|
onMoveUp: onMoveUp,
|
|
364
367
|
onMoveDown: onMoveDown,
|
|
365
368
|
menuSx: {
|
|
@@ -550,6 +553,7 @@ function EventActionEditor({ action, index, onChange, onRemove, onMoveDown, onMo
|
|
|
550
553
|
}
|
|
551
554
|
function WebhookActionEditor({ action, index, onChange, onRemove, onMoveUp, onMoveDown }) {
|
|
552
555
|
const webhookAction = action;
|
|
556
|
+
const dragHandleRef = useRef(null);
|
|
553
557
|
const [pendingChange, setPendingChange] = useState(null);
|
|
554
558
|
const contentTypeValue = webhookAction.contentType ?? 'none';
|
|
555
559
|
const hasBodyTemplate = (webhookAction.bodyTemplate ?? '').trim().length > 0;
|
|
@@ -662,6 +666,7 @@ function WebhookActionEditor({ action, index, onChange, onRemove, onMoveUp, onMo
|
|
|
662
666
|
]);
|
|
663
667
|
return /*#__PURE__*/ _jsxs(DragAndDropElement, {
|
|
664
668
|
data: webhookAction,
|
|
669
|
+
dragHandleRef: dragHandleRef,
|
|
665
670
|
children: [
|
|
666
671
|
/*#__PURE__*/ _jsxs(Stack, {
|
|
667
672
|
direction: "row",
|
|
@@ -714,6 +719,7 @@ function WebhookActionEditor({ action, index, onChange, onRemove, onMoveUp, onMo
|
|
|
714
719
|
description: "Reorder action settings",
|
|
715
720
|
placement: "top",
|
|
716
721
|
children: /*#__PURE__*/ _jsx(DragButton, {
|
|
722
|
+
ref: dragHandleRef,
|
|
717
723
|
onMoveUp: onMoveUp,
|
|
718
724
|
onMoveDown: onMoveDown,
|
|
719
725
|
menuSx: {
|