Skip to content

Commit

Permalink
Connection config: import assumeRoleInstructionsStyle instead of pass…
Browse files Browse the repository at this point in the history
…ing it as prop (#76)
  • Loading branch information
idastambuk authored Feb 12, 2024
1 parent 9f92ab0 commit 619ea43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
17 changes: 6 additions & 11 deletions src/components/ConnectionConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC, useEffect, useMemo, useState } from 'react';
import { Input, Select, InlineField, ButtonGroup, ToolbarButton, FieldSet, Collapse, useStyles2 } from '@grafana/ui';
import { Input, Select, InlineField, ButtonGroup, ToolbarButton, FieldSet, Collapse } from '@grafana/ui';
import {
DataSourcePluginOptionsEditorProps,
onUpdateDatasourceJsonDataOptionSelect,
Expand Down Expand Up @@ -79,7 +79,6 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
}, [loadRegions]);

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

return (
<>
Expand All @@ -91,7 +90,6 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
setIsARNInstructionsOpen={setIsARNInstructionsOpen}
awsAssumeRoleEnabled={awsAssumeRoleEnabled}
regions={regions}
assumeRoleInstructionsStyle={styles.assumeRoleInstructions}
{...props}
/>
) : (
Expand Down Expand Up @@ -176,7 +174,7 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
)}

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

function getStyles() {
return {
assumeRoleInstructions: css({
maxWidth: '715px',
}),
};
}
export const assumeRoleInstructionsStyle = css({
maxWidth: '715px',
})

4 changes: 1 addition & 3 deletions src/components/NewConnectionConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { AwsAuthType } from '../types';
import { awsAuthProviderOptions } from '../providers';
import { ConfigSection, ConfigSubSection } from '@grafana/experimental';
import { ConnectionConfigProps } from './ConnectionConfig';
import { ConnectionConfigProps, assumeRoleInstructionsStyle } from './ConnectionConfig';

interface NewConnectionConfigProps extends ConnectionConfigProps {
currentProvider?: SelectableValue<AwsAuthType> | undefined;
Expand All @@ -19,7 +19,6 @@ interface NewConnectionConfigProps extends ConnectionConfigProps {
setIsARNInstructionsOpen: (isOpen: boolean) => void;
awsAssumeRoleEnabled: boolean;
regions: SelectableValue[];
assumeRoleInstructionsStyle: string;
}

export const NewConnectionConfig = ({
Expand All @@ -30,7 +29,6 @@ export const NewConnectionConfig = ({
awsAllowedAuthProviders,
skipHeader,
regions,
assumeRoleInstructionsStyle,
...props
}: NewConnectionConfigProps) => {
const options = props.options;
Expand Down

0 comments on commit 619ea43

Please sign in to comment.