-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: Revert "chore: Remove empty canvas prompts and improve widget editor header (#33993)" #34035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
rahulbarwal
wants to merge
1
commit into
release
from
revert/removal-of-canvas-empty-hints-due-to-faling-cypress-specs
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
app/client/src/pages/Editor/WidgetsEditor/components/EmptyCanvasPrompts.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| import React, { useEffect } from "react"; | ||
| import styled from "styled-components"; | ||
| import { Text, TextType } from "design-system-old"; | ||
| import { useDispatch, useSelector } from "react-redux"; | ||
| import { | ||
| selectURLSlugs, | ||
| showCanvasTopSectionSelector, | ||
| } from "selectors/editorSelectors"; | ||
| import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil"; | ||
| import history from "utils/history"; | ||
| import { generateTemplateFormURL } from "@appsmith/RouteBuilder"; | ||
| import { useParams } from "react-router"; | ||
| import type { ExplorerURLParams } from "@appsmith/pages/Editor/Explorer/helpers"; | ||
| import { showTemplatesModal as showTemplatesModalAction } from "actions/templateActions"; | ||
| import { | ||
| createMessage, | ||
| GENERATE_PAGE, | ||
| GENERATE_PAGE_DESCRIPTION, | ||
| TEMPLATE_CARD_DESCRIPTION, | ||
| TEMPLATE_CARD_TITLE, | ||
| } from "@appsmith/constants/messages"; | ||
| import { deleteCanvasCardsState } from "actions/editorActions"; | ||
| import { isAirgapped } from "@appsmith/utils/airgapHelpers"; | ||
| import { Icon } from "design-system"; | ||
| import { | ||
| LayoutSystemFeatures, | ||
| useLayoutSystemFeatures, | ||
| } from "layoutSystems/common/useLayoutSystemFeatures"; | ||
|
|
||
| const Wrapper = styled.div` | ||
| margin: ${(props) => | ||
| `${props.theme.spaces[7]}px ${props.theme.spaces[16]}px 0px ${props.theme.spaces[13]}px`}; | ||
| display: flex; | ||
| flex-direction: row; | ||
| gap: ${(props) => props.theme.spaces[7]}px; | ||
| `; | ||
|
|
||
| const Card = styled.div<{ centerAlign?: boolean }>` | ||
| padding: ${(props) => | ||
| `${props.theme.spaces[5]}px ${props.theme.spaces[9]}px`}; | ||
| border: solid 1px var(--ads-v2-color-border); | ||
| background: var(--ads-v2-color-bg); | ||
| flex: 1; | ||
| display: flex; | ||
| flex-direction: row; | ||
| align-items: center; | ||
| border-radius: var(--ads-v2-border-radius); | ||
| ${(props) => | ||
| props.centerAlign && | ||
| ` | ||
| justify-content: center; | ||
| `} | ||
| cursor: pointer; | ||
|
|
||
| svg { | ||
| height: 24px; | ||
| width: 24px; | ||
| } | ||
| &:hover { | ||
| background-color: var(--ads-v2-color-bg-subtle); | ||
| } | ||
| `; | ||
|
|
||
| const Content = styled.div` | ||
| display: flex; | ||
| flex-direction: column; | ||
| padding-left: ${(props) => props.theme.spaces[7]}px; | ||
| `; | ||
|
|
||
| interface routeId { | ||
| applicationSlug: string; | ||
| pageId: string; | ||
| pageSlug: string; | ||
| } | ||
|
|
||
| const goToGenPageForm = ({ pageId }: routeId): void => { | ||
| AnalyticsUtil.logEvent("GEN_CRUD_PAGE_ACTION_CARD_CLICK"); | ||
| history.push(generateTemplateFormURL({ pageId })); | ||
| }; | ||
|
|
||
| interface EmptyCanvasPromptsProps { | ||
| isPreview: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * OldName: CanvasTopSection | ||
| */ | ||
| /** | ||
| * This Component encompasses the prompts for empty canvas | ||
| * prompts like generate crud app or import from template | ||
| * @param props Object that contains | ||
| * @prop isPreview, boolean to indicate preview mode | ||
| * @returns | ||
| */ | ||
| function EmptyCanvasPrompts(props: EmptyCanvasPromptsProps) { | ||
| const dispatch = useDispatch(); | ||
| const showCanvasTopSection = useSelector(showCanvasTopSectionSelector); | ||
| const { isPreview } = props; | ||
| const { pageId } = useParams<ExplorerURLParams>(); | ||
| const { applicationSlug, pageSlug } = useSelector(selectURLSlugs); | ||
|
|
||
| const checkLayoutSystemFeatures = useLayoutSystemFeatures(); | ||
| const [enableForkingFromTemplates, enableGenerateCrud] = | ||
| checkLayoutSystemFeatures([ | ||
| LayoutSystemFeatures.ENABLE_FORKING_FROM_TEMPLATES, | ||
| LayoutSystemFeatures.ENABLE_GENERATE_CRUD_APP, | ||
| ]); | ||
|
|
||
| useEffect(() => { | ||
| if (!showCanvasTopSection && !isPreview) { | ||
| dispatch(deleteCanvasCardsState()); | ||
| } | ||
| }, [showCanvasTopSection, isPreview]); | ||
|
|
||
| if (!showCanvasTopSection || isPreview) return null; | ||
|
|
||
| const showTemplatesModal = () => { | ||
| dispatch(showTemplatesModalAction({ isOpenFromCanvas: false })); | ||
| AnalyticsUtil.logEvent("CANVAS_BLANK_PAGE_CTA_CLICK", { | ||
| item: "ADD_PAGE_FROM_TEMPLATE", | ||
| }); | ||
| }; | ||
|
|
||
| const onGeneratePageClick = () => { | ||
| goToGenPageForm({ applicationSlug, pageSlug, pageId }); | ||
| AnalyticsUtil.logEvent("CANVAS_BLANK_PAGE_CTA_CLICK", { | ||
| item: "GENERATE_PAGE", | ||
| }); | ||
| }; | ||
|
|
||
| const isAirgappedInstance = isAirgapped(); | ||
| const showCanvasPrompts = | ||
| (enableForkingFromTemplates && !isAirgappedInstance) || enableGenerateCrud; | ||
| return showCanvasPrompts ? ( | ||
| <Wrapper data-testid="canvas-ctas"> | ||
| {enableForkingFromTemplates && !isAirgappedInstance && ( | ||
| <Card data-testid="start-from-template" onClick={showTemplatesModal}> | ||
| <Icon name="layout-2-line" size="lg" /> | ||
| <Content> | ||
| <Text color={"var(--ads-v2-color-fg-emphasis)"} type={TextType.H5}> | ||
| {createMessage(TEMPLATE_CARD_TITLE)} | ||
| </Text> | ||
| <Text type={TextType.P3}> | ||
| {createMessage(TEMPLATE_CARD_DESCRIPTION)} | ||
| </Text> | ||
| </Content> | ||
| </Card> | ||
| )} | ||
| {enableGenerateCrud && ( | ||
| <Card | ||
| centerAlign={false} | ||
| data-testid="generate-app" | ||
| onClick={onGeneratePageClick} | ||
| > | ||
| <Icon name="database-2-line" size="lg" /> | ||
| <Content> | ||
| <Text color={"var(--ads-v2-color-fg-emphasis)"} type={TextType.H5}> | ||
| {createMessage(GENERATE_PAGE)} | ||
| </Text> | ||
| <Text type={TextType.P3}> | ||
| {createMessage(GENERATE_PAGE_DESCRIPTION)} | ||
| </Text> | ||
| </Content> | ||
| </Card> | ||
| )} | ||
| </Wrapper> | ||
| ) : null; | ||
| } | ||
|
|
||
| export default EmptyCanvasPrompts; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using consistent naming for constants related to similar functionalities.
This change ensures that the function names and return strings are more readable and maintain a consistent format across similar functionalities.
Also applies to: 1829-1831
Committable suggestion