2023-04-20 12:25:32 +00:00
|
|
|
import React from "react";
|
2023-04-26 07:18:16 +00:00
|
|
|
import { useSelector } from "react-redux";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { Text, Link, Button } from "design-system";
|
2023-04-26 07:18:16 +00:00
|
|
|
import { PRICING_PAGE_URL } from "constants/ThirdPartyConstants";
|
2023-04-20 12:25:32 +00:00
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
IN_APP_EMBED_SETTING,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2023-05-19 18:37:06 +00:00
|
|
|
import {
|
|
|
|
|
isPermitted,
|
|
|
|
|
PERMISSION_TYPE,
|
|
|
|
|
} from "@appsmith/utils/permissionHelpers";
|
2023-04-26 07:18:16 +00:00
|
|
|
import { getAppsmithConfigs } from "@appsmith/configs";
|
|
|
|
|
import { getInstanceId } from "@appsmith/selectors/tenantSelectors";
|
2023-05-19 18:37:06 +00:00
|
|
|
import styled from "styled-components";
|
2023-04-20 12:25:32 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const StyledLink = styled(Link)`
|
|
|
|
|
text-decoration: underline !important;
|
|
|
|
|
display: inline;
|
2023-04-20 12:25:32 +00:00
|
|
|
`;
|
|
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
function PrivateEmbeddingContent(props: {
|
|
|
|
|
userAppPermissions: any[];
|
|
|
|
|
changeTab?: () => void;
|
|
|
|
|
isAppSettings?: boolean;
|
|
|
|
|
}) {
|
|
|
|
|
const { changeTab, isAppSettings = false } = props;
|
2023-04-26 07:18:16 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const canMakeAppPublic = isPermitted(
|
|
|
|
|
props.userAppPermissions,
|
|
|
|
|
PERMISSION_TYPE.MAKE_PUBLIC_APPLICATION,
|
|
|
|
|
);
|
2023-04-26 07:18:16 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
if (isAppSettings)
|
|
|
|
|
return <AppSettingsContent canMakeAppPublic={canMakeAppPublic} />;
|
2023-04-20 12:25:32 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
return (
|
|
|
|
|
<SnippetTabContent
|
|
|
|
|
canMakeAppPublic={canMakeAppPublic}
|
|
|
|
|
changeTab={changeTab}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-04-20 12:25:32 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
export default PrivateEmbeddingContent;
|
2023-04-26 07:18:16 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
function EmbeddedLink() {
|
|
|
|
|
const appsmithConfigs = getAppsmithConfigs();
|
|
|
|
|
const instanceId = useSelector(getInstanceId);
|
2023-04-20 12:25:32 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
return (
|
|
|
|
|
<Text kind="action-m">
|
|
|
|
|
{createMessage(IN_APP_EMBED_SETTING.upgradeContent)}
|
|
|
|
|
<StyledLink
|
|
|
|
|
onClick={() => {
|
|
|
|
|
window.open(
|
|
|
|
|
PRICING_PAGE_URL(
|
|
|
|
|
appsmithConfigs.pricingUrl,
|
|
|
|
|
appsmithConfigs.cloudHosting ? "Cloud" : "CE",
|
|
|
|
|
instanceId,
|
|
|
|
|
),
|
|
|
|
|
"_blank",
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
rel="noreferrer"
|
|
|
|
|
to="#"
|
|
|
|
|
>
|
|
|
|
|
{createMessage(IN_APP_EMBED_SETTING.appsmithBusinessEdition)}
|
|
|
|
|
</StyledLink>
|
|
|
|
|
</Text>
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-04-20 12:25:32 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
function AppSettingsContent({
|
|
|
|
|
canMakeAppPublic,
|
|
|
|
|
}: {
|
2023-04-20 12:25:32 +00:00
|
|
|
canMakeAppPublic: boolean;
|
|
|
|
|
}) {
|
2023-05-19 18:37:06 +00:00
|
|
|
return (
|
|
|
|
|
<div className="px-4" data-testid="t--upgrade-content">
|
|
|
|
|
<Text className="pt-3 pb-3" kind="heading-xs" renderAs="p">
|
|
|
|
|
{createMessage(IN_APP_EMBED_SETTING.embed)}
|
|
|
|
|
</Text>
|
|
|
|
|
<div className="flex flex-col gap-1">
|
|
|
|
|
<Text kind="action-m" renderAs="p">
|
|
|
|
|
{canMakeAppPublic
|
|
|
|
|
? createMessage(IN_APP_EMBED_SETTING.secondaryHeadingForAppSettings)
|
|
|
|
|
: createMessage(IN_APP_EMBED_SETTING.secondaryHeading)}
|
|
|
|
|
</Text>
|
2023-04-20 12:25:32 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
<EmbeddedLink />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SnippetTabContent({
|
|
|
|
|
canMakeAppPublic,
|
|
|
|
|
changeTab,
|
|
|
|
|
}: {
|
|
|
|
|
canMakeAppPublic: boolean;
|
|
|
|
|
changeTab?: () => void;
|
|
|
|
|
}) {
|
2023-04-20 12:25:32 +00:00
|
|
|
return (
|
2023-05-19 18:37:06 +00:00
|
|
|
<div
|
|
|
|
|
className="flex flex-col gap-1 items-start"
|
|
|
|
|
data-testid="t--upgrade-content"
|
|
|
|
|
>
|
|
|
|
|
<Text color="var(--ads-v2-color-fg-emphasis)" kind="heading-s">
|
|
|
|
|
{canMakeAppPublic
|
|
|
|
|
? createMessage(IN_APP_EMBED_SETTING.upgradeHeadingForInviteModal)
|
|
|
|
|
: createMessage(IN_APP_EMBED_SETTING.upgradeHeading)}
|
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
|
|
<EmbeddedLink />
|
|
|
|
|
|
|
|
|
|
{canMakeAppPublic && (
|
|
|
|
|
<Button
|
|
|
|
|
className="mt-2"
|
|
|
|
|
data-testid="t--share-settings-btn"
|
|
|
|
|
onClick={changeTab}
|
|
|
|
|
size="md"
|
2023-04-20 12:25:32 +00:00
|
|
|
>
|
2023-05-19 18:37:06 +00:00
|
|
|
Share settings
|
|
|
|
|
</Button>
|
2023-04-26 07:18:16 +00:00
|
|
|
)}
|
2023-05-19 18:37:06 +00:00
|
|
|
</div>
|
2023-04-20 12:25:32 +00:00
|
|
|
);
|
|
|
|
|
}
|