PromucFlow_constructor/app/client/src/widgets/ConnectDataOverlay.tsx
Sangeeth Sivan 43940b7f2f
feat: JSON form widget one click binding integration (#25873)
## Description
- Adds one click binding support for JSON form widget.

#### PR fixes following issue(s)
Fixes #25561 
Fixes #26375 

#### 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

- New feature (non-breaking change which adds functionality)

## 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
- [x] Manual
- [x] Jest
- [x] Cypress

#### Test Plan
> [One click binding support on JSON Form (Test
plan)](https://github.com/appsmithorg/TestSmith/issues/2523)

#### 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
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] 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

---------

Co-authored-by: balajisoundar <balaji@appsmith.com>
2023-10-03 13:40:51 +05:30

123 lines
3.1 KiB
TypeScript

import { adaptiveSignpostingEnabled } from "@appsmith/selectors/featureFlagsSelectors";
import WalkthroughContext from "components/featureWalkthrough/walkthroughContext";
import { Colors } from "constants/Colors";
import { FEATURE_WALKTHROUGH_KEYS } from "constants/WalkthroughConstants";
import { Button } from "design-system";
import { SignpostingWalkthroughConfig } from "pages/Editor/FirstTimeUserOnboarding/Utils";
import React, { useContext, useEffect } from "react";
import { useSelector } from "react-redux";
import { actionsExistInCurrentPage } from "@appsmith/selectors/entitiesSelector";
import {
getIsFirstTimeUserOnboardingEnabled,
isWidgetActionConnectionPresent,
} from "selectors/onboardingSelectors";
import styled from "styled-components";
import { getFeatureWalkthroughShown } from "utils/storage";
const Wrapper = styled.div`
position: absolute;
z-index: 9;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: #ffffff61;
display: flex;
align-items: center;
justify-content: center;
`;
const Container = styled.div`
text-align: center;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
padding: 10px;
height: 100%;
justify-content: center;
backdrop-filter: blur(1px);
`;
const Header = styled.div`
font-weight: 600;
font-size: 16px;
line-height: 24px;
color: ${Colors.GREY_900};
margin-bottom: 12px;
`;
const ConnecData = styled(Button)`
margin-bottom: 16px;
`;
export function ConnectDataOverlay(props: {
onConnectData: () => void;
message: string;
btnText: string;
}) {
const {
isOpened: isWalkthroughOpened,
popFeature,
pushFeature,
} = useContext(WalkthroughContext) || {};
const signpostingEnabled = useSelector(getIsFirstTimeUserOnboardingEnabled);
const adaptiveSignposting = useSelector(adaptiveSignpostingEnabled);
const actionsExist = useSelector(actionsExistInCurrentPage);
const isConnectionPresent = useSelector(isWidgetActionConnectionPresent);
useEffect(() => {
if (
signpostingEnabled &&
adaptiveSignposting &&
!isConnectionPresent &&
actionsExist
) {
checkAndShowWalkthrough();
}
}, [
signpostingEnabled,
adaptiveSignposting,
isConnectionPresent,
actionsExist,
]);
const closeWalkthrough = () => {
if (popFeature && isWalkthroughOpened) {
popFeature();
}
};
const checkAndShowWalkthrough = async () => {
const isFeatureWalkthroughShown = await getFeatureWalkthroughShown(
FEATURE_WALKTHROUGH_KEYS.connect_data,
);
!isFeatureWalkthroughShown &&
pushFeature &&
pushFeature(SignpostingWalkthroughConfig.CONNECT_DATA, true);
};
const onClick = () => {
props.onConnectData();
closeWalkthrough();
};
return (
<Wrapper>
<Container>
<Header className="t--cypress-table-overlay-header">
{props.message}
</Header>
<ConnecData
className="t--cypress-table-overlay-connectdata"
id={"table-overlay-connectdata"}
onClick={onClick}
size="md"
>
{props.btnText}
</ConnecData>
</Container>
</Wrapper>
);
}