## Description - Adding a check to not update the settings if the variable doesn't exist in docker.env and the value for this variable is changed to false via the Admin settings page. - Calling the fetch admin settings API on general page, everytime it is clicked, to update admin emails, which needs an update everytime a user is manually given Instance Administrator role via Users page under Access control. #### PR fixes following issue(s) Fixes #23473 #### Media https://cjrc9tc9nt.vmaker.com/record/AfxXuzXlMlGL0YuP #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing #### How Has This Been Tested? - [x] Manual - [ ] Jest - [ ] Cypress ## 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 - [ ] 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
221 lines
6.4 KiB
TypeScript
221 lines
6.4 KiB
TypeScript
import React from "react";
|
|
import { Link } from "react-router-dom";
|
|
import styled from "styled-components";
|
|
import AdminConfig from "@appsmith/pages/AdminSettings/config";
|
|
import type { Category } from "@appsmith/pages/AdminSettings/config/types";
|
|
import { adminSettingsCategoryUrl } from "RouteBuilder";
|
|
import { useParams } from "react-router";
|
|
import { createMessage, UPGRADE } from "@appsmith/constants/messages";
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
|
import { Icon, Text } from "design-system";
|
|
import { useDispatch } from "react-redux";
|
|
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
|
|
|
|
export const Wrapper = styled.div`
|
|
flex-basis: ${(props) => props.theme.sidebarWidth};
|
|
overflow-y: auto;
|
|
border-right: 1px solid var(--ads-v2-color-border);
|
|
flex-shrink: 0;
|
|
|
|
&::-webkit-scrollbar {
|
|
display: none;
|
|
}
|
|
|
|
> div:not(:first-child) {
|
|
border-top: 1px solid var(--ads-v2-color-border);
|
|
}
|
|
`;
|
|
|
|
export const HeaderContainer = styled.div`
|
|
padding: 20px 0;
|
|
margin: 0 16px;
|
|
`;
|
|
|
|
export const StyledHeader = styled(Text)`
|
|
height: 20px;
|
|
margin: 8px 16px 8px;
|
|
color: var(--ads-v2-color-fg-emphasis);
|
|
`;
|
|
|
|
export const CategoryList = styled.ul`
|
|
margin: 0;
|
|
list-style-type: none;
|
|
`;
|
|
|
|
export const CategoryItem = styled.li`
|
|
/* width: 90%; */
|
|
`;
|
|
|
|
export const StyledLink = styled(Link)<{ $active: boolean }>`
|
|
height: 38px;
|
|
padding: 8px 16px;
|
|
border-radius: var(--ads-v2-border-radius);
|
|
background-color: ${(props) =>
|
|
props.$active ? `var(--ads-v2-color-bg-muted)` : ""};
|
|
display: flex;
|
|
gap: 12px;
|
|
|
|
&& {
|
|
color: var(--ads-v2-color-fg);
|
|
}
|
|
|
|
&:hover {
|
|
text-decoration: none;
|
|
}
|
|
|
|
&:hover:not(.active) {
|
|
background-color: var(--ads-v2-color-bg-subtle);
|
|
}
|
|
`;
|
|
|
|
export const SettingName = styled(Text)<{ active?: boolean }>`
|
|
color: ${(props) =>
|
|
props.active
|
|
? "var(--ads-v2-color-fg-emphasis-plus)"
|
|
: "var(--ads-v2-color-fg)"};
|
|
font-weight: 400;
|
|
`;
|
|
|
|
export function getSettingsCategory() {
|
|
return Array.from(AdminConfig.categories);
|
|
}
|
|
|
|
export function Categories({
|
|
categories,
|
|
currentCategory,
|
|
currentSubCategory,
|
|
parentCategory,
|
|
showSubCategory,
|
|
}: {
|
|
categories?: Category[];
|
|
parentCategory?: Category;
|
|
currentCategory: string;
|
|
currentSubCategory?: string;
|
|
showSubCategory?: boolean;
|
|
}) {
|
|
const dispatch = useDispatch();
|
|
|
|
const onClickHandler = (category: string) => {
|
|
if (category === "general") {
|
|
dispatch({
|
|
type: ReduxActionTypes.FETCH_ADMIN_SETTINGS,
|
|
});
|
|
}
|
|
};
|
|
|
|
return (
|
|
<CategoryList className="t--settings-category-list">
|
|
{categories?.map((config) => {
|
|
const active =
|
|
!!currentSubCategory && showSubCategory
|
|
? currentSubCategory == config.slug
|
|
: currentCategory == config.slug;
|
|
return (
|
|
<CategoryItem key={config.slug}>
|
|
<StyledLink
|
|
$active={active}
|
|
className={`t--settings-category-${config.slug} ${
|
|
active ? "active" : ""
|
|
}`}
|
|
onClick={() => onClickHandler(config.slug)}
|
|
to={
|
|
!parentCategory
|
|
? adminSettingsCategoryUrl({ category: config.slug })
|
|
: adminSettingsCategoryUrl({
|
|
category: parentCategory.slug,
|
|
selected: config.slug,
|
|
})
|
|
}
|
|
>
|
|
{config?.icon && <Icon name={config?.icon} size="md" />}
|
|
<SettingName active={active}>{config.title}</SettingName>
|
|
</StyledLink>
|
|
{showSubCategory && (
|
|
<Categories
|
|
categories={config.children}
|
|
currentCategory={currentCategory}
|
|
currentSubCategory={currentSubCategory}
|
|
parentCategory={config}
|
|
/>
|
|
)}
|
|
</CategoryItem>
|
|
);
|
|
})}
|
|
</CategoryList>
|
|
);
|
|
}
|
|
|
|
export default function LeftPane() {
|
|
const categories = getSettingsCategory();
|
|
const { category, selected: subCategory } = useParams() as any;
|
|
|
|
function triggerAnalytics(source: string) {
|
|
AnalyticsUtil.logEvent("ADMIN_SETTINGS_CLICK", {
|
|
source,
|
|
});
|
|
}
|
|
|
|
return (
|
|
<Wrapper>
|
|
<HeaderContainer>
|
|
<StyledHeader kind="heading-s" renderAs="p">
|
|
Admin settings
|
|
</StyledHeader>
|
|
<Categories
|
|
categories={categories}
|
|
currentCategory={category}
|
|
currentSubCategory={subCategory}
|
|
/>
|
|
</HeaderContainer>
|
|
<HeaderContainer>
|
|
<StyledHeader kind="heading-s" renderAs="p">
|
|
Business
|
|
</StyledHeader>
|
|
<CategoryList data-testid="t--enterprise-settings-category-list">
|
|
<CategoryItem>
|
|
<StyledLink
|
|
$active={category === "access-control"}
|
|
className={`${category === "access-control" ? "active" : ""}`}
|
|
data-testid="t--enterprise-settings-category-item-access-control"
|
|
to="/settings/access-control"
|
|
>
|
|
<Icon name="lock-2-line" size="md" />
|
|
<SettingName active={category === "access-control"}>
|
|
Access control
|
|
</SettingName>
|
|
</StyledLink>
|
|
</CategoryItem>
|
|
<CategoryItem>
|
|
<StyledLink
|
|
$active={category === "audit-logs"}
|
|
className={`${category === "audit-logs" ? "active" : ""}`}
|
|
data-testid="t--enterprise-settings-category-item-audit-logs"
|
|
onClick={() => triggerAnalytics("AuditLogs")}
|
|
to="/settings/audit-logs"
|
|
>
|
|
<Icon name="lock-2-line" size="md" />
|
|
<SettingName active={category === "audit-logs"}>
|
|
Audit logs
|
|
</SettingName>
|
|
</StyledLink>
|
|
</CategoryItem>
|
|
<CategoryItem>
|
|
<StyledLink
|
|
$active={category === "business-edition"}
|
|
className={`${category === "business-edition" ? "active" : ""}`}
|
|
data-testid="t--enterprise-settings-category-item-be"
|
|
onClick={() => triggerAnalytics("BusinessEdition")}
|
|
to="/settings/business-edition"
|
|
>
|
|
<Icon name="arrow-up-line" size="md" />
|
|
<SettingName active={category === "business-edition"}>
|
|
{createMessage(UPGRADE)}
|
|
</SettingName>
|
|
</StyledLink>
|
|
</CategoryItem>
|
|
</CategoryList>
|
|
</HeaderContainer>
|
|
</Wrapper>
|
|
);
|
|
}
|