## Description Improving the homepage UI for better user experience Fixes [#30750](https://github.com/appsmithorg/appsmith/issues/30750) [#30747](https://github.com/appsmithorg/appsmith/issues/30747) [#30874](https://github.com/appsmithorg/appsmith/issues/30874) ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8938008387> > Commit: 7f1d28275b8d1d1e594e06b30c22228ac66135dd > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8938008387&attempt=2" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No
88 lines
2.6 KiB
TypeScript
88 lines
2.6 KiB
TypeScript
import React, { useEffect } from "react";
|
|
import { useRouteMatch } from "react-router-dom";
|
|
import { connect, useDispatch, useSelector } from "react-redux";
|
|
import { getCurrentUser } from "selectors/usersSelectors";
|
|
import styled from "styled-components";
|
|
import StyledHeader from "components/designSystems/appsmith/StyledHeader";
|
|
import type { AppState } from "@appsmith/reducers";
|
|
import type { User } from "constants/userConstants";
|
|
import { useIsMobileDevice } from "utils/hooks/useDeviceDetect";
|
|
import { getTemplateNotificationSeenAction } from "actions/templateActions";
|
|
import { shouldShowLicenseBanner } from "@appsmith/selectors/tenantSelectors";
|
|
import { Banner } from "@appsmith/utils/licenseHelpers";
|
|
import bootIntercom from "utils/bootIntercom";
|
|
import EntitySearchBar from "pages/common/SearchBar/EntitySearchBar";
|
|
|
|
const StyledPageHeader = styled(StyledHeader)<{
|
|
hideShadow?: boolean;
|
|
isMobile?: boolean;
|
|
showSeparator?: boolean;
|
|
isBannerVisible?: boolean;
|
|
}>`
|
|
justify-content: space-between;
|
|
background: var(--ads-v2-color-bg);
|
|
height: 48px;
|
|
color: var(--ads-v2-color-bg);
|
|
position: fixed;
|
|
top: 0;
|
|
z-index: var(--ads-v2-z-index-9);
|
|
border-bottom: 1px solid var(--ads-v2-color-border);
|
|
${({ isMobile }) =>
|
|
isMobile &&
|
|
`
|
|
padding: 0 12px;
|
|
padding-left: 10px;
|
|
`};
|
|
${({ isBannerVisible, isMobile }) =>
|
|
isBannerVisible ? (isMobile ? `top: 70px;` : `top: 40px;`) : ""};
|
|
`;
|
|
|
|
interface PageHeaderProps {
|
|
user?: User;
|
|
hideShadow?: boolean;
|
|
showSeparator?: boolean;
|
|
hideEditProfileLink?: boolean;
|
|
}
|
|
|
|
export function PageHeader(props: PageHeaderProps) {
|
|
const { user } = props;
|
|
const dispatch = useDispatch();
|
|
|
|
const isMobile = useIsMobileDevice();
|
|
|
|
useEffect(() => {
|
|
dispatch(getTemplateNotificationSeenAction());
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
bootIntercom(user);
|
|
}, [user?.email]);
|
|
|
|
const showBanner = useSelector(shouldShowLicenseBanner);
|
|
const isHomePage = useRouteMatch("/applications")?.isExact;
|
|
const isLicensePage = useRouteMatch("/license")?.isExact;
|
|
|
|
return (
|
|
<>
|
|
<Banner />
|
|
<StyledPageHeader
|
|
data-testid="t--appsmith-page-header"
|
|
hideShadow={props.hideShadow || false}
|
|
isBannerVisible={showBanner && (isHomePage || isLicensePage)}
|
|
isMobile={isMobile}
|
|
showSeparator={props.showSeparator || false}
|
|
>
|
|
<EntitySearchBar user={user} />
|
|
</StyledPageHeader>
|
|
</>
|
|
);
|
|
}
|
|
|
|
const mapStateToProps = (state: AppState) => ({
|
|
user: getCurrentUser(state),
|
|
hideShadow: state.ui.theme.hideHeaderShadow,
|
|
showSeparator: state.ui.theme.showHeaderSeparator,
|
|
});
|
|
|
|
export default connect(mapStateToProps)(PageHeader);
|