PromucFlow_constructor/app/client/src/pages/common/SearchBar/HomepageHeaderAction.tsx
Ankit Srivastava a45dcfa61f
feat: Homepage experience v2 changes (#29282)
> Pull Request Template
>
> Use this template to quickly create a well written pull request.
Delete all quotes before creating the pull request.
>
## Description
> Add a TL;DR when description is extra long (helps content team)
>
> Please include a summary of the changes and which issue has been
fixed. Please also include relevant motivation
> and context. List any dependencies that are required for this change
>
> Links to Notion, Figma or any other documents that might be relevant
to the PR
>
>
#### PR fixes following issue(s)
Fixes # (issue number)
> if no issue exists, please create an issue and ask the maintainers
about this first
>
>
#### Media
> A video or a GIF is preferred. when using Loom, don’t embed because it
looks like it’s a GIF. instead, just link to the video
>
>
#### Type of change
> Please delete options that are not relevant.
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- Chore (housekeeping or task changes that don't impact user perception)
- This change requires a documentation update
>
>
>
## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [ ] Manual
- [ ] JUnit
- [ ] Jest
- [ ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
    - Added new workspace search functionality in the search bar.
    - Introduced a help button for user assistance.
- Implemented new UI components for workspace selection and management.
    - Enhanced application card with edit permission checks.
- Integrated workspace actions for creating and fetching workspaces
directly from the UI.

- **Improvements**
    - Improved workspace and application fetching logic.
    - Enhanced Global Search with updated import paths and logic.
- Refined the layout and styling of the applications page and sub-header
components.
- Optimized workspace-related sagas and reducers for better performance
and maintainability.

- **Bug Fixes**
- Fixed tooltip functionality in "Reconnect Datasources" within
templates.
    - Corrected test logic for forking templates and applications.
    - Updated Cypress test commands for consistency and reliability.
- Addressed issues with application URL test cases and workspace import
logic.

- **Documentation**
- Updated messages and constants related to workspace and application UI
elements for clearer user communication.

- **Chores**
- Cleaned up unused code and simplified selectors across various
components and tests.
- Refactored application and workspace selectors for improved code
organization.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Dipyaman Biswas <dipyaman@appsmith.com>
Co-authored-by: Abhijeet <abhi.nagarnaik@gmail.com>
Co-authored-by: Nidhi <nidhi@appsmith.com>
Co-authored-by: Goutham Pratapa <goutham@appsmith.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
Co-authored-by: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com>
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Nayan <nayan@appsmith.com>
Co-authored-by: Rishabh Rathod <rishabh.rathod@appsmith.com>
2024-01-25 19:11:48 +05:30

184 lines
5.9 KiB
TypeScript

import { getAppsmithConfigs } from "@appsmith/configs";
import {
ADMIN_SETTINGS,
APPSMITH_DISPLAY_VERSION,
CHAT_WITH_US,
DOCUMENTATION,
HELP,
WHATS_NEW,
createMessage,
} from "@appsmith/constants/messages";
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
import { getCurrentApplicationIdForCreateNewApp } from "@appsmith/selectors/applicationSelectors";
import { getTenantPermissions } from "@appsmith/selectors/tenantSelectors";
import {
getAdminSettingsPath,
getShowAdminSettings,
} from "@appsmith/utils/BusinessFeatures/adminSettingsHelpers";
import { isAirgapped } from "@appsmith/utils/airgapHelpers";
import { ShowUpgradeMenuItem } from "@appsmith/utils/licenseHelpers";
import type { User } from "constants/userConstants";
import {
Button,
Menu,
MenuContent,
MenuItem,
MenuSeparator,
MenuTrigger,
Tooltip,
} from "design-system";
import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useRouteMatch } from "react-router";
import { howMuchTimeBeforeText } from "utils/helpers";
import { useFeatureFlag } from "utils/hooks/useFeatureFlag";
import {
DropdownOnSelectActions,
getOnSelectAction,
} from "../CustomizedDropdown/dropdownHelpers";
import { IntercomConsent } from "pages/Editor/HelpButton";
import { DOCS_BASE_URL } from "constants/ThirdPartyConstants";
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
import styled from "styled-components";
const { cloudHosting, intercomAppID } = getAppsmithConfigs();
export const VersionData = styled.div`
display: flex;
flex-direction: column;
color: var(--ads-v2-color-fg-muted);
font-size: 8px;
position: relative;
padding: 6px 12px 12px;
gap: 4px;
`;
const HomepageHeaderAction = ({
setIsProductUpdatesModalOpen,
user,
}: {
user: User;
setIsProductUpdatesModalOpen: (val: boolean) => void;
}) => {
const dispatch = useDispatch();
const isFeatureEnabled = useFeatureFlag(FEATURE_FLAG.license_gac_enabled);
const tenantPermissions = useSelector(getTenantPermissions);
const isCreateNewAppFlow = useSelector(
getCurrentApplicationIdForCreateNewApp,
);
const isHomePage = useRouteMatch("/applications")?.isExact;
const isAirgappedInstance = isAirgapped();
const { appVersion } = getAppsmithConfigs();
const howMuchTimeBefore = howMuchTimeBeforeText(appVersion.releaseDate);
const [showIntercomConsent, setShowIntercomConsent] = useState(false);
if (!isHomePage || !!isCreateNewAppFlow) return null;
return (
<div className="flex items-center">
<ShowUpgradeMenuItem />
{getShowAdminSettings(isFeatureEnabled, user) && (
<Tooltip content={createMessage(ADMIN_SETTINGS)} placement="bottom">
<Button
className="admin-settings-menu-option"
isIconButton
kind="tertiary"
onClick={() => {
getOnSelectAction(DropdownOnSelectActions.REDIRECT, {
path: getAdminSettingsPath(
isFeatureEnabled,
user?.isSuperUser,
tenantPermissions,
),
});
}}
size="md"
startIcon="settings-control"
/>
</Tooltip>
)}
{!isAirgappedInstance && (
<Menu
onOpenChange={(open) => {
if (open) {
setShowIntercomConsent(false);
dispatch({
type: ReduxActionTypes.FETCH_RELEASES,
});
}
}}
>
<Tooltip content={createMessage(HELP)} placement="bottom">
<MenuTrigger>
<Button
className="t--help-menu-option"
isIconButton
kind="tertiary"
onClick={() => {}}
size="md"
startIcon="question-line"
/>
</MenuTrigger>
</Tooltip>
<MenuContent align="end" width="172px">
{showIntercomConsent ? (
<IntercomConsent showIntercomConsent={setShowIntercomConsent} />
) : (
<>
<MenuItem
className="t--documentation-button"
onClick={() => {
window.open(DOCS_BASE_URL, "_blank");
}}
startIcon="book-line"
>
{createMessage(DOCUMENTATION)}
</MenuItem>
{intercomAppID && window.Intercom && !isAirgapped() && (
<MenuItem
onSelect={(e) => {
if (user?.isIntercomConsentGiven || cloudHosting) {
window.Intercom("show");
} else {
e?.preventDefault();
setShowIntercomConsent(true);
}
}}
startIcon="chat-help"
>
{createMessage(CHAT_WITH_US)}
</MenuItem>
)}
<MenuSeparator className="mb-1" />
<MenuItem
className="t--product-updates-btn"
data-testid="t--product-updates-btn"
onClick={() => {
setIsProductUpdatesModalOpen(true);
}}
startIcon="gift-line"
>
{createMessage(WHATS_NEW)}
</MenuItem>
<VersionData>
<div>
{createMessage(
APPSMITH_DISPLAY_VERSION,
appVersion.edition,
appVersion.id,
)}
</div>
{howMuchTimeBefore !== "" && (
<div>Released {howMuchTimeBefore} ago</div>
)}
</VersionData>
</>
)}
</MenuContent>
</Menu>
)}
</div>
);
};
export default HomepageHeaderAction;