diff --git a/src/components/ConfigScreen/ConfigScreen.tsx b/src/components/ConfigScreen/ConfigScreen.tsx index 8d4a8159..183f304c 100644 --- a/src/components/ConfigScreen/ConfigScreen.tsx +++ b/src/components/ConfigScreen/ConfigScreen.tsx @@ -23,6 +23,7 @@ import packageJson from './../../../package.json'; export interface AppInstallationParameters { imgixAPIKey?: string; + sourceID?: string; successfullyVerified?: boolean; } @@ -197,15 +198,32 @@ export default class Config extends Component { return { ...currentState, EditorInterface }; }; - handleChange = (e: ChangeEvent) => { + handleAPIKeyChange = ( + e: ChangeEvent, + ) => { + const prevState = { ...this.state }; this.setState({ parameters: { + ...prevState.parameters, imgixAPIKey: e.target.value, successfullyVerified: this.state.parameters.successfullyVerified, }, }); }; + handleSourceIDChange = ( + e: ChangeEvent, + ) => { + const prevState = { ...this.state }; + this.setState({ + parameters: { + ...prevState.parameters, + sourceID: e.target.value, + successfullyVerified: this.state.parameters.successfullyVerified, + }, + }); + }; + verifyAPIKey = async () => { this.setState({ isButtonLoading: true }); @@ -219,7 +237,12 @@ export default class Config extends Component { }; try { - await imgix.request('sources'); + if (this.state.parameters.sourceID?.length) { + await imgix.request(`sources/${this.state.parameters.sourceID}`); + } else { + await imgix.request('sources'); + } + Notification.setPosition('top', { offset: 650 }); Notification.success( 'Your API key was successfully confirmed! Click the Install/Save button (in the top right corner) to complete installation.', @@ -347,7 +370,7 @@ export default class Config extends Component { type: 'password', autoComplete: 'new-api-key', }} - onChange={this.handleChange} + onChange={this.handleAPIKeyChange} /> {this.state.parameters.successfullyVerified && ( @@ -366,6 +389,22 @@ export default class Config extends Component { https://dashboard.imgix.com/api-keys

+
+
+ +
+
+ !allSources.length ? ( + + ) : ( + + ) } > - {!allSources.length ? ( - - Loading - - ) : null} {allSources.map((source: SourceProps) => ( handleClick(source)}> {source.name}