diff --git a/packages/grafana-ui/src/components/DataSourceSettings/BasicAuthSettings.tsx b/packages/grafana-ui/src/components/DataSourceSettings/BasicAuthSettings.tsx new file mode 100644 index 00000000000..9fcf126fec4 --- /dev/null +++ b/packages/grafana-ui/src/components/DataSourceSettings/BasicAuthSettings.tsx @@ -0,0 +1,61 @@ +import React from 'react'; +import { HttpSettingsProps } from './types'; +import { FormField } from '../FormField/FormField'; +import { SecretFormField } from '../SecretFormFied/SecretFormField'; + +export const BasicAuthSettings: React.FC = ({ dataSourceConfig, onChange }) => { + const password = dataSourceConfig.secureJsonData ? dataSourceConfig.secureJsonData.basicAuthPassword : ''; + + const onPasswordReset = () => { + onChange({ + ...dataSourceConfig, + basicAuthPassword: '', + secureJsonData: { + ...dataSourceConfig.secureJsonData, + basicAuthPassword: '', + }, + secureJsonFields: { + ...dataSourceConfig.secureJsonFields, + basicAuthPassword: false, + }, + }); + }; + + const onPasswordChange = (event: React.SyntheticEvent) => { + onChange({ + ...dataSourceConfig, + secureJsonData: { + ...dataSourceConfig.secureJsonData, + basicAuthPassword: event.currentTarget.value, + }, + }); + }; + + return ( + <> +
+ onChange({ ...dataSourceConfig, basicAuthUser: event.currentTarget.value })} + /> +
+
+ +
+ + ); +}; diff --git a/packages/grafana-ui/src/components/DataSourceSettings/CertificationKey.tsx b/packages/grafana-ui/src/components/DataSourceSettings/CertificationKey.tsx new file mode 100644 index 00000000000..5ed9a27cb76 --- /dev/null +++ b/packages/grafana-ui/src/components/DataSourceSettings/CertificationKey.tsx @@ -0,0 +1,40 @@ +import React, { ChangeEvent, MouseEvent, FC } from 'react'; + +interface Props { + label: string; + hasCert: boolean; + placeholder: string; + + onChange: (event: ChangeEvent) => void; + onClick: (event: MouseEvent) => void; +} + +export const CertificationKey: FC = ({ hasCert, label, onChange, onClick, placeholder }) => { + return ( +
+
+ +
+ {!hasCert && ( +
+ -
- -
- - reset -
-
- - -
-
-
-
- -
-
- - reset -
-
- -
-
-
- -
-
- - reset -
-
-
- diff --git a/public/app/features/datasources/settings/HttpSettingsCtrl.ts b/public/app/features/datasources/settings/HttpSettingsCtrl.ts index 5b233118057..59b664a3272 100644 --- a/public/app/features/datasources/settings/HttpSettingsCtrl.ts +++ b/public/app/features/datasources/settings/HttpSettingsCtrl.ts @@ -1,5 +1,4 @@ import { coreModule } from 'app/core/core'; -import { createChangeHandler, createResetHandler, PasswordFieldEnum } from '../utils/passwordHandlers'; coreModule.directive('datasourceHttpSettings', () => { return { @@ -8,22 +7,14 @@ coreModule.directive('datasourceHttpSettings', () => { suggestUrl: '@', noDirectAccess: '@', }, - templateUrl: 'public/app/features/datasources/partials/http_settings.html', + templateUrl: 'public/app/features/datasources/partials/http_settings_next.html', link: { - pre: ($scope: any, elem, attrs) => { + pre: ($scope: any) => { // do not show access option if direct access is disabled $scope.showAccessOption = $scope.noDirectAccess !== 'true'; - $scope.showAccessHelp = false; - $scope.toggleAccessHelp = () => { - $scope.showAccessHelp = !$scope.showAccessHelp; + $scope.onChange = (datasourceSetting: any) => { + $scope.current = datasourceSetting; }; - - $scope.getSuggestUrls = () => { - return [$scope.suggestUrl]; - }; - - $scope.onBasicAuthPasswordReset = createResetHandler($scope, PasswordFieldEnum.BasicAuthPassword); - $scope.onBasicAuthPasswordChange = createChangeHandler($scope, PasswordFieldEnum.BasicAuthPassword); }, }, };