2023-08-30 08:31:16 +00:00
|
|
|
import { adaptiveSignpostingEnabled } from "@appsmith/selectors/featureFlagsSelectors";
|
|
|
|
|
import WalkthroughContext from "components/featureWalkthrough/walkthroughContext";
|
2023-06-01 17:26:05 +00:00
|
|
|
import { Colors } from "constants/Colors";
|
2023-08-30 08:31:16 +00:00
|
|
|
|
|
|
|
|
import { FEATURE_WALKTHROUGH_KEYS } from "constants/WalkthroughConstants";
|
2023-06-06 17:35:43 +00:00
|
|
|
import { Button } from "design-system";
|
2023-08-30 08:31:16 +00:00
|
|
|
import { SignpostingWalkthroughConfig } from "pages/Editor/FirstTimeUserOnboarding/Utils";
|
|
|
|
|
import React, { useContext, useEffect } from "react";
|
|
|
|
|
import { useSelector } from "react-redux";
|
2023-09-12 11:51:39 +00:00
|
|
|
import { actionsExistInCurrentPage } from "@appsmith/selectors/entitiesSelector";
|
2023-08-30 08:31:16 +00:00
|
|
|
import {
|
|
|
|
|
getIsFirstTimeUserOnboardingEnabled,
|
|
|
|
|
isWidgetActionConnectionPresent,
|
|
|
|
|
} from "selectors/onboardingSelectors";
|
2023-06-01 17:26:05 +00:00
|
|
|
import styled from "styled-components";
|
2023-08-30 08:31:16 +00:00
|
|
|
import { getFeatureWalkthroughShown } from "utils/storage";
|
2023-06-01 17:26:05 +00:00
|
|
|
|
|
|
|
|
const Wrapper = styled.div`
|
|
|
|
|
position: absolute;
|
|
|
|
|
z-index: 9;
|
2023-10-03 08:10:51 +00:00
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
2023-06-01 17:26:05 +00:00
|
|
|
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;
|
2023-10-03 08:10:51 +00:00
|
|
|
height: 100%;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
backdrop-filter: blur(1px);
|
2023-06-01 17:26:05 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const Header = styled.div`
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
line-height: 24px;
|
|
|
|
|
color: ${Colors.GREY_900};
|
2023-06-06 17:35:43 +00:00
|
|
|
margin-bottom: 12px;
|
2023-06-01 17:26:05 +00:00
|
|
|
`;
|
|
|
|
|
|
2023-06-06 17:35:43 +00:00
|
|
|
const ConnecData = styled(Button)`
|
|
|
|
|
margin-bottom: 16px;
|
2023-06-01 17:26:05 +00:00
|
|
|
`;
|
|
|
|
|
|
2023-10-03 08:10:51 +00:00
|
|
|
export function ConnectDataOverlay(props: {
|
|
|
|
|
onConnectData: () => void;
|
|
|
|
|
message: string;
|
|
|
|
|
btnText: string;
|
|
|
|
|
}) {
|
2023-08-30 08:31:16 +00:00
|
|
|
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();
|
|
|
|
|
};
|
|
|
|
|
|
2023-06-01 17:26:05 +00:00
|
|
|
return (
|
|
|
|
|
<Wrapper>
|
|
|
|
|
<Container>
|
|
|
|
|
<Header className="t--cypress-table-overlay-header">
|
2023-10-03 08:10:51 +00:00
|
|
|
{props.message}
|
2023-06-01 17:26:05 +00:00
|
|
|
</Header>
|
|
|
|
|
<ConnecData
|
|
|
|
|
className="t--cypress-table-overlay-connectdata"
|
2023-08-30 08:31:16 +00:00
|
|
|
id={"table-overlay-connectdata"}
|
|
|
|
|
onClick={onClick}
|
2023-06-06 17:35:43 +00:00
|
|
|
size="md"
|
2023-06-01 17:26:05 +00:00
|
|
|
>
|
2023-10-03 08:10:51 +00:00
|
|
|
{props.btnText}
|
2023-06-01 17:26:05 +00:00
|
|
|
</ConnecData>
|
|
|
|
|
</Container>
|
|
|
|
|
</Wrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|