@pushwoosh/smart-components-kit 1.0.46 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useParams
|
|
2
|
+
import { useParams } from 'react-router-dom';
|
|
3
3
|
import { Link, Spinner } from '@pushwoosh/dumb-components';
|
|
4
4
|
import { Color, PlatformsIcons, PlatformsLabels, Tag } from '@pushwoosh/kit-constants';
|
|
5
5
|
import { Horizontal, useAsync, Vertical } from '@pushwoosh/kit-helpers';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { PlatformLogoIcon } from '@pushwoosh/kit-icons';
|
|
7
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
8
8
|
import { LinkRow, ClickActionSection } from './styles';
|
|
9
9
|
import { useSPAContext } from '../../../context';
|
|
10
10
|
import { getSafariUrl } from '../../helpers';
|
|
@@ -30,12 +30,12 @@ export const OpenActionsSummary = ({
|
|
|
30
30
|
}) : Promise.resolve(undefined), [rpcGateway, applicationCode]);
|
|
31
31
|
const hasCustomPlatformsDeeplink = Object.keys(platformsDeeplinkUrls).length > 0;
|
|
32
32
|
const safariUrl = getSafariUrl((applicationData === null || applicationData === void 0 || (_applicationData$valu = applicationData.value) === null || _applicationData$valu === void 0 ? void 0 : _applicationData$valu.application) || null, safariUrlArgs ?? '');
|
|
33
|
-
const renderInfoBlock = (device, action, url = null) => React.createElement(Vertical, null, React.createElement("span", null, "For", ' ', React.createElement("strong", null, device), ' ', "subscribers:", ' ', React.createElement("strong", null, action)), url && React.createElement(LinkRow, null, React.createElement(Link, {
|
|
33
|
+
const renderInfoBlock = (device, action, url = null, urlText) => React.createElement(Vertical, null, React.createElement("span", null, "For", ' ', React.createElement("strong", null, device), ' ', "subscribers:", ' ', React.createElement("strong", null, action)), url && React.createElement(LinkRow, null, React.createElement(Link, {
|
|
34
34
|
as: Tag.A,
|
|
35
35
|
rel: "noopener noreferrer",
|
|
36
36
|
target: "_blank",
|
|
37
37
|
href: url
|
|
38
|
-
}, url)));
|
|
38
|
+
}, urlText ?? url)));
|
|
39
39
|
const renderPlatformDeepLink = (platformKey, url, label = 'deep link') => {
|
|
40
40
|
const isEnumKey = typeof platformKey === 'number';
|
|
41
41
|
const icon = isEnumKey ? PlatformsIcons[platformKey] : null;
|
|
@@ -56,28 +56,19 @@ export const OpenActionsSummary = ({
|
|
|
56
56
|
"$uppercase": true
|
|
57
57
|
}, labelText, ' ', label)), React.createElement(LinkRow, null, url));
|
|
58
58
|
};
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"$alignItems": "center"
|
|
67
|
-
}, React.createElement(H4, null, "Show in-app banner:"), React.createElement(Text, null, richmedia.code), React.createElement(ReactLink, {
|
|
68
|
-
to: `/applications/${applicationCode}/rich-media/${richmedia.code}/edit`,
|
|
69
|
-
target: "_blank"
|
|
70
|
-
}, React.createElement(OpenIcon, {
|
|
71
|
-
color: Color.SOFT,
|
|
72
|
-
size: "small",
|
|
73
|
-
view: "lined"
|
|
74
|
-
})));
|
|
59
|
+
const getRichmediaLink = ({
|
|
60
|
+
url,
|
|
61
|
+
code,
|
|
62
|
+
createdType = 'BUILDER'
|
|
63
|
+
}) => {
|
|
64
|
+
if (code) {
|
|
65
|
+
return createdType === 'BUILDER' ? `/applications/${applicationCode}/rich-media/${code}/edit` : `/applications/${applicationCode}/richMedia/edit/${Date.now()}/${code}`;
|
|
75
66
|
}
|
|
76
|
-
return
|
|
67
|
+
return url;
|
|
77
68
|
};
|
|
78
69
|
return React.createElement(Vertical, {
|
|
79
70
|
"$gap": 8
|
|
80
|
-
}, openActions ? React.createElement(React.Fragment, null, hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link'), Object.entries(platformsDeeplinkUrls).map(([platformKey, url]) => renderPlatformDeepLink(+platformKey, url)), allPlatformsDeeplinkUrl && hasCustomPlatformsDeeplink && renderPlatformDeepLink('Other platforms', allPlatformsDeeplinkUrl), allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link', allPlatformsDeeplinkUrl), !allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'open home page in application'), webPageUrl && renderInfoBlock('web', 'open URL in browser', webPageUrl), webPageUrl && safariUrl && renderInfoBlock('Safari', 'open URL in Safari browser', safariUrl), !webPageUrl && renderInfoBlock('web', 'open home page in browser')
|
|
71
|
+
}, openActions ? React.createElement(React.Fragment, null, showRichmedia && renderInfoBlock('mobile', 'open in-app banner', getRichmediaLink(showRichmedia), showRichmedia.name || showRichmedia.code), !showRichmedia && hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link'), !showRichmedia && Object.entries(platformsDeeplinkUrls).map(([platformKey, url]) => renderPlatformDeepLink(+platformKey, url)), !showRichmedia && allPlatformsDeeplinkUrl && hasCustomPlatformsDeeplink && renderPlatformDeepLink('Other platforms', allPlatformsDeeplinkUrl), !showRichmedia && allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'follow the Deep link', allPlatformsDeeplinkUrl), !showRichmedia && !allPlatformsDeeplinkUrl && !hasCustomPlatformsDeeplink && renderInfoBlock('mobile', 'open home page in application'), webPageUrl && renderInfoBlock('web', 'open URL in browser', webPageUrl), webPageUrl && safariUrl && renderInfoBlock('Safari', 'open URL in Safari browser', safariUrl), !webPageUrl && renderInfoBlock('web', 'open home page in browser')) : React.createElement(Spinner, {
|
|
81
72
|
color: Color.MAIN,
|
|
82
73
|
size: "medium"
|
|
83
74
|
}));
|
package/OpenActions/types.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { type AllPlatforms } from '@pushwoosh/kit-constants';
|
|
2
|
+
import { type RichMedia_CreatedType } from '@pushwoosh/rpc-v2-http-api-data/rich_medias';
|
|
3
|
+
export type RichmediaOpenAction = {
|
|
4
|
+
url?: string;
|
|
5
|
+
code?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
createdType?: RichMedia_CreatedType;
|
|
8
|
+
};
|
|
2
9
|
export type ParsedOpenActions = {
|
|
3
10
|
platformsDeeplinkUrls: Partial<Record<AllPlatforms, string>>;
|
|
4
11
|
defaultDeeplinkUrl: string | null;
|
|
5
12
|
webPageUrl: string | null;
|
|
6
|
-
showRichmedia:
|
|
7
|
-
url?: string;
|
|
8
|
-
code?: string;
|
|
9
|
-
} | null;
|
|
13
|
+
showRichmedia: RichmediaOpenAction | null;
|
|
10
14
|
safariUrlArgs: string | null;
|
|
11
15
|
};
|
|
12
16
|
export type OpenActionsSummaryProps = {
|
package/package.json
CHANGED