@@ -4,7 +4,7 @@ import { dropdownInputSimpleControl } from "comps/controls/dropdownInputSimpleCo
44import { MultiCompBuilder , valueComp , withDefault } from "comps/generators" ;
55import { AddIcon , Dropdown } from "lowcoder-design" ;
66import { EllipsisSpan } from "pages/setting/theme/styledComponents" ;
7- import { useEffect } from "react" ;
7+ import { useEffect , useState } from "react" ;
88import { useSelector } from "react-redux" ;
99import { getDefaultTheme , getThemeList } from "redux/selectors/commonSettingSelectors" ;
1010import styled , { css } from "styled-components" ;
@@ -19,6 +19,8 @@ import { IconControl } from "comps/controls/iconControl";
1919import { dropdownControl } from "comps/controls/dropdownControl" ;
2020import { ApplicationCategoriesEnum } from "constants/applicationConstants" ;
2121import { BoolControl } from "../controls/boolControl" ;
22+ import { getNpmPackageMeta } from "../utils/remote" ;
23+ import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils" ;
2224
2325const TITLE = trans ( "appSetting.title" ) ;
2426const USER_DEFINE = "__USER_DEFINE" ;
@@ -189,13 +191,15 @@ const childrenMap = {
189191 preventAppStylesOverwriting : withDefault ( BoolControl , true ) ,
190192 customShortcuts : CustomShortcutsComp ,
191193 disableCollision : valueComp < boolean > ( false ) ,
194+ lowcoderCompVersion : withDefault ( StringControl , 'latest' ) ,
192195} ;
193196type ChildrenInstance = RecordConstructorToComp < typeof childrenMap > & {
194197 themeList : ThemeType [ ] ;
195198 defaultTheme : string ;
196199} ;
197200
198201function AppSettingsModal ( props : ChildrenInstance ) {
202+ const [ lowcoderCompVersions , setLowcoderCompVersions ] = useState ( [ 'latest' ] ) ;
199203 const {
200204 themeList,
201205 defaultTheme,
@@ -207,11 +211,14 @@ function AppSettingsModal(props: ChildrenInstance) {
207211 category,
208212 showHeaderInPublic,
209213 preventAppStylesOverwriting,
214+ lowcoderCompVersion,
210215 } = props ;
216+
211217 const THEME_OPTIONS = themeList ?. map ( ( theme ) => ( {
212218 label : theme . name ,
213219 value : theme . id + "" ,
214220 } ) ) ;
221+
215222 const themeWithDefault = (
216223 themeId . getView ( ) === DEFAULT_THEMEID ||
217224 ( ! ! themeId . getView ( ) &&
@@ -225,6 +232,17 @@ function AppSettingsModal(props: ChildrenInstance) {
225232 themeId . dispatchChangeValueAction ( themeWithDefault ) ;
226233 }
227234 } , [ 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+
228246
229247 const DropdownItem = ( params : { value : string } ) => {
230248 const themeItem = themeList . find ( ( theme ) => theme . id === params . value ) ;
@@ -308,6 +326,31 @@ function AppSettingsModal(props: ChildrenInstance) {
308326 } ) }
309327 </ div >
310328 </ 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 />
311354 { props . customShortcuts . getPropertyView ( ) }
312355 </ SettingsStyled >
313356 ) ;
0 commit comments