2021-10-20 07:38:17 +00:00
|
|
|
import React, { useState } from "react";
|
2021-03-04 09:37:02 +00:00
|
|
|
import PageWrapper from "pages/common/PageWrapper";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { TabComponent, TabProp } from "components/ads/Tabs";
|
|
|
|
|
import Text, { TextType } from "components/ads/Text";
|
2021-09-09 15:10:22 +00:00
|
|
|
import { Icon } from "@blueprintjs/core";
|
2021-10-20 07:38:17 +00:00
|
|
|
// import { Link } from "react-router-dom";
|
2021-03-04 09:37:02 +00:00
|
|
|
import General from "./General";
|
|
|
|
|
import { Colors } from "constants/Colors";
|
2021-09-17 10:48:38 +00:00
|
|
|
import GitConfig from "./GitConfig";
|
2021-10-20 07:38:17 +00:00
|
|
|
import { useLocation } from "react-router";
|
|
|
|
|
import { GIT_PROFILE_ROUTE } from "constants/routes";
|
2022-04-07 17:57:32 +00:00
|
|
|
import { useSelector } from "react-redux";
|
|
|
|
|
import { selectFeatureFlags } from "selectors/usersSelectors";
|
2021-03-04 09:37:02 +00:00
|
|
|
|
|
|
|
|
const ProfileWrapper = styled.div`
|
|
|
|
|
width: ${(props) => props.theme.pageContentWidth}px;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
`;
|
|
|
|
|
|
2021-10-20 07:38:17 +00:00
|
|
|
const LinkToApplications = styled.div`
|
2021-03-04 09:37:02 +00:00
|
|
|
margin-top: 30px;
|
|
|
|
|
margin-bottom: 35px;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
width: auto;
|
|
|
|
|
&:hover {
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
}
|
|
|
|
|
svg {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2021-04-28 10:28:39 +00:00
|
|
|
function UserProfile() {
|
2021-10-20 07:38:17 +00:00
|
|
|
const location = useLocation();
|
2022-04-07 17:57:32 +00:00
|
|
|
const featureFlags = useSelector(selectFeatureFlags);
|
2021-10-20 07:38:17 +00:00
|
|
|
|
|
|
|
|
let initialTabIndex = 0;
|
2021-03-04 09:37:02 +00:00
|
|
|
const tabs: TabProp[] = [
|
|
|
|
|
{
|
|
|
|
|
key: "general",
|
|
|
|
|
title: "General",
|
|
|
|
|
panelComponent: <General />,
|
|
|
|
|
icon: "general",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2022-04-07 17:57:32 +00:00
|
|
|
if (featureFlags.GIT) {
|
2021-09-17 10:48:38 +00:00
|
|
|
tabs.push({
|
|
|
|
|
key: "gitConfig",
|
|
|
|
|
title: "Git user config",
|
|
|
|
|
panelComponent: <GitConfig />,
|
|
|
|
|
icon: "git-branch",
|
|
|
|
|
});
|
2021-10-20 07:38:17 +00:00
|
|
|
if (location.pathname === GIT_PROFILE_ROUTE) {
|
|
|
|
|
initialTabIndex = 1;
|
|
|
|
|
}
|
2021-09-17 10:48:38 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-20 07:38:17 +00:00
|
|
|
const [selectedTabIndex, setSelectedTabIndex] = useState(initialTabIndex);
|
|
|
|
|
|
2021-03-04 09:37:02 +00:00
|
|
|
return (
|
|
|
|
|
<PageWrapper displayName={"Profile"}>
|
|
|
|
|
<ProfileWrapper>
|
2021-10-20 07:38:17 +00:00
|
|
|
<LinkToApplications className="t--back" onClick={() => history.back()}>
|
2021-09-09 15:10:22 +00:00
|
|
|
<Icon color={Colors.SILVER_CHALICE} icon="chevron-left" />
|
2021-03-04 09:37:02 +00:00
|
|
|
<Text type={TextType.H1}>Profile</Text>
|
|
|
|
|
</LinkToApplications>
|
2021-10-20 07:38:17 +00:00
|
|
|
<TabComponent
|
|
|
|
|
onSelect={setSelectedTabIndex}
|
|
|
|
|
selectedIndex={selectedTabIndex}
|
|
|
|
|
tabs={tabs}
|
|
|
|
|
/>
|
2021-03-04 09:37:02 +00:00
|
|
|
</ProfileWrapper>
|
|
|
|
|
</PageWrapper>
|
|
|
|
|
);
|
2021-04-28 10:28:39 +00:00
|
|
|
}
|
2021-03-04 09:37:02 +00:00
|
|
|
|
|
|
|
|
export default UserProfile;
|