PromucFlow_constructor/app/client/src/pages/Settings/SaveSettings.tsx
Nilesh Sarupriya 98a8287697
chore: add utility for widget level acl (#23526)
## Description
> This is a utility code change for supporting Widget Level ACL in
Appsmith-EE.

#### PR fixes following issue(s)
Fixes https://github.com/appsmithorg/appsmith/issues/23260

#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)

## Testing
> A test case has been added to assert the user management role.

#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>

## Checklist:
#### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed

---------

Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
2023-06-02 16:36:41 +05:30

74 lines
2.0 KiB
TypeScript

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