From 1247c8a55ca239d06472821ce0fdaeb41bb8267e Mon Sep 17 00:00:00 2001 From: Levente Balogh Date: Wed, 7 Aug 2024 20:42:55 +0200 Subject: [PATCH] feat(scenes-app): wrap the config fields with `
` --- .../src/components/AppConfig/AppConfig.tsx | 152 +++++++----------- 1 file changed, 55 insertions(+), 97 deletions(-) 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 (
- {/* ENABLE / DISABLE PLUGIN */} -
- {!enabled && ( - <> -
The plugin is currently not enabled.
- - - )} - - {/* Disable the plugin */} - {enabled && ( - <> -
The plugin is currently enabled.
- - - )} -
- - {/* CUSTOM SETTINGS */} -
- {/* API Key */} - - - - - {/* API Url */} - - - - -
- -
-
+
+ +
); };