2022-02-11 18:08:46 +00:00
|
|
|
import React from "react";
|
2023-06-02 11:06:41 +00:00
|
|
|
import {
|
|
|
|
|
RESET_BUTTON,
|
|
|
|
|
SAVE_AND_RESTART_BUTTON,
|
|
|
|
|
SAVE_BUTTON,
|
|
|
|
|
createMessage,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { Button } from "design-system";
|
2022-02-11 18:08:46 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
|
|
|
|
|
const SettingsButtonWrapper = styled.div`
|
|
|
|
|
position: fixed;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: ${(props) => props.theme.settings.footerHeight}px;
|
2023-05-19 18:37:06 +00:00
|
|
|
padding: ${(props) => props.theme.spaces[11]}px 20px 24px
|
2022-02-11 18:08:46 +00:00
|
|
|
${(props) =>
|
|
|
|
|
props.theme.homePage.leftPane.leftPadding +
|
|
|
|
|
props.theme.homePage.leftPane.width +
|
2022-10-20 16:49:30 +00:00
|
|
|
props.theme.spaces[8]}px;
|
2023-05-19 18:37:06 +00:00
|
|
|
/* box-shadow: ${(props) => props.theme.settings.footerShadow}; */
|
|
|
|
|
border-top: 1px solid var(--ads-v2-color-border);
|
2022-02-11 18:08:46 +00:00
|
|
|
z-index: 2;
|
2023-05-19 18:37:06 +00:00
|
|
|
background-color: var(--ads-v2-color-bg);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row-reverse;
|
|
|
|
|
gap: 16px;
|
|
|
|
|
align-items: center;
|
2022-02-11 18:08:46 +00:00
|
|
|
`;
|
|
|
|
|
|
2022-04-04 07:07:12 +00:00
|
|
|
type SaveAdminSettingsProps = {
|
2022-02-11 18:08:46 +00:00
|
|
|
isSaving?: boolean;
|
|
|
|
|
onSave?: () => void;
|
|
|
|
|
onClear?: () => void;
|
|
|
|
|
settings: Record<string, string>;
|
|
|
|
|
valid: boolean;
|
2023-06-02 11:06:41 +00:00
|
|
|
updatedTenantSettings?: string[];
|
2022-04-04 07:07:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const saveAdminSettings = (props: SaveAdminSettingsProps) => {
|
2023-06-02 11:06:41 +00:00
|
|
|
const { isSaving, onClear, onSave, settings, updatedTenantSettings, valid } =
|
|
|
|
|
props;
|
2022-04-04 07:07:12 +00:00
|
|
|
|
2022-02-11 18:08:46 +00:00
|
|
|
return (
|
|
|
|
|
<SettingsButtonWrapper>
|
2023-05-19 18:37:06 +00:00
|
|
|
<Button
|
2022-02-11 18:08:46 +00:00
|
|
|
className="t--admin-settings-save-button"
|
2023-05-19 18:37:06 +00:00
|
|
|
isDisabled={Object.keys(settings).length == 0 || !valid}
|
2022-04-04 07:07:12 +00:00
|
|
|
isLoading={isSaving}
|
|
|
|
|
onClick={onSave}
|
2023-05-19 18:37:06 +00:00
|
|
|
size="md"
|
|
|
|
|
>
|
2023-06-02 11:06:41 +00:00
|
|
|
{createMessage(
|
|
|
|
|
updatedTenantSettings?.length === Object.keys(settings).length &&
|
|
|
|
|
updatedTenantSettings?.length !== 0
|
|
|
|
|
? SAVE_BUTTON
|
|
|
|
|
: SAVE_AND_RESTART_BUTTON,
|
|
|
|
|
)}
|
2023-05-19 18:37:06 +00:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
2022-02-11 18:08:46 +00:00
|
|
|
className="t--admin-settings-reset-button"
|
2023-05-19 18:37:06 +00:00
|
|
|
isDisabled={Object.keys(settings).length == 0}
|
|
|
|
|
kind="secondary"
|
2022-04-04 07:07:12 +00:00
|
|
|
onClick={onClear}
|
2023-05-19 18:37:06 +00:00
|
|
|
size="md"
|
|
|
|
|
>
|
2023-06-02 11:06:41 +00:00
|
|
|
{createMessage(RESET_BUTTON)}
|
2023-05-19 18:37:06 +00:00
|
|
|
</Button>
|
2022-02-11 18:08:46 +00:00
|
|
|
</SettingsButtonWrapper>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
export default saveAdminSettings;
|