diff --git a/packages/create-plugin/templates/scenes-app/src/components/AppConfig/AppConfig.tsx b/packages/create-plugin/templates/scenes-app/src/components/AppConfig/AppConfig.tsx index 8ad9e8e0d..3b87666a5 100644 --- a/packages/create-plugin/templates/scenes-app/src/components/AppConfig/AppConfig.tsx +++ b/packages/create-plugin/templates/scenes-app/src/components/AppConfig/AppConfig.tsx @@ -33,6 +33,8 @@ export const AppConfig = ({ plugin }: Props) => { isApiKeySet: Boolean(jsonData?.isApiKeySet), }); + const isSubmitDisabled = Boolean(!state.apiUrl || (!state.isApiKeySet && !state.apiKey)); + const onResetApiKey = () => setState({ ...state, @@ -54,106 +56,62 @@ export const AppConfig = ({ plugin }: Props) => { }); }; + const onSubmit = () => { + updatePluginAndReload(plugin.meta.id, { + enabled, + pinned, + jsonData: { + apiUrl: state.apiUrl, + isApiKeySet: true, + }, + // This cannot be queried later by the frontend. + // We don't want to override it in case it was set previously and left untouched now. + secureJsonData: state.isApiKeySet + ? undefined + : { + apiKey: state.apiKey, + }, + }); + }; + return (