mirror of https://github.com/grafana/grafana
grafana/ui: Documenting DataSourceHttpSettings (#27547)
* documenting component * Update packages/grafana-ui/src/components/DataSourceSettings/DataSourceHttpSettings.mdx Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * text updates Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>pull/27554/head
parent
126683929c
commit
4707508f4b
@ -1,46 +0,0 @@ |
||||
import React from 'react'; |
||||
import { withCenteredStory, withHorizontallyCenteredStory } from '../../utils/storybook/withCenteredStory'; |
||||
import { CustomHeadersSettings } from './CustomHeadersSettings'; |
||||
import { DataSourceSettings } from '@grafana/data'; |
||||
|
||||
export default { |
||||
title: 'Data Source/CustomHeadersSettings', |
||||
component: CustomHeadersSettings, |
||||
decorators: [withCenteredStory, withHorizontallyCenteredStory], |
||||
}; |
||||
|
||||
export const simple = () => { |
||||
const dataSourceConfig: DataSourceSettings<any, any> = { |
||||
id: 4, |
||||
orgId: 1, |
||||
name: 'gdev-influxdb', |
||||
type: 'influxdb', |
||||
typeLogoUrl: '', |
||||
access: 'direct', |
||||
url: 'http://localhost:8086', |
||||
password: '', |
||||
user: 'grafana', |
||||
database: 'site', |
||||
basicAuth: false, |
||||
basicAuthUser: '', |
||||
basicAuthPassword: '', |
||||
withCredentials: false, |
||||
isDefault: false, |
||||
jsonData: { |
||||
timeInterval: '15s', |
||||
httpMode: 'GET', |
||||
keepCookies: ['cookie1', 'cookie2'], |
||||
httpHeaderName1: 'X-Custom-Header', |
||||
}, |
||||
secureJsonData: { |
||||
password: true, |
||||
httpHeaderValue1: 'X-Custom-Header', |
||||
}, |
||||
secureJsonFields: { |
||||
httpHeaderValue1: true, |
||||
}, |
||||
readOnly: true, |
||||
}; |
||||
|
||||
return <CustomHeadersSettings dataSourceConfig={dataSourceConfig} onChange={() => {}} />; |
||||
}; |
@ -0,0 +1,32 @@ |
||||
import { Meta, Props } from '@storybook/addon-docs/blocks'; |
||||
import { DataSourceHttpSettings } from './DataSourceHttpSettings'; |
||||
|
||||
<Meta title="MDX|DataSourceHttpSettings" component={DataSourceHttpSettings} /> |
||||
|
||||
# DataSourceHttpSettings |
||||
Component for displaying the configuration options for a data source plugin. |
||||
|
||||
### When to use |
||||
It is used in a `ConfigEditor` for data source plugins. You can find more examples in our core data source |
||||
plugins [here](https://github.com/grafana/grafana/tree/master/public/app/plugins/datasource). |
||||
|
||||
### Example usage |
||||
```jsx |
||||
export const ConfigEditor = (props: Props) => { |
||||
const { options, onOptionsChange } = props; |
||||
return ( |
||||
<> |
||||
<DataSourceHttpSettings |
||||
defaultUrl="http://localhost:9090" |
||||
dataSourceConfig={options} |
||||
showAccessOptions={true} |
||||
onChange={onOptionsChange} |
||||
/> |
||||
|
||||
{/* Additional configuration settings for your data source plugin.*/} |
||||
</> |
||||
); |
||||
}; |
||||
``` |
||||
|
||||
<Props of={DataSourceHttpSettings} /> |
@ -1,11 +1,15 @@ |
||||
import { DataSourceSettings } from '@grafana/data'; |
||||
|
||||
export interface HttpSettingsBaseProps { |
||||
/** The configuration object of the data source */ |
||||
dataSourceConfig: DataSourceSettings<any, any>; |
||||
/** Callback for handling changes to the configuration object */ |
||||
onChange: (config: DataSourceSettings) => void; |
||||
} |
||||
|
||||
export interface HttpSettingsProps extends HttpSettingsBaseProps { |
||||
/** The default url for the data source */ |
||||
defaultUrl: string; |
||||
/** Show the http access help box */ |
||||
showAccessOptions?: boolean; |
||||
} |
||||
|
Loading…
Reference in new issue