11import { HelpText } from "components/HelpText" ;
22import { 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" ;
44import React , { useEffect , useMemo , useState } from "react" ;
55import { useDispatch , useSelector } from "react-redux" ;
66import styled from "styled-components" ;
@@ -21,7 +21,6 @@ import { getUser } from "@lowcoder-ee/redux/selectors/usersSelectors";
2121import { Org } from "@lowcoder-ee/constants/orgConstants" ;
2222import { BrandingConfig , BrandingSettings , createBranding , getBranding } from "@lowcoder-ee/api/enterpriseApi" ;
2323import Flex from "antd/es/flex" ;
24- import Button from "antd/es/button" ;
2524import { fetchBrandingSetting } from "@lowcoder-ee/redux/reduxActions/enterpriseActions" ;
2625import { Level1SettingPageTitle } from "../styled" ;
2726
@@ -184,6 +183,7 @@ const beforeUpload = (file: RcFile) => {
184183export function BrandingSetting ( ) {
185184 const dispatch = useDispatch ( ) ;
186185 const [ configOrgId , setConfigOrgId ] = useState < string > ( '' ) ;
186+ const [ configOrgName , setConfigOrgName ] = useState < string | undefined > ( 'Global' ) ;
187187 const [ settings , setSettings ] = useState < BrandingSettings > ( defaultSettings ) ;
188188 const [ brandingConfig , setBrandingConfig ] = useState < BrandingConfig > ( ) ;
189189 const [ defaultBrandingConfig , setDefaultBrandingConfig ] = useState < BrandingConfig > ( ) ;
@@ -273,7 +273,7 @@ export function BrandingSetting() {
273273 }
274274 }
275275
276- const handleSave = async ( ) => {
276+ const handleSave = async ( brandingConfig ?: BrandingConfig ) => {
277277 try {
278278 await createBranding ( {
279279 ...brandingConfig ,
@@ -288,6 +288,26 @@ export function BrandingSetting() {
288288 }
289289 }
290290
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+
291311 const uploadButton = ( loading : boolean ) => (
292312 < div >
293313 { loading ? < LoadingOutlined /> : < PlusOutlined /> }
@@ -319,6 +339,7 @@ export function BrandingSetting() {
319339 allowClear
320340 onChange = { ( value ) => {
321341 setConfigOrgId ( value ) ;
342+ setConfigOrgName ( orgsList . find ( org => org . value === value ) ?. label )
322343 } }
323344 value = { configOrgId }
324345 />
@@ -756,6 +777,13 @@ export function BrandingSetting() {
756777 </ BrandingSettingContent >
757778
758779 < 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 >
759787 < TacoButton
760788 buttonType = "normal"
761789 icon = { < ResetIcon /> }
@@ -767,7 +795,7 @@ export function BrandingSetting() {
767795 < TacoButton
768796 buttonType = "primary"
769797 disabled = { isBrandingNotChange ( ) }
770- onClick = { handleSave }
798+ onClick = { ( ) => handleSave ( brandingConfig ) }
771799 >
772800 { trans ( "branding.saveButton" ) }
773801 </ TacoButton >
0 commit comments