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";
|
2022-02-11 18:08:46 +00:00
|
|
|
import AdminConfig from "./config";
|
|
|
|
|
import { Category } from "@appsmith/pages/AdminSettings/config/types";
|
2021-10-18 07:47:55 +00:00
|
|
|
|
|
|
|
|
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`
|
2022-02-11 18:08:46 +00:00
|
|
|
font-size: 14px;
|
|
|
|
|
height: 20px;
|
|
|
|
|
line-height: 17px;
|
|
|
|
|
letter-spacing: -0.24px;
|
|
|
|
|
text-transform: uppercase;
|
2021-10-28 04:47:02 +00:00
|
|
|
margin: 40px 16px 16px;
|
|
|
|
|
color: ${Colors.MASALA};
|
2021-10-18 07:47:55 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const CategoryList = styled.ul`
|
|
|
|
|
margin: 0;
|
2022-02-11 18:08:46 +00:00
|
|
|
padding: 0 0 0 16px;
|
2021-10-18 07:47:55 +00:00
|
|
|
list-style-type: none;
|
|
|
|
|
`;
|
|
|
|
|
|
2022-02-11 18:08:46 +00:00
|
|
|
const CategoryItem = styled.li``;
|
2021-10-18 07:47:55 +00:00
|
|
|
|
|
|
|
|
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() {
|
2022-02-11 18:08:46 +00:00
|
|
|
return Array.from(AdminConfig.categories);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Categories({
|
|
|
|
|
categories,
|
|
|
|
|
currentCategory,
|
|
|
|
|
currentSubCategory,
|
|
|
|
|
parentCategory,
|
|
|
|
|
showSubCategory,
|
|
|
|
|
}: {
|
|
|
|
|
categories?: Category[];
|
|
|
|
|
parentCategory?: Category;
|
|
|
|
|
currentCategory: string;
|
|
|
|
|
currentSubCategory?: string;
|
|
|
|
|
showSubCategory?: boolean;
|
|
|
|
|
}) {
|
|
|
|
|
return (
|
|
|
|
|
<CategoryList className="t--settings-category-list">
|
|
|
|
|
{categories?.map((config) => (
|
|
|
|
|
<CategoryItem key={config.slug}>
|
|
|
|
|
<StyledLink
|
|
|
|
|
$active={
|
|
|
|
|
!!currentSubCategory && showSubCategory
|
|
|
|
|
? currentSubCategory == config.slug
|
|
|
|
|
: currentCategory == config.slug
|
|
|
|
|
}
|
|
|
|
|
className={`t--settings-category-${config.slug}`}
|
|
|
|
|
to={
|
|
|
|
|
!parentCategory
|
|
|
|
|
? getAdminSettingsCategoryUrl(config.slug)
|
|
|
|
|
: getAdminSettingsCategoryUrl(parentCategory.slug, config.slug)
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{config.title}
|
|
|
|
|
</StyledLink>
|
|
|
|
|
{showSubCategory && (
|
|
|
|
|
<Categories
|
|
|
|
|
categories={config.children}
|
|
|
|
|
currentCategory={currentCategory}
|
|
|
|
|
currentSubCategory={currentSubCategory}
|
|
|
|
|
parentCategory={config}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</CategoryItem>
|
|
|
|
|
))}
|
|
|
|
|
</CategoryList>
|
|
|
|
|
);
|
2021-10-18 07:47:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function LeftPane() {
|
|
|
|
|
const categories = useSettingsCategory();
|
2022-02-11 18:08:46 +00:00
|
|
|
const { category, subCategory } = useParams() as any;
|
2021-10-18 07:47:55 +00:00
|
|
|
return (
|
|
|
|
|
<Wrapper>
|
|
|
|
|
<HeaderContainer>
|
|
|
|
|
<StyledHeader>Appsmith Admin</StyledHeader>
|
|
|
|
|
</HeaderContainer>
|
2022-02-11 18:08:46 +00:00
|
|
|
<Categories
|
|
|
|
|
categories={categories}
|
|
|
|
|
currentCategory={category}
|
|
|
|
|
currentSubCategory={subCategory}
|
|
|
|
|
/>
|
2021-10-18 07:47:55 +00:00
|
|
|
</Wrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|