Skip to content

Commit

Permalink
pass flag as component prop instead of in jsondata
Browse files Browse the repository at this point in the history
  • Loading branch information
bohandley committed Aug 3, 2023
1 parent 0e36f10 commit d349702
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/ConnectionConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,17 @@ export interface ConnectionConfigProps<
skipEndpoint?: boolean;
children?: React.ReactNode;
labelWidth?: number;
inExperimentalAuthComponent?: boolean;
}

export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionConfigProps) => {
const [regions, setRegions] = useState((props.standardRegions || standardRegions).map(toOption));
const { loadRegions, onOptionsChange, skipHeader = false, skipEndpoint = false } = props;
const { labelWidth = DEFAULT_LABEL_WIDTH, options } = props;
const {
labelWidth = DEFAULT_LABEL_WIDTH,
options,
inExperimentalAuthComponent
} = props;
let profile = options.jsonData.profile;
if (profile === undefined) {
profile = options.database;
Expand Down Expand Up @@ -71,8 +76,6 @@ export const ConnectionConfig: FC<ConnectionConfigProps> = (props: ConnectionCon
loadRegions().then((regions) => setRegions(regions.map(toOption)));
}, [loadRegions]);

const inExperimentalAuthComponent = options.jsonData.inExperimentalAuthComponent;

const inputWidth = inExperimentalAuthComponent ? "width-20" : "width-30";

return (
Expand Down
9 changes: 7 additions & 2 deletions src/SIGV4ConnectionConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import { ConnectionConfig, ConnectionConfigProps } from './ConnectionConfig';

import { AwsAuthDataSourceSecureJsonData, AwsAuthDataSourceJsonData } from './types';

export const SIGV4ConnectionConfig: React.FC<DataSourcePluginOptionsEditorProps<any, any>> = (
props: DataSourcePluginOptionsEditorProps<any, any>
export interface SIGV4ConnectionConfigProps extends DataSourcePluginOptionsEditorProps<any, any> {
inExperimentalAuthComponent?: boolean;
};

export const SIGV4ConnectionConfig: React.FC<SIGV4ConnectionConfigProps> = (
props: SIGV4ConnectionConfigProps
) => {
const { onOptionsChange, options } = props;

Expand Down Expand Up @@ -54,6 +58,7 @@ export const SIGV4ConnectionConfig: React.FC<DataSourcePluginOptionsEditorProps<
secretKey: options.secureJsonData?.sigV4SecretKey,
},
},
inExperimentalAuthComponent: props.inExperimentalAuthComponent,
};

return (
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface AwsAuthDataSourceJsonData extends DataSourceJsonData {
profile?: string; // Credentials profile name, as specified in ~/.aws/credentials
defaultRegion?: string; // region if it is not defined by your credentials file
endpoint?: string;
inExperimentalAuthComponent?: boolean;
}

export interface AwsAuthDataSourceSecureJsonData {
Expand Down

0 comments on commit d349702

Please sign in to comment.