Skip to content

Commit 619ea43

Browse files
authored
Connection config: import assumeRoleInstructionsStyle instead of passing it as prop (#76)
1 parent 9f92ab0 commit 619ea43

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/components/ConnectionConfig.tsx

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { FC, useEffect, useMemo, useState } from 'react';
2-
import { Input, Select, InlineField, ButtonGroup, ToolbarButton, FieldSet, Collapse, useStyles2 } from '@grafana/ui';
2+
import { Input, Select, InlineField, ButtonGroup, ToolbarButton, FieldSet, Collapse } from '@grafana/ui';
33
import {
44
DataSourcePluginOptionsEditorProps,
55
onUpdateDatasourceJsonDataOptionSelect,
@@ -79,7 +79,6 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
7979
}, [loadRegions]);
8080

8181
const inputWidth = inExperimentalAuthComponent ? 'width-20' : 'width-30';
82-
const styles = useStyles2(getStyles);
8382

8483
return (
8584
<>
@@ -91,7 +90,6 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
9190
setIsARNInstructionsOpen={setIsARNInstructionsOpen}
9291
awsAssumeRoleEnabled={awsAssumeRoleEnabled}
9392
regions={regions}
94-
assumeRoleInstructionsStyle={styles.assumeRoleInstructions}
9593
{...props}
9694
/>
9795
) : (
@@ -176,7 +174,7 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
176174
)}
177175

178176
{options.jsonData.authType === AwsAuthType.GrafanaAssumeRole && (
179-
<div className={styles.assumeRoleInstructions}>
177+
<div className={assumeRoleInstructionsStyle}>
180178
<Collapse
181179
label={'How to create an IAM role for grafana to assume:'}
182180
collapsible={true}
@@ -305,10 +303,7 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
305303
);
306304
};
307305

308-
function getStyles() {
309-
return {
310-
assumeRoleInstructions: css({
311-
maxWidth: '715px',
312-
}),
313-
};
314-
}
306+
export const assumeRoleInstructionsStyle = css({
307+
maxWidth: '715px',
308+
})
309+

src/components/NewConnectionConfig.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { AwsAuthType } from '../types';
1111
import { awsAuthProviderOptions } from '../providers';
1212
import { ConfigSection, ConfigSubSection } from '@grafana/experimental';
13-
import { ConnectionConfigProps } from './ConnectionConfig';
13+
import { ConnectionConfigProps, assumeRoleInstructionsStyle } from './ConnectionConfig';
1414

1515
interface NewConnectionConfigProps extends ConnectionConfigProps {
1616
currentProvider?: SelectableValue<AwsAuthType> | undefined;
@@ -19,7 +19,6 @@ interface NewConnectionConfigProps extends ConnectionConfigProps {
1919
setIsARNInstructionsOpen: (isOpen: boolean) => void;
2020
awsAssumeRoleEnabled: boolean;
2121
regions: SelectableValue[];
22-
assumeRoleInstructionsStyle: string;
2322
}
2423

2524
export const NewConnectionConfig = ({
@@ -30,7 +29,6 @@ export const NewConnectionConfig = ({
3029
awsAllowedAuthProviders,
3130
skipHeader,
3231
regions,
33-
assumeRoleInstructionsStyle,
3432
...props
3533
}: NewConnectionConfigProps) => {
3634
const options = props.options;

0 commit comments

Comments
 (0)