Skip to content

Commit 4e8b332

Browse files
added reset option in branding settings
1 parent c8a61d3 commit 4e8b332

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2966,7 +2966,7 @@ export const en = {
29662966
"documentationLinkPlaceholder": "Enter the URL for your documentation...",
29672967
"documentationLinkHelp": "Provide a valid URL that users can visit for documentation.",
29682968
"whatsNewSection": "Documentation Settings",
2969-
"whatsNewLink": "Documentation Link",
2969+
"whatsNewLink": "What's New Link",
29702970
"whatsNewLinkPlaceholder": "Enter the URL for your documentation...",
29712971
"whatsNewLinkHelp": "Provide a valid URL that users can visit for your news."
29722972
},

client/packages/lowcoder/src/pages/setting/branding/BrandingSetting.tsx

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HelpText } from "components/HelpText";
22
import { Upload, Switch, Card, Input, message, Divider } from "antd";
3-
import { TacoButton, CustomSelect, messageInstance, Dropdown } from "lowcoder-design";
3+
import { TacoButton, CustomSelect, messageInstance, Dropdown, ResetIcon } from "lowcoder-design";
44
import React, { useEffect, useMemo, useState } from "react";
55
import { useSelector } from "react-redux";
66
import styled from "styled-components";
@@ -20,6 +20,8 @@ import { buildMaterialPreviewURL } from "@lowcoder-ee/util/materialUtils";
2020
import { getUser } from "@lowcoder-ee/redux/selectors/usersSelectors";
2121
import { Org } from "@lowcoder-ee/constants/orgConstants";
2222
import { BrandingConfig, BrandingSettings, createBranding, getBranding } from "@lowcoder-ee/api/enterpriseApi";
23+
import Flex from "antd/es/flex";
24+
import Button from "antd/es/button";
2325

2426
const { TextArea } = Input;
2527

@@ -169,6 +171,7 @@ export function BrandingSetting() {
169171
const [configOrgId, setConfigOrgId] = useState<string>('');
170172
const [settings, setSettings] = useState<BrandingSettings>(defaultSettings);
171173
const [brandingConfig, setBrandingConfig] = useState<BrandingConfig>();
174+
const [defaultBrandingConfig, setDefaultBrandingConfig] = useState<BrandingConfig>();
172175
const [loading, setLoading] = useState({
173176
[SettingsEnum.LOGO]: false,
174177
[SettingsEnum.SQUARE_LOGO]: false,
@@ -197,14 +200,23 @@ export function BrandingSetting() {
197200
try {
198201
const branding = await getBranding(configOrgId);
199202
setBrandingConfig(branding);
203+
setDefaultBrandingConfig(branding);
200204
} catch(e) {
201205
setBrandingConfig(undefined);
206+
setDefaultBrandingConfig(undefined);
202207
}
203208
}
204209

205210
fetchBrandingDetails();
206211
}, [configOrgId]);
207212

213+
const isBrandingNotChange = () => {
214+
return (
215+
JSON.stringify({ ...brandingConfig }) ===
216+
JSON.stringify({ ...defaultBrandingConfig })
217+
);
218+
}
219+
208220
const updateSettings = (key: keyof BrandingSettings, value: any) => {
209221
setBrandingConfig((branding) => ({
210222
...branding,
@@ -247,10 +259,16 @@ export function BrandingSetting() {
247259
}
248260

249261
const handleSave = async () => {
250-
const response = await createBranding({
251-
...brandingConfig,
252-
org_id: configOrgId,
253-
});
262+
try {
263+
await createBranding({
264+
...brandingConfig,
265+
org_id: configOrgId,
266+
});
267+
setDefaultBrandingConfig(brandingConfig);
268+
messageInstance.success(trans("theme.saveSuccessMsg"));
269+
} catch (e) {
270+
console.error(e)
271+
}
254272
}
255273

256274
const uploadButton = (loading: boolean) => (
@@ -719,13 +737,24 @@ export function BrandingSetting() {
719737
)}
720738
</Card>
721739
</BrandingSettingContent>
722-
723-
<TacoButton
724-
onClick={handleSave}
725-
style={{ marginTop: 20 }}
726-
>
727-
{trans("branding.saveButton")}
728-
</TacoButton>
740+
741+
<Flex gap={10} style={{ marginTop: 20 }}>
742+
<TacoButton
743+
buttonType="normal"
744+
icon={<ResetIcon />}
745+
disabled={isBrandingNotChange()}
746+
onClick={() => setBrandingConfig(defaultBrandingConfig)}
747+
>
748+
{trans("reset")}
749+
</TacoButton>
750+
<TacoButton
751+
buttonType="primary"
752+
disabled={isBrandingNotChange()}
753+
onClick={handleSave}
754+
>
755+
{trans("branding.saveButton")}
756+
</TacoButton>
757+
</Flex>
729758
</DetailContent>
730759
</DetailContainer>
731760
);

0 commit comments

Comments
 (0)