1
1
import { HelpText } from "components/HelpText" ;
2
2
import { Upload , Switch , Card , Input , message , Divider } from "antd" ;
3
- import { TacoButton , CustomSelect , messageInstance , Dropdown , ResetIcon } from "lowcoder-design" ;
3
+ import { TacoButton , CustomSelect , messageInstance , Dropdown , ResetIcon , CustomModal } from "lowcoder-design" ;
4
4
import React , { useEffect , useMemo , useState } from "react" ;
5
5
import { useDispatch , useSelector } from "react-redux" ;
6
6
import styled from "styled-components" ;
@@ -21,7 +21,6 @@ import { getUser } from "@lowcoder-ee/redux/selectors/usersSelectors";
21
21
import { Org } from "@lowcoder-ee/constants/orgConstants" ;
22
22
import { BrandingConfig , BrandingSettings , createBranding , getBranding } from "@lowcoder-ee/api/enterpriseApi" ;
23
23
import Flex from "antd/es/flex" ;
24
- import Button from "antd/es/button" ;
25
24
import { fetchBrandingSetting } from "@lowcoder-ee/redux/reduxActions/enterpriseActions" ;
26
25
import { Level1SettingPageTitle } from "../styled" ;
27
26
@@ -184,6 +183,7 @@ const beforeUpload = (file: RcFile) => {
184
183
export function BrandingSetting ( ) {
185
184
const dispatch = useDispatch ( ) ;
186
185
const [ configOrgId , setConfigOrgId ] = useState < string > ( '' ) ;
186
+ const [ configOrgName , setConfigOrgName ] = useState < string | undefined > ( 'Global' ) ;
187
187
const [ settings , setSettings ] = useState < BrandingSettings > ( defaultSettings ) ;
188
188
const [ brandingConfig , setBrandingConfig ] = useState < BrandingConfig > ( ) ;
189
189
const [ defaultBrandingConfig , setDefaultBrandingConfig ] = useState < BrandingConfig > ( ) ;
@@ -273,7 +273,7 @@ export function BrandingSetting() {
273
273
}
274
274
}
275
275
276
- const handleSave = async ( ) => {
276
+ const handleSave = async ( brandingConfig ?: BrandingConfig ) => {
277
277
try {
278
278
await createBranding ( {
279
279
...brandingConfig ,
@@ -288,6 +288,26 @@ export function BrandingSetting() {
288
288
}
289
289
}
290
290
291
+ const handleDelete = ( id : string ) => {
292
+ CustomModal . confirm ( {
293
+ title : trans ( "branding.deleteBranding" ) ,
294
+ content : trans ( "branding.deleteBrandingContent" , { orgName : configOrgName } ) ,
295
+ onConfirm : ( ) => {
296
+ const newBrandingConfig = {
297
+ ...brandingConfig ,
298
+ config_name : '' ,
299
+ config_description : '' ,
300
+ config_icon : '' ,
301
+ config_set : { } ,
302
+ }
303
+ setBrandingConfig ( newBrandingConfig ) ;
304
+ handleSave ( newBrandingConfig ) ;
305
+ } ,
306
+ confirmBtnType : "delete" ,
307
+ okText : trans ( "delete" ) ,
308
+ } )
309
+ }
310
+
291
311
const uploadButton = ( loading : boolean ) => (
292
312
< div >
293
313
{ loading ? < LoadingOutlined /> : < PlusOutlined /> }
@@ -319,6 +339,7 @@ export function BrandingSetting() {
319
339
allowClear
320
340
onChange = { ( value ) => {
321
341
setConfigOrgId ( value ) ;
342
+ setConfigOrgName ( orgsList . find ( org => org . value === value ) ?. label )
322
343
} }
323
344
value = { configOrgId }
324
345
/>
@@ -756,6 +777,13 @@ export function BrandingSetting() {
756
777
</ BrandingSettingContent >
757
778
758
779
< Flex gap = { 10 } style = { { marginTop : 20 } } >
780
+ < TacoButton
781
+ buttonType = "delete"
782
+ disabled = { ! Boolean ( brandingConfig ?. id ) }
783
+ onClick = { ( ) => handleDelete ( brandingConfig ?. id ! ) }
784
+ >
785
+ { trans ( "delete" ) }
786
+ </ TacoButton >
759
787
< TacoButton
760
788
buttonType = "normal"
761
789
icon = { < ResetIcon /> }
@@ -767,7 +795,7 @@ export function BrandingSetting() {
767
795
< TacoButton
768
796
buttonType = "primary"
769
797
disabled = { isBrandingNotChange ( ) }
770
- onClick = { handleSave }
798
+ onClick = { ( ) => handleSave ( brandingConfig ) }
771
799
>
772
800
{ trans ( "branding.saveButton" ) }
773
801
</ TacoButton >
0 commit comments