2021-10-28 04:47:02 +00:00
|
|
|
import { Colors } from "constants/Colors";
|
2021-10-18 07:47:55 +00:00
|
|
|
import { getAdminSettingsCategoryUrl } from "constants/routes";
|
|
|
|
|
import React from "react";
|
|
|
|
|
import { Link, useParams } from "react-router-dom";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { SettingsFactory } from "./SettingsConfig";
|
|
|
|
|
|
|
|
|
|
const Wrapper = styled.div`
|
|
|
|
|
flex-basis: ${(props) =>
|
|
|
|
|
props.theme.homePage.leftPane.width +
|
|
|
|
|
props.theme.homePage.leftPane.leftPadding}px;
|
|
|
|
|
padding: 0px 0px 0px ${(props) => props.theme.homePage.leftPane.leftPadding}px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const HeaderContainer = styled.div``;
|
|
|
|
|
|
|
|
|
|
const StyledHeader = styled.div`
|
2021-10-28 04:47:02 +00:00
|
|
|
font-size: 20px;
|
|
|
|
|
text-transform: capitalize;
|
|
|
|
|
margin: 40px 16px 16px;
|
|
|
|
|
color: ${Colors.MASALA};
|
2021-10-18 07:47:55 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const CategoryList = styled.ul`
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
list-style-type: none;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const Category = styled.li``;
|
|
|
|
|
|
|
|
|
|
const StyledLink = styled(Link)<{ $active: boolean }>`
|
|
|
|
|
height: 38px;
|
|
|
|
|
padding: 10px 16px;
|
|
|
|
|
display: block;
|
|
|
|
|
background-color: ${(props) =>
|
|
|
|
|
props.$active ? props.theme.colors.menuItem.hoverBg : ""};
|
|
|
|
|
font-weight: ${(props) => (props.$active ? 500 : 400)};
|
|
|
|
|
text-transform: capitalize;
|
|
|
|
|
&& {
|
|
|
|
|
color: ${(props) =>
|
|
|
|
|
props.$active
|
|
|
|
|
? props.theme.colors.menuItem.hoverText
|
|
|
|
|
: props.theme.colors.menuItem.normalText};
|
|
|
|
|
}
|
|
|
|
|
&:hover {
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
background-color: ${(props) => props.theme.colors.menuItem.hoverBg};
|
|
|
|
|
color: ${(props) => props.theme.colors.menuItem.hoverText};
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
function useSettingsCategory() {
|
|
|
|
|
return Array.from(SettingsFactory.categories)
|
|
|
|
|
.map((setting: string) => {
|
|
|
|
|
return {
|
|
|
|
|
label: setting.replace(/-/g, " "),
|
|
|
|
|
slug: setting,
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
if (a.label == "general") return -1;
|
|
|
|
|
else if (b.label == "general") return 1;
|
2021-10-28 04:47:02 +00:00
|
|
|
if (a.label == "advanced") return 1;
|
|
|
|
|
else if (b.label == "advanced") return -1;
|
2021-10-18 07:47:55 +00:00
|
|
|
return a.label < b.label ? -1 : 1;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function LeftPane() {
|
|
|
|
|
const categories = useSettingsCategory();
|
|
|
|
|
const { category } = useParams() as any;
|
|
|
|
|
return (
|
|
|
|
|
<Wrapper>
|
|
|
|
|
<HeaderContainer>
|
|
|
|
|
<StyledHeader>Appsmith Admin</StyledHeader>
|
|
|
|
|
</HeaderContainer>
|
2021-12-16 14:17:16 +00:00
|
|
|
<CategoryList className="t--settings-category-list">
|
2021-10-18 07:47:55 +00:00
|
|
|
{categories.map((config) => (
|
|
|
|
|
<Category key={config.slug}>
|
|
|
|
|
<StyledLink
|
|
|
|
|
$active={category == config.slug}
|
2021-12-16 14:17:16 +00:00
|
|
|
className={`t--settings-category-${config.slug}`}
|
2021-10-18 07:47:55 +00:00
|
|
|
to={getAdminSettingsCategoryUrl(config.slug)}
|
|
|
|
|
>
|
|
|
|
|
{config.label}
|
|
|
|
|
</StyledLink>
|
|
|
|
|
</Category>
|
|
|
|
|
))}
|
|
|
|
|
</CategoryList>
|
|
|
|
|
</Wrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|