PromucFlow_constructor/app/client/src/pages/common/PageHeader.tsx

88 lines
2.4 KiB
TypeScript
Raw Normal View History

import React from "react";
import { Link, useLocation } from "react-router-dom";
import { connect } from "react-redux";
import { getCurrentUser } from "selectors/usersSelectors";
import styled from "styled-components";
import StyledHeader from "components/designSystems/appsmith/StyledHeader";
2020-08-18 06:40:11 +00:00
import AppsmithLogo from "assets/images/appsmith_logo_white.png";
import { AppState } from "reducers";
import { User, ANONYMOUS_USERNAME } from "constants/userConstants";
import { AUTH_LOGIN_URL, APPLICATIONS_URL } from "constants/routes";
import Button from "components/editorComponents/Button";
import history from "utils/history";
2020-08-18 06:40:11 +00:00
import { Colors } from "constants/Colors";
import ProfileDropdown from "./ProfileDropdown";
2021-06-09 14:32:17 +00:00
import Bell from "notifications/Bell";
const StyledPageHeader = styled(StyledHeader)`
2020-08-18 06:40:11 +00:00
background: ${Colors.BALTIC_SEA};
height: 48px;
color: white;
flex-direction: row;
Homepage redesign with themes (#482) * Updating homepage body color * WIP: Fixing scrolls and adding anchors * Removing divider from bottom of the page. * Adding hover background color to app card * Changing edit and launch icons. * Fixing app name paddding in card. * Fixing workspaces overflow * Adding right padding to applications view * Adding share icon to share btn * Fixing Application card styles. * Fixing text decoration in button. * Adding new workspace button * Fixing new workspace and new app styles. * Adding icon sizes. * Fixing Org Name and Org settings menu. * Application menu working * Fixing overlay visibility on app card * Fixing settings page content width. * Fixing workspace icon * Changing app card colors. * Removing debugger * Adding app icon. * Fixing the spaces in application card * Adding storybook-static folder to gitignore. * Adding other storybook files. * Adding menu items for app * Removing cypress selector from text. * Menu width issue fixed * Default app icon color added * Removing hardcoded colors * Removing hardcoded colors. * Light Mode on! * Showing correct icon and color in menu * Update color working properly. * Updating appIcon * Editable text working. * Adding validator * Adding edit permissions to menu * Removing box shadow on app card. * Fixing context menu fill color * Fixing Menu hover issues. * Fixing menu open close hover issues. * Fixing settings pages * Changed Workspace to org. * Fix: State management in EditableText Component (#540) * Error state height is fixed as per design * savingState prop condition fixed * Fixing createnew. * Fixing saving state for application card. * Fixed application card editable text error. * Fixing issue caused during merge. * Fixing tests in create org. * Removing commented code. * Removing unwanted vars. * Fixing delete duplicate tests. * Latest color palette. * Fixing form and table widget. * Removing switcher from header * Removing unused files * Fixing app card context dropdown * Show overlay fix * Adding localStorage support to theme. * Making dark mode the default. Co-authored-by: Rohit Kumawat <rohit.kumawat@primathon.in>
2020-09-16 11:50:47 +00:00
position: fixed;
top: 0;
z-index: 10;
2020-08-18 06:40:11 +00:00
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.05);
`;
const HeaderSection = styled.div`
display: flex;
2020-08-18 06:40:11 +00:00
flex: 1;
align-items: center;
`;
const StyledDropDownContainer = styled.div``;
2020-08-18 06:40:11 +00:00
const AppsmithLogoImg = styled.img`
max-width: 110px;
`;
type PageHeaderProps = {
user?: User;
};
export function PageHeader(props: PageHeaderProps) {
const { user } = props;
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
let loginUrl = AUTH_LOGIN_URL;
if (queryParams.has("redirectUrl")) {
loginUrl += `?redirectUrl
=${queryParams.get("redirectUrl")}`;
}
return (
<StyledPageHeader>
2020-08-18 06:40:11 +00:00
<HeaderSection>
<Link className="t--appsmith-logo" to={APPLICATIONS_URL}>
<AppsmithLogoImg alt="Appsmith logo" src={AppsmithLogo} />
</Link>
2020-08-18 06:40:11 +00:00
</HeaderSection>
{user && (
2021-06-09 14:32:17 +00:00
<>
<Bell />
2021-06-09 14:32:17 +00:00
<StyledDropDownContainer>
{user.username === ANONYMOUS_USERNAME ? (
<Button
filled
intent={"primary"}
onClick={() => history.push(loginUrl)}
size="small"
text="Sign In"
/>
) : (
<ProfileDropdown name={user.name} userName={user.username} />
)}
</StyledDropDownContainer>
</>
)}
</StyledPageHeader>
);
}
const mapStateToProps = (state: AppState) => ({
user: getCurrentUser(state),
});
export default connect(mapStateToProps)(PageHeader);