@@ -4,7 +4,7 @@ import { dropdownInputSimpleControl } from "comps/controls/dropdownInputSimpleCo
4
4
import { MultiCompBuilder , valueComp , withDefault } from "comps/generators" ;
5
5
import { AddIcon , Dropdown } from "lowcoder-design" ;
6
6
import { EllipsisSpan } from "pages/setting/theme/styledComponents" ;
7
- import { useEffect } from "react" ;
7
+ import { useEffect , useState } from "react" ;
8
8
import { useSelector } from "react-redux" ;
9
9
import { getDefaultTheme , getThemeList } from "redux/selectors/commonSettingSelectors" ;
10
10
import styled , { css } from "styled-components" ;
@@ -19,6 +19,8 @@ import { IconControl } from "comps/controls/iconControl";
19
19
import { dropdownControl } from "comps/controls/dropdownControl" ;
20
20
import { ApplicationCategoriesEnum } from "constants/applicationConstants" ;
21
21
import { BoolControl } from "../controls/boolControl" ;
22
+ import { getNpmPackageMeta } from "../utils/remote" ;
23
+ import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils" ;
22
24
23
25
const TITLE = trans ( "appSetting.title" ) ;
24
26
const USER_DEFINE = "__USER_DEFINE" ;
@@ -189,13 +191,15 @@ const childrenMap = {
189
191
preventAppStylesOverwriting : withDefault ( BoolControl , true ) ,
190
192
customShortcuts : CustomShortcutsComp ,
191
193
disableCollision : valueComp < boolean > ( false ) ,
194
+ lowcoderCompVersion : withDefault ( StringControl , 'latest' ) ,
192
195
} ;
193
196
type ChildrenInstance = RecordConstructorToComp < typeof childrenMap > & {
194
197
themeList : ThemeType [ ] ;
195
198
defaultTheme : string ;
196
199
} ;
197
200
198
201
function AppSettingsModal ( props : ChildrenInstance ) {
202
+ const [ lowcoderCompVersions , setLowcoderCompVersions ] = useState ( [ 'latest' ] ) ;
199
203
const {
200
204
themeList,
201
205
defaultTheme,
@@ -207,11 +211,14 @@ function AppSettingsModal(props: ChildrenInstance) {
207
211
category,
208
212
showHeaderInPublic,
209
213
preventAppStylesOverwriting,
214
+ lowcoderCompVersion,
210
215
} = props ;
216
+
211
217
const THEME_OPTIONS = themeList ?. map ( ( theme ) => ( {
212
218
label : theme . name ,
213
219
value : theme . id + "" ,
214
220
} ) ) ;
221
+
215
222
const themeWithDefault = (
216
223
themeId . getView ( ) === DEFAULT_THEMEID ||
217
224
( ! ! themeId . getView ( ) &&
@@ -225,6 +232,17 @@ function AppSettingsModal(props: ChildrenInstance) {
225
232
themeId . dispatchChangeValueAction ( themeWithDefault ) ;
226
233
}
227
234
} , [ themeWithDefault ] ) ;
235
+
236
+ useEffect ( ( ) => {
237
+ const fetchCompsPackageMeta = async ( ) => {
238
+ const packageMeta = await getNpmPackageMeta ( 'lowcoder-comps' ) ;
239
+ if ( packageMeta ?. versions ) {
240
+ setLowcoderCompVersions ( Object . keys ( packageMeta . versions ) . reverse ( ) )
241
+ }
242
+ }
243
+ fetchCompsPackageMeta ( ) ;
244
+ } , [ ] )
245
+
228
246
229
247
const DropdownItem = ( params : { value : string } ) => {
230
248
const themeItem = themeList . find ( ( theme ) => theme . id === params . value ) ;
@@ -308,6 +326,31 @@ function AppSettingsModal(props: ChildrenInstance) {
308
326
} ) }
309
327
</ div >
310
328
</ DivStyled >
329
+ < DividerStyled />
330
+ < DivStyled >
331
+ < Dropdown
332
+ defaultValue = { lowcoderCompVersion . getView ( ) }
333
+ placeholder = { 'Select version' }
334
+ options = {
335
+ lowcoderCompVersions . map ( version => ( { label : version , value : version } ) )
336
+ }
337
+ label = { 'Lowcoder Comps Version' }
338
+ placement = "bottom"
339
+ allowClear
340
+ onChange = { async ( value ) => {
341
+ await getPromiseAfterDispatch (
342
+ lowcoderCompVersion . dispatch ,
343
+ lowcoderCompVersion . changeValueAction ( value ) , {
344
+ autoHandleAfterReduce : true ,
345
+ }
346
+ )
347
+ setTimeout ( ( ) => {
348
+ window . location . reload ( ) ;
349
+ } , 1000 ) ;
350
+ } }
351
+ />
352
+ </ DivStyled >
353
+ < DividerStyled />
311
354
{ props . customShortcuts . getPropertyView ( ) }
312
355
</ SettingsStyled >
313
356
) ;
0 commit comments