-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added premium tags datasources for knowing users request to ad…
…d new integrations (#38110)
- Loading branch information
1 parent
1ade47d
commit e22dbd1
Showing
14 changed files
with
481 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,21 @@ | ||
import { getAssetUrl } from "ee/utils/airgapHelpers"; | ||
import { ASSETS_CDN_URL } from "./ThirdPartyConstants"; | ||
|
||
interface PremiumIntegration { | ||
name: string; | ||
icon: string; | ||
} | ||
|
||
export const PREMIUM_INTEGRATIONS: PremiumIntegration[] = [ | ||
{ | ||
name: "Zendesk", | ||
icon: getAssetUrl(`${ASSETS_CDN_URL}/zendesk-icon.png`), | ||
}, | ||
{ | ||
name: "Salesforce", | ||
icon: getAssetUrl(`${ASSETS_CDN_URL}/salesforce-icon.png`), | ||
}, | ||
]; | ||
|
||
export const PREMIUM_INTEGRATION_CONTACT_FORM = | ||
"PREMIUM_INTEGRATION_CONTACT_FORM"; |
This file contains 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 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 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
175 changes: 175 additions & 0 deletions
175
app/client/src/pages/Editor/IntegrationEditor/PremiumDatasources/ContactForm.tsx
This file contains 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,175 @@ | ||
import { Button, Flex, ModalHeader, Text, toast } from "@appsmith/ads"; | ||
import { createMessage, PREMIUM_DATASOURCES } from "ee/constants/messages"; | ||
import type { AppState } from "ee/reducers"; | ||
import React, { useCallback } from "react"; | ||
import { connect, useSelector } from "react-redux"; | ||
import { | ||
Field, | ||
formValueSelector, | ||
getFormSyncErrors, | ||
reduxForm, | ||
type FormErrors, | ||
type InjectedFormProps, | ||
} from "redux-form"; | ||
import { getCurrentUser } from "selectors/usersSelectors"; | ||
import styled from "styled-components"; | ||
import { isEmail } from "utils/formhelpers"; | ||
import ReduxFormTextField from "components/utils/ReduxFormTextField"; | ||
import { PRICING_PAGE_URL } from "constants/ThirdPartyConstants"; | ||
import { getAppsmithConfigs } from "ee/configs"; | ||
import { getInstanceId, isFreePlan } from "ee/selectors/tenantSelectors"; | ||
import { pricingPageUrlSource } from "ee/utils/licenseHelpers"; | ||
import { RampFeature, RampSection } from "utils/ProductRamps/RampsControlList"; | ||
import { | ||
getContactFormModalDescription, | ||
getContactFormModalTitle, | ||
getContactFormSubmitButtonText, | ||
handleLearnMoreClick, | ||
handleSubmitEvent, | ||
shouldLearnMoreButtonBeVisible, | ||
} from "utils/PremiumDatasourcesHelpers"; | ||
import { PREMIUM_INTEGRATION_CONTACT_FORM } from "constants/PremiumDatasourcesConstants"; | ||
|
||
const FormWrapper = styled.form` | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--ads-spaces-7); | ||
`; | ||
|
||
const PremiumDatasourceContactForm = ( | ||
props: PremiumDatasourceContactFormProps, | ||
) => { | ||
const instanceId = useSelector(getInstanceId); | ||
const appsmithConfigs = getAppsmithConfigs(); | ||
const isFreePlanInstance = useSelector(isFreePlan); | ||
|
||
const redirectPricingURL = PRICING_PAGE_URL( | ||
appsmithConfigs.pricingUrl, | ||
pricingPageUrlSource, | ||
instanceId, | ||
RampFeature.PremiumDatasources, | ||
RampSection.PremiumDatasourcesContactModal, | ||
); | ||
|
||
const onSubmit = () => { | ||
submitEvent(); | ||
toast.show(createMessage(PREMIUM_DATASOURCES.SUCCESS_TOAST_MESSAGE), { | ||
kind: "success", | ||
}); | ||
props.closeModal(); | ||
}; | ||
|
||
const onClickLearnMore = useCallback(() => { | ||
handleLearnMoreClick( | ||
props.integrationName, | ||
props.email || "", | ||
redirectPricingURL, | ||
); | ||
}, [redirectPricingURL, props.email, props.integrationName]); | ||
|
||
const submitEvent = useCallback(() => { | ||
handleSubmitEvent( | ||
props.integrationName, | ||
props.email || "", | ||
!isFreePlanInstance, | ||
); | ||
}, [props.email, props.integrationName, isFreePlanInstance]); | ||
|
||
return ( | ||
<> | ||
<ModalHeader> | ||
{getContactFormModalTitle(props.integrationName, !isFreePlanInstance)} | ||
</ModalHeader> | ||
<FormWrapper onSubmit={props.handleSubmit(onSubmit)}> | ||
<Text renderAs="p"> | ||
{getContactFormModalDescription( | ||
props.email || "", | ||
!isFreePlanInstance, | ||
)} | ||
</Text> | ||
<Field | ||
component={ReduxFormTextField} | ||
description={createMessage( | ||
PREMIUM_DATASOURCES.FORM_EMAIL.DESCRIPTION, | ||
)} | ||
label={createMessage(PREMIUM_DATASOURCES.FORM_EMAIL.LABEL)} | ||
name={PREMIUM_DATASOURCES.FORM_EMAIL.NAME} | ||
size="md" | ||
type="email" | ||
/> | ||
<Flex gap="spaces-7" justifyContent="flex-end" marginTop="spaces-3"> | ||
{shouldLearnMoreButtonBeVisible(!isFreePlanInstance) && ( | ||
<Button | ||
aria-label="Learn more" | ||
kind="secondary" | ||
onClick={onClickLearnMore} | ||
size="md" | ||
> | ||
{createMessage(PREMIUM_DATASOURCES.LEARN_MORE)} | ||
</Button> | ||
)} | ||
<Button isDisabled={props.invalid} size="md" type="submit"> | ||
{getContactFormSubmitButtonText( | ||
props.email || "", | ||
!isFreePlanInstance, | ||
)} | ||
</Button> | ||
</Flex> | ||
</FormWrapper> | ||
</> | ||
); | ||
}; | ||
|
||
const selector = formValueSelector(PREMIUM_INTEGRATION_CONTACT_FORM); | ||
|
||
interface PremiumDatasourceContactFormValues { | ||
email?: string; | ||
} | ||
|
||
type PremiumDatasourceContactFormProps = PremiumDatasourceContactFormValues & { | ||
formSyncErrors?: FormErrors<string, string>; | ||
closeModal: () => void; | ||
integrationName: string; | ||
} & InjectedFormProps< | ||
PremiumDatasourceContactFormValues, | ||
{ | ||
formSyncErrors?: FormErrors<string, string>; | ||
closeModal: () => void; | ||
integrationName: string; | ||
} | ||
>; | ||
|
||
const validate = (values: PremiumDatasourceContactFormValues) => { | ||
const errors: Partial<PremiumDatasourceContactFormValues> = {}; | ||
|
||
if (!values.email || !isEmail(values.email)) { | ||
errors.email = createMessage(PREMIUM_DATASOURCES.FORM_EMAIL.ERROR); | ||
} | ||
|
||
return errors; | ||
}; | ||
|
||
export default connect((state: AppState) => { | ||
const currentUser = getCurrentUser(state); | ||
|
||
return { | ||
email: selector(state, "email"), | ||
initialValues: { | ||
email: currentUser?.email, | ||
}, | ||
formSyncErrors: getFormSyncErrors(PREMIUM_INTEGRATION_CONTACT_FORM)(state), | ||
}; | ||
}, null)( | ||
reduxForm< | ||
PremiumDatasourceContactFormValues, | ||
{ | ||
formSyncErrors?: FormErrors<string, string>; | ||
closeModal: () => void; | ||
integrationName: string; | ||
} | ||
>({ | ||
validate, | ||
form: PREMIUM_INTEGRATION_CONTACT_FORM, | ||
enableReinitialize: true, | ||
})(PremiumDatasourceContactForm), | ||
); |
Oops, something went wrong.