@grafana/create-plugin 5.2.2-canary.1041.1247c8a.0 → 5.2.2-canary.1046.3745b69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "5.2.2-canary.1041.1247c8a.0",
3
+ "version": "5.2.2-canary.1046.3745b69.0",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -87,5 +87,5 @@
87
87
  "engines": {
88
88
  "node": ">=20"
89
89
  },
90
- "gitHead": "1247c8a55ca239d06472821ce0fdaeb41bb8267e"
90
+ "gitHead": "3745b697ca4e22098422d54a86e01e058ee6123c"
91
91
  }
@@ -30,8 +30,6 @@ export const AppConfig = ({ plugin }: AppConfigProps) => {
30
30
  isApiKeySet: Boolean(secureJsonFields?.apiKey),
31
31
  });
32
32
 
33
- const isSubmitDisabled = Boolean(!state.apiUrl || (!state.isApiKeySet && !state.apiKey));
34
-
35
33
  const onResetApiKey = () =>
36
34
  setState({
37
35
  ...state,
@@ -46,30 +44,8 @@ export const AppConfig = ({ plugin }: AppConfigProps) => {
46
44
  });
47
45
  };
48
46
 
49
- const onSubmit = () => {
50
- if (isSubmitDisabled) {
51
- return;
52
- }
53
-
54
- updatePluginAndReload(plugin.meta.id, {
55
- enabled,
56
- pinned,
57
- jsonData: {
58
- apiUrl: state.apiUrl,
59
- },
60
- // This cannot be queried later by the frontend.
61
- // We don't want to override it in case it was set previously and left untouched now.
62
- secureJsonData: state.isApiKeySet
63
- ? undefined
64
- : {
65
- apiKey: state.apiKey,
66
- },
67
- });
68
- };
69
-
70
47
  return (
71
48
  <div data-testid={testIds.appConfig.container}>
72
- <form onSubmit={onSubmit}>
73
49
  <FieldSet label="API Settings">
74
50
  <Field label="API Key" description="A secret key for authenticating to our custom API">
75
51
  <SecretInput
@@ -101,13 +77,28 @@ export const AppConfig = ({ plugin }: AppConfigProps) => {
101
77
  <Button
102
78
  type="submit"
103
79
  data-testid={testIds.appConfig.submit}
104
- disabled={isSubmitDisabled}
80
+ onClick={() =>
81
+ updatePluginAndReload(plugin.meta.id, {
82
+ enabled,
83
+ pinned,
84
+ jsonData: {
85
+ apiUrl: state.apiUrl,
86
+ },
87
+ // This cannot be queried later by the frontend.
88
+ // We don't want to override it in case it was set previously and left untouched now.
89
+ secureJsonData: state.isApiKeySet
90
+ ? undefined
91
+ : {
92
+ apiKey: state.apiKey,
93
+ },
94
+ })
95
+ }
96
+ disabled={Boolean(!state.apiUrl || (!state.isApiKeySet && !state.apiKey))}
105
97
  >
106
98
  Save API settings
107
99
  </Button>
108
100
  </div>
109
101
  </FieldSet>
110
- </form>
111
102
  </div>
112
103
  );
113
104
  };
@@ -169,8 +169,8 @@ jobs:
169
169
 
170
170
  - name: Start Grafana
171
171
  run: |
172
- docker-compose pull
173
- DEVELOPMENT=false GRAFANA_VERSION=$\{{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=$\{{ matrix.GRAFANA_IMAGE.NAME }} docker-compose up -d
172
+ docker compose pull
173
+ DEVELOPMENT=false GRAFANA_VERSION=$\{{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=$\{{ matrix.GRAFANA_IMAGE.NAME }} docker compose up -d
174
174
 
175
175
  - name: Wait for Grafana to start
176
176
  uses: nev7n/wait_for_response@v1
@@ -193,7 +193,7 @@ jobs:
193
193
  docker logs {{ pluginId }} >& grafana-server.log
194
194
 
195
195
  - name: Stop grafana docker
196
- run: docker-compose down
196
+ run: docker compose down
197
197
 
198
198
  - name: Upload server log
199
199
  uses: actions/upload-artifact@v4
@@ -33,8 +33,6 @@ export const AppConfig = ({ plugin }: Props) => {
33
33
  isApiKeySet: Boolean(jsonData?.isApiKeySet),
34
34
  });
35
35
 
36
- const isSubmitDisabled = Boolean(!state.apiUrl || (!state.isApiKeySet && !state.apiKey));
37
-
38
36
  const onResetApiKey = () =>
39
37
  setState({
40
38
  ...state,
@@ -56,62 +54,106 @@ export const AppConfig = ({ plugin }: Props) => {
56
54
  });
57
55
  };
58
56
 
59
- const onSubmit = () => {
60
- updatePluginAndReload(plugin.meta.id, {
61
- enabled,
62
- pinned,
63
- jsonData: {
64
- apiUrl: state.apiUrl,
65
- isApiKeySet: true,
66
- },
67
- // This cannot be queried later by the frontend.
68
- // We don't want to override it in case it was set previously and left untouched now.
69
- secureJsonData: state.isApiKeySet
70
- ? undefined
71
- : {
72
- apiKey: state.apiKey,
73
- },
74
- });
75
- };
76
-
77
57
  return (
78
58
  <div data-testid={testIds.appConfig.container}>
79
- <form onSubmit={onSubmit}>
80
- <FieldSet label="API Settings" className={s.marginTopXl}>
81
- {/* API Key */}
82
- <Field label="API Key" description="A secret key for authenticating to our custom API">
83
- <SecretInput
84
- width={60}
85
- data-testid={testIds.appConfig.apiKey}
86
- id="api-key"
87
- value={state?.apiKey}
88
- isConfigured={state.isApiKeySet}
89
- placeholder={'Your secret API key'}
90
- onChange={onChangeApiKey}
91
- onReset={onResetApiKey}
92
- />
93
- </Field>
94
-
95
- {/* API Url */}
96
- <Field label="API Url" description="" className={s.marginTop}>
97
- <Input
98
- width={60}
99
- id="api-url"
100
- data-testid={testIds.appConfig.apiUrl}
101
- label={`API Url`}
102
- value={state?.apiUrl}
103
- placeholder={`E.g.: http://mywebsite.com/api/v1`}
104
- onChange={onChangeApiUrl}
105
- />
106
- </Field>
107
-
108
- <div className={s.marginTop}>
109
- <Button type="submit" data-testid={testIds.appConfig.submit} disabled={isSubmitDisabled}>
110
- Save API settings
59
+ {/* ENABLE / DISABLE PLUGIN */}
60
+ <FieldSet label="Enable / Disable">
61
+ {!enabled && (
62
+ <>
63
+ <div className={s.colorWeak}>The plugin is currently not enabled.</div>
64
+ <Button
65
+ className={s.marginTop}
66
+ variant="primary"
67
+ onClick={() =>
68
+ updatePluginAndReload(plugin.meta.id, {
69
+ enabled: true,
70
+ pinned: true,
71
+ jsonData,
72
+ })
73
+ }
74
+ >
75
+ Enable plugin
76
+ </Button>
77
+ </>
78
+ )}
79
+
80
+ {/* Disable the plugin */}
81
+ {enabled && (
82
+ <>
83
+ <div className={s.colorWeak}>The plugin is currently enabled.</div>
84
+ <Button
85
+ className={s.marginTop}
86
+ variant="destructive"
87
+ onClick={() =>
88
+ updatePluginAndReload(plugin.meta.id, {
89
+ enabled: false,
90
+ pinned: false,
91
+ jsonData,
92
+ })
93
+ }
94
+ >
95
+ Disable plugin
111
96
  </Button>
112
- </div>
113
- </FieldSet>
114
- </form>
97
+ </>
98
+ )}
99
+ </FieldSet>
100
+
101
+ {/* CUSTOM SETTINGS */}
102
+ <FieldSet label="API Settings" className={s.marginTopXl}>
103
+ {/* API Key */}
104
+ <Field label="API Key" description="A secret key for authenticating to our custom API">
105
+ <SecretInput
106
+ width={60}
107
+ data-testid={testIds.appConfig.apiKey}
108
+ id="api-key"
109
+ value={state?.apiKey}
110
+ isConfigured={state.isApiKeySet}
111
+ placeholder={'Your secret API key'}
112
+ onChange={onChangeApiKey}
113
+ onReset={onResetApiKey}
114
+ />
115
+ </Field>
116
+
117
+ {/* API Url */}
118
+ <Field label="API Url" description="" className={s.marginTop}>
119
+ <Input
120
+ width={60}
121
+ id="api-url"
122
+ data-testid={testIds.appConfig.apiUrl}
123
+ label={`API Url`}
124
+ value={state?.apiUrl}
125
+ placeholder={`E.g.: http://mywebsite.com/api/v1`}
126
+ onChange={onChangeApiUrl}
127
+ />
128
+ </Field>
129
+
130
+ <div className={s.marginTop}>
131
+ <Button
132
+ type="submit"
133
+ data-testid={testIds.appConfig.submit}
134
+ onClick={() =>
135
+ updatePluginAndReload(plugin.meta.id, {
136
+ enabled,
137
+ pinned,
138
+ jsonData: {
139
+ apiUrl: state.apiUrl,
140
+ isApiKeySet: true,
141
+ },
142
+ // This cannot be queried later by the frontend.
143
+ // We don't want to override it in case it was set previously and left untouched now.
144
+ secureJsonData: state.isApiKeySet
145
+ ? undefined
146
+ : {
147
+ apiKey: state.apiKey,
148
+ },
149
+ })
150
+ }
151
+ disabled={Boolean(!state.apiUrl || (!state.isApiKeySet && !state.apiKey))}
152
+ >
153
+ Save API settings
154
+ </Button>
155
+ </div>
156
+ </FieldSet>
115
157
  </div>
116
158
  );
117
159
  };