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GAAAA,MAAAA,WAAAA,MAHd,SAKGqG,EAAckD,SAAWxG,KAAKuG,0BAKrC,SAAC,EAAD,CACE/I,SAAWV,GAAUkD,KAAKxC,SAASV,GACnCO,SAAU2C,KAAK+E,cAAgB+B,EAC/BxJ,WAAY0C,KAAK+E,cAAgBa,EACjCrI,SAAUyC,KAAKzC,SACfE,OAASX,GAAUkD,KAAKvC,OAAOX,GAC/BY,WAAYsC,KAAKmF,2BAMzB1D,SACE,MAAM,SAAEqC,EAAF,KAAYN,EAAZ,UAAkBJ,EAAlB,QAA6BC,GAAYrD,KAAKF,MAEpD,OAAIsD,EACKpD,KAAK2F,mBAIZ,SAACK,EAAA,EAAD,CAAMlC,SAAUA,EAAhB,UACE,SAACkC,EAAA,WAAD,CAAeC,UAAW5C,EAA1B,SACGrD,KAAKkF,eAAgB,yBAAM1B,EAAOxD,KAAKkG,qBAAqB1C,GAAQxD,KAAK6G,mBAA0B,UAO9G,QAAerE,EAAU0B,I,+ECxSlB,MAAM6C,EAA8BjH,IACzC,MAAMmH,EASR,SAA6BvE,GAC3B,OAAQA,GACN,KAAKwE,EAAAA,YAAAA,WACH,MAAO,CACL1C,KAAM,aACN2C,MAAO,MACP7K,QAAU,sEAEd,KAAK4K,EAAAA,YAAAA,MACH,MAAO,CACL1C,KAAM,QACN2C,MAAO,OACP7K,QAAU,oFAEd,KAAK4K,EAAAA,YAAAA,KACH,MAAO,CACL1C,KAAM,OACN2C,MAAO,OACP7K,QAAU,0DAEd,QACE,OAAO,MA9BK8K,CAAoBtH,EAAM4C,OAE1C,OAAKuE,GAIE,SAAC,EAAAI,MAAD,CAAOF,MAAOF,EAAQE,MAAO9H,MAAO4H,EAAQ3K,QAASkI,KAAMyC,EAAQzC,KAAMG,KAAMsC,EAAQtC,OAHrF","sources":["webpack://grafana/./public/app/features/datasources/settings/BasicSettings.tsx","webpack://grafana/./public/app/features/datasources/settings/ButtonRow.tsx","webpack://grafana/./public/app/features/datasources/settings/CloudInfoBox.tsx","webpack://grafana/./public/app/features/datasources/settings/PluginSettings.tsx","webpack://grafana/./public/app/features/datasources/settings/DataSourceSettingsPage.tsx","webpack://grafana/./public/app/features/plugins/components/PluginStateInfo.tsx"],"sourcesContent":["import React, { FC } from 'react';\n\nimport { selectors } from '@grafana/e2e-selectors';\nimport { InlineField, InlineSwitch, Input } from '@grafana/ui';\n\nexport interface Props {\n dataSourceName: string;\n isDefault: boolean;\n onNameChange: (name: string) => void;\n onDefaultChange: (value: boolean) => void;\n}\n\nconst BasicSettings: FC = ({ dataSourceName, isDefault, onDefaultChange, onNameChange }) => {\n return (\n
\n
\n
\n \n onNameChange(event.currentTarget.value)}\n required\n aria-label={selectors.pages.DataSource.name}\n />\n \n
\n\n \n ) => {\n onDefaultChange(event.currentTarget.checked);\n }}\n />\n \n
\n
\n );\n};\n\nexport default BasicSettings;\n","import React, { FC } from 'react';\n\nimport { selectors } from '@grafana/e2e-selectors';\nimport { Button, LinkButton } from '@grafana/ui';\nimport { contextSrv } from 'app/core/core';\nimport { AccessControlAction } from 'app/types/';\n\nexport interface Props {\n exploreUrl: string;\n canSave: boolean;\n canDelete: boolean;\n onDelete: () => void;\n onSubmit: (event: any) => void;\n onTest: (event: any) => void;\n}\n\nconst ButtonRow: FC = ({ canSave, canDelete, onDelete, onSubmit, onTest, exploreUrl }) => {\n const canExploreDataSources = contextSrv.hasPermission(AccessControlAction.DataSourcesExplore);\n\n return (\n
\n \n \n Explore\n \n \n Delete\n \n {canSave && (\n onSubmit(event)}\n aria-label={selectors.pages.DataSource.saveAndTest}\n >\n Save & test\n \n )}\n {!canSave && (\n \n )}\n
\n );\n};\n\nexport default ButtonRow;\n","import React, { FC } from 'react';\n\nimport { DataSourceSettings } from '@grafana/data';\nimport { GrafanaEdition } from '@grafana/data/src/types/config';\nimport { Alert } from '@grafana/ui';\nimport { LocalStorageValueProvider } from 'app/core/components/LocalStorageValueProvider';\nimport { config } from 'app/core/config';\n\nconst LOCAL_STORAGE_KEY = 'datasources.settings.cloudInfoBox.isDismissed';\n\nexport interface Props {\n dataSource: DataSourceSettings;\n}\n\nexport const CloudInfoBox: FC = ({ dataSource }) => {\n let mainDS = '';\n let extraDS = '';\n\n // don't show for already configured data sources or provisioned data sources\n if (dataSource.readOnly || (dataSource.version ?? 0) > 2) {\n return null;\n }\n\n // Skip showing this info box in some editions\n if (config.buildInfo.edition !== GrafanaEdition.OpenSource) {\n return null;\n }\n\n switch (dataSource.type) {\n case 'prometheus':\n mainDS = 'Prometheus';\n extraDS = 'Loki';\n break;\n case 'loki':\n mainDS = 'Loki';\n extraDS = 'Prometheus';\n break;\n default:\n return null;\n }\n\n return (\n storageKey={LOCAL_STORAGE_KEY} defaultValue={false}>\n {(isDismissed, onDismiss) => {\n if (isDismissed) {\n return null;\n }\n return (\n {\n onDismiss(true);\n }}\n >\n Or skip the effort and get {mainDS} (and {extraDS}) as fully-managed, scalable, and hosted data sources from\n Grafana Labs with the{' '}\n \n free-forever Grafana Cloud plan\n \n .\n \n );\n }}\n \n );\n};\n","import { cloneDeep } from 'lodash';\nimport React, { PureComponent } from 'react';\n\nimport {\n DataQuery,\n DataSourceApi,\n DataSourceJsonData,\n DataSourcePlugin,\n DataSourcePluginMeta,\n DataSourceSettings,\n} from '@grafana/data';\nimport { AngularComponent, getAngularLoader } from '@grafana/runtime';\n\nexport type GenericDataSourcePlugin = DataSourcePlugin>;\n\nexport interface Props {\n plugin: GenericDataSourcePlugin;\n dataSource: DataSourceSettings;\n dataSourceMeta: DataSourcePluginMeta;\n onModelChange: (dataSource: DataSourceSettings) => void;\n}\n\nexport class PluginSettings extends PureComponent {\n element: HTMLDivElement | null = null;\n component?: AngularComponent;\n scopeProps: {\n ctrl: { datasourceMeta: DataSourcePluginMeta; current: DataSourceSettings };\n onModelChanged: (dataSource: DataSourceSettings) => void;\n };\n\n constructor(props: Props) {\n super(props);\n\n this.scopeProps = {\n ctrl: { datasourceMeta: props.dataSourceMeta, current: cloneDeep(props.dataSource) },\n onModelChanged: this.onModelChanged,\n };\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n componentDidMount() {\n const { plugin } = this.props;\n\n if (!this.element) {\n return;\n }\n\n if (!plugin.components.ConfigEditor) {\n // React editor is not specified, let's render angular editor\n // How to approach this better? Introduce ReactDataSourcePlugin interface and typeguard it here?\n const loader = getAngularLoader();\n const template = '';\n\n this.component = loader.load(this.element, this.scopeProps, template);\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n const { plugin } = this.props;\n if (!plugin.components.ConfigEditor && this.props.dataSource !== prevProps.dataSource) {\n this.scopeProps.ctrl.current = cloneDeep(this.props.dataSource);\n\n this.component?.digest();\n }\n }\n\n componentWillUnmount() {\n if (this.component) {\n this.component.destroy();\n }\n }\n\n onModelChanged = (dataSource: DataSourceSettings) => {\n this.props.onModelChange(dataSource);\n };\n\n render() {\n const { plugin, dataSource } = this.props;\n\n if (!plugin) {\n return null;\n }\n\n return (\n
(this.element = element)}>\n {plugin.components.ConfigEditor &&\n React.createElement(plugin.components.ConfigEditor, {\n options: dataSource,\n onOptionsChange: this.onModelChanged,\n })}\n
\n );\n }\n}\n\nexport default PluginSettings;\n","import React, { PureComponent } from 'react';\nimport { connect, ConnectedProps } from 'react-redux';\n\nimport { DataSourceSettings, urlUtil } from '@grafana/data';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { Alert, Button } from '@grafana/ui';\nimport { cleanUpAction } from 'app/core/actions/cleanUp';\nimport appEvents from 'app/core/app_events';\nimport Page from 'app/core/components/Page/Page';\nimport { contextSrv } from 'app/core/core';\nimport { GrafanaRouteComponentProps } from 'app/core/navigation/types';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { PluginStateInfo } from 'app/features/plugins/components/PluginStateInfo';\nimport { StoreState, AccessControlAction } from 'app/types/';\n\nimport { ShowConfirmModalEvent } from '../../../types/events';\nimport {\n deleteDataSource,\n initDataSourceSettings,\n loadDataSource,\n testDataSource,\n updateDataSource,\n} from '../state/actions';\nimport { getDataSourceLoadingNav, buildNavModel, getDataSourceNav } from '../state/navModel';\nimport { dataSourceLoaded, setDataSourceName, setIsDefault } from '../state/reducers';\nimport { getDataSource, getDataSourceMeta } from '../state/selectors';\n\nimport BasicSettings from './BasicSettings';\nimport ButtonRow from './ButtonRow';\nimport { CloudInfoBox } from './CloudInfoBox';\nimport { PluginSettings } from './PluginSettings';\n\nexport interface OwnProps extends GrafanaRouteComponentProps<{ uid: string }> {}\n\nfunction mapStateToProps(state: StoreState, props: OwnProps) {\n const dataSourceId = props.match.params.uid;\n const params = new URLSearchParams(props.location.search);\n const dataSource = getDataSource(state.dataSources, dataSourceId);\n const { plugin, loadError, loading, testingStatus } = state.dataSourceSettings;\n const page = params.get('page');\n\n const nav = plugin\n ? getDataSourceNav(buildNavModel(dataSource, plugin), page || 'settings')\n : getDataSourceLoadingNav('settings');\n\n const navModel = getNavModel(\n state.navIndex,\n page ? `datasource-page-${page}` : `datasource-settings-${dataSourceId}`,\n nav\n );\n\n return {\n dataSource: getDataSource(state.dataSources, dataSourceId),\n dataSourceMeta: getDataSourceMeta(state.dataSources, dataSource.type),\n dataSourceId: dataSourceId,\n page,\n plugin,\n loadError,\n loading,\n testingStatus,\n navModel,\n };\n}\n\nconst mapDispatchToProps = {\n deleteDataSource,\n loadDataSource,\n setDataSourceName,\n updateDataSource,\n setIsDefault,\n dataSourceLoaded,\n initDataSourceSettings,\n testDataSource,\n cleanUpAction,\n};\n\nconst connector = connect(mapStateToProps, mapDispatchToProps);\n\nexport type Props = OwnProps & ConnectedProps;\n\nexport class DataSourceSettingsPage extends PureComponent {\n componentDidMount() {\n const { initDataSourceSettings, dataSourceId } = this.props;\n initDataSourceSettings(dataSourceId);\n }\n\n componentWillUnmount() {\n this.props.cleanUpAction({\n stateSelector: (state) => state.dataSourceSettings,\n });\n }\n\n onSubmit = async (evt: React.FormEvent) => {\n evt.preventDefault();\n\n await this.props.updateDataSource({ ...this.props.dataSource });\n\n this.testDataSource();\n };\n\n onTest = async (evt: React.FormEvent) => {\n evt.preventDefault();\n\n this.testDataSource();\n };\n\n onDelete = () => {\n appEvents.publish(\n new ShowConfirmModalEvent({\n title: 'Delete',\n text: `Are you sure you want to delete the \"${this.props.dataSource.name}\" data source?`,\n yesText: 'Delete',\n icon: 'trash-alt',\n onConfirm: () => {\n this.confirmDelete();\n },\n })\n );\n };\n\n confirmDelete = () => {\n this.props.deleteDataSource();\n };\n\n onModelChange = (dataSource: DataSourceSettings) => {\n this.props.dataSourceLoaded(dataSource);\n };\n\n isReadOnly() {\n return this.props.dataSource.readOnly === true;\n }\n\n renderIsReadOnlyMessage() {\n return (\n \n This data source was added by config and cannot be modified using the UI. Please contact your server admin to\n update this data source.\n \n );\n }\n\n renderMissingEditRightsMessage() {\n return (\n \n You are not allowed to modify this data source. Please contact your server admin to update this data source.\n \n );\n }\n\n testDataSource() {\n const { dataSource, testDataSource } = this.props;\n testDataSource(dataSource.name);\n }\n\n get hasDataSource() {\n return this.props.dataSource.id > 0;\n }\n\n onNavigateToExplore() {\n const { dataSource } = this.props;\n const exploreState = JSON.stringify({ datasource: dataSource.name, context: 'explore' });\n const url = urlUtil.renderUrl('/explore', { left: exploreState });\n return url;\n }\n\n renderLoadError() {\n const { loadError, dataSource } = this.props;\n const canDeleteDataSource =\n !this.isReadOnly() && contextSrv.hasPermissionInMetadata(AccessControlAction.DataSourcesDelete, dataSource);\n\n const node = {\n text: loadError!,\n subTitle: 'Data Source Error',\n icon: 'exclamation-triangle',\n };\n const nav = {\n node: node,\n main: node,\n };\n\n return (\n \n \n {this.isReadOnly() && this.renderIsReadOnlyMessage()}\n
\n {canDeleteDataSource && (\n \n )}\n \n
\n
\n
\n );\n }\n\n renderConfigPageBody(page: string) {\n const { plugin } = this.props;\n if (!plugin || !plugin.configPages) {\n return null; // still loading\n }\n\n for (const p of plugin.configPages) {\n if (p.id === page) {\n // Investigate is any plugins using this? We should change this interface\n return ;\n }\n }\n\n return
Page not found: {page}
;\n }\n\n renderAlertDetails() {\n const { testingStatus } = this.props;\n\n return (\n <>\n {testingStatus?.details?.message}\n {testingStatus?.details?.verboseMessage ? (\n
{testingStatus?.details?.verboseMessage}
\n ) : null}\n \n );\n }\n\n renderSettings() {\n const { dataSourceMeta, setDataSourceName, setIsDefault, dataSource, plugin, testingStatus } = this.props;\n const canWriteDataSource = contextSrv.hasPermissionInMetadata(AccessControlAction.DataSourcesWrite, dataSource);\n const canDeleteDataSource = contextSrv.hasPermissionInMetadata(AccessControlAction.DataSourcesDelete, dataSource);\n\n return (\n
\n {!canWriteDataSource && this.renderMissingEditRightsMessage()}\n {this.isReadOnly() && this.renderIsReadOnlyMessage()}\n {dataSourceMeta.state && (\n
\n \n \n
\n )}\n\n \n\n setIsDefault(state)}\n onNameChange={(name) => setDataSourceName(name)}\n />\n\n {plugin && (\n \n )}\n\n {testingStatus?.message && (\n
\n \n {testingStatus.details && this.renderAlertDetails()}\n \n
\n )}\n\n this.onSubmit(event)}\n canSave={!this.isReadOnly() && canWriteDataSource}\n canDelete={!this.isReadOnly() && canDeleteDataSource}\n onDelete={this.onDelete}\n onTest={(event) => this.onTest(event)}\n exploreUrl={this.onNavigateToExplore()}\n />\n \n );\n }\n\n render() {\n const { navModel, page, loadError, loading } = this.props;\n\n if (loadError) {\n return this.renderLoadError();\n }\n\n return (\n \n \n {this.hasDataSource ?
{page ? this.renderConfigPageBody(page) : this.renderSettings()}
: null}\n
\n
\n );\n }\n}\n\nexport default connector(DataSourceSettingsPage);\n","import React, { FC } from 'react';\n\nimport { PluginState } from '@grafana/data';\nimport { Badge, BadgeProps } from '@grafana/ui';\n\ninterface Props {\n state?: PluginState;\n}\n\nexport const PluginStateInfo: FC = (props) => {\n const display = getFeatureStateInfo(props.state);\n\n if (!display) {\n return null;\n }\n\n return ;\n};\n\nfunction getFeatureStateInfo(state?: PluginState): BadgeProps | null {\n switch (state) {\n case PluginState.deprecated:\n return {\n text: 'Deprecated',\n color: 'red',\n tooltip: `This feature is deprecated and will be removed in a future release`,\n };\n case PluginState.alpha:\n return {\n text: 'Alpha',\n color: 'blue',\n tooltip: `This feature is experimental and future updates might not be backward compatible`,\n };\n case PluginState.beta:\n return {\n text: 'Beta',\n color: 'blue',\n tooltip: `This feature is close to complete but not fully tested`,\n };\n default:\n return null;\n }\n}\n"],"names":["dataSourceName","isDefault","onDefaultChange","onNameChange","className","InlineField","label","tooltip","grow","Input","id","type","value","placeholder","onChange","event","currentTarget","required","selectors","labelWidth","InlineSwitch","checked","canSave","canDelete","onDelete","onSubmit","onTest","exploreUrl","canExploreDataSources","contextSrv","AccessControlAction","Button","variant","fill","onClick","history","back","LinkButton","href","disabled","CloudInfoBox","dataSource","mainDS","extraDS","readOnly","version","config","GrafanaEdition","LocalStorageValueProvider","storageKey","defaultValue","isDismissed","onDismiss","Alert","title","severity","bottomSpacing","onRemove","target","rel","PluginSettings","PureComponent","constructor","props","super","this","onModelChange","scopeProps","ctrl","datasourceMeta","dataSourceMeta","current","cloneDeep","onModelChanged","bind","componentDidMount","plugin","element","components","ConfigEditor","loader","getAngularLoader","template","component","load","componentDidUpdate","prevProps","digest","componentWillUnmount","destroy","render","ref","React","options","onOptionsChange","mapDispatchToProps","deleteDataSource","loadDataSource","setDataSourceName","updateDataSource","setIsDefault","dataSourceLoaded","initDataSourceSettings","testDataSource","cleanUpAction","connector","connect","state","dataSourceId","match","params","uid","URLSearchParams","location","search","getDataSource","dataSources","loadError","loading","testingStatus","dataSourceSettings","page","get","nav","getDataSourceNav","buildNavModel","getDataSourceLoadingNav","navModel","getNavModel","navIndex","getDataSourceMeta","DataSourceSettingsPage","async","evt","preventDefault","appEvents","ShowConfirmModalEvent","text","name","yesText","icon","onConfirm","confirmDelete","stateSelector","isReadOnly","renderIsReadOnlyMessage","renderMissingEditRightsMessage","hasDataSource","onNavigateToExplore","exploreState","JSON","stringify","datasource","context","urlUtil","left","renderLoadError","canDeleteDataSource","node","subTitle","main","Page","isLoading","renderConfigPageBody","configPages","p","body","query","renderAlertDetails","details","message","verboseMessage","style","whiteSpace","renderSettings","canWriteDataSource","PluginStateInfo","status","display","PluginState","color","getFeatureStateInfo","Badge"],"sourceRoot":""}