@pushwoosh/dumb-components 1.1.36 → 1.1.38
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.
- package/EnhancedInput/EnhancedInput.d.ts +5 -3
- package/EnhancedInput/EnhancedInput.js +6 -5
- package/FrequencyCapping/FrequencyCappingEdit.d.ts +1 -1
- package/FrequencyCapping/FrequencyCappingEdit.js +6 -4
- package/FrequencyCapping/FrequencyCappingReadonly.d.ts +1 -1
- package/FrequencyCapping/FrequencyCappingReadonly.js +5 -5
- package/FrequencyCapping/components/Condition/index.d.ts +3 -2
- package/FrequencyCapping/components/Condition/index.js +7 -4
- package/FrequencyCapping/components/Condition/styles.d.ts +3 -1
- package/FrequencyCapping/components/Condition/styles.js +3 -1
- package/FrequencyCapping/components/Description/index.d.ts +1 -0
- package/FrequencyCapping/components/Description/index.js +14 -7
- package/FrequencyCapping/constants.d.ts +5 -0
- package/FrequencyCapping/constants.js +11 -0
- package/FrequencyCapping/helpers/getCappingOption.d.ts +0 -4
- package/FrequencyCapping/helpers/getCappingOption.js +1 -11
- package/FrequencyCapping/helpers/getReadonlyCappingHelpers.d.ts +1 -2
- package/FrequencyCapping/helpers/getReadonlyCappingHelpers.js +12 -42
- package/FrequencyCapping/types.d.ts +2 -0
- package/SendRate/SendRateEdit.js +1 -2
- package/SendRate/SendRateReadonly.d.ts +1 -1
- package/SendRate/SendRateReadonly.js +2 -3
- package/SendRate/components/Condition/index.d.ts +3 -2
- package/SendRate/components/Condition/index.js +7 -4
- package/SendRate/components/Condition/styles.d.ts +3 -1
- package/SendRate/components/Condition/styles.js +3 -1
- package/SendRate/components/Description/index.js +8 -4
- package/SendRate/constants.d.ts +2 -0
- package/SendRate/constants.js +10 -0
- package/SendRate/helpers/getReadonlySendRateHelpers.d.ts +1 -2
- package/SendRate/helpers/getReadonlySendRateHelpers.js +9 -40
- package/package.json +1 -1
- package/SendRate/helpers/getSendRateOptions.d.ts +0 -2
- package/SendRate/helpers/getSendRateOptions.js +0 -10
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const EnhancedInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & import("../native/Input").NativeInputProps & {
|
|
3
|
+
$icon?: React.ReactNode;
|
|
4
|
+
$onClear?: () => void;
|
|
5
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import { CloseIcon } from '@pushwoosh/kit-icons';
|
|
3
3
|
import { Wrapper } from './styles';
|
|
4
4
|
import { NativeInput } from '../native';
|
|
5
|
-
export const EnhancedInput = ({
|
|
5
|
+
export const EnhancedInput = forwardRef(({
|
|
6
6
|
$icon,
|
|
7
7
|
$onClear,
|
|
8
8
|
...props
|
|
9
|
-
}) => {
|
|
9
|
+
}, ref) => {
|
|
10
10
|
return React.createElement(Wrapper, {
|
|
11
11
|
"$hasIcon": !!$icon,
|
|
12
12
|
"$hasClear": !!$onClear,
|
|
13
13
|
"$hasError": !!props.$isErrored
|
|
14
14
|
}, $icon, React.createElement(NativeInput, {
|
|
15
|
-
...props
|
|
15
|
+
...props,
|
|
16
|
+
ref: ref
|
|
16
17
|
}), $onClear && React.createElement(CloseIcon, {
|
|
17
18
|
size: "small",
|
|
18
19
|
onClick: $onClear
|
|
19
20
|
}));
|
|
20
|
-
};
|
|
21
|
+
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type CappingBase, type FrequencyCappingEditProps } from './types';
|
|
3
|
-
export declare function FrequencyCappingEdit<T extends CappingBase>({ capping, globalCapping, onChange, applicationCode, editGlobalClicked, }: FrequencyCappingEditProps<T>): React.JSX.Element;
|
|
3
|
+
export declare function FrequencyCappingEdit<T extends CappingBase>({ capping, globalCapping, onChange, applicationCode, editGlobalClicked, isInJourney, }: FrequencyCappingEditProps<T>): React.JSX.Element;
|
|
@@ -4,18 +4,20 @@ import { Vertical } from '@pushwoosh/kit-helpers';
|
|
|
4
4
|
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
5
5
|
import { Description } from './components/Description';
|
|
6
6
|
import { EditCappingSettings } from './components/Settings';
|
|
7
|
-
import { getCappingOption
|
|
7
|
+
import { getCappingOption } from './helpers/getCappingOption';
|
|
8
8
|
import { CappingTypes } from './types';
|
|
9
9
|
import { FieldBox } from '../FieldBox';
|
|
10
10
|
import { Link } from '../Link';
|
|
11
11
|
import { Select } from '../Select';
|
|
12
|
+
import { cappingOptions } from './constants';
|
|
12
13
|
import { Container, LinkWrapper } from './styles';
|
|
13
14
|
export function FrequencyCappingEdit({
|
|
14
15
|
capping,
|
|
15
16
|
globalCapping,
|
|
16
17
|
onChange,
|
|
17
18
|
applicationCode,
|
|
18
|
-
editGlobalClicked
|
|
19
|
+
editGlobalClicked,
|
|
20
|
+
isInJourney = false
|
|
19
21
|
}) {
|
|
20
22
|
const {
|
|
21
23
|
enabled,
|
|
@@ -26,7 +28,6 @@ export function FrequencyCappingEdit({
|
|
|
26
28
|
const cappingOption = getCappingOption(enabled, ignoreGlobalCapping);
|
|
27
29
|
const isGlobalCappingDisabled = globalCapping.count === 0 && globalCapping.days === 0;
|
|
28
30
|
const globalCappingLinkText = isGlobalCappingDisabled ? 'Set up' : 'Settings';
|
|
29
|
-
const cappingOptions = getCappingOptions(isGlobalCappingDisabled);
|
|
30
31
|
const onChangeFrequencyCapping = React.useCallback(value => {
|
|
31
32
|
if (value === CappingTypes.IGNORE) {
|
|
32
33
|
onChange({
|
|
@@ -75,7 +76,8 @@ export function FrequencyCappingEdit({
|
|
|
75
76
|
})), React.createElement(Description, {
|
|
76
77
|
cappingOption: cappingOption,
|
|
77
78
|
messages: globalCapping.count,
|
|
78
|
-
days: globalCapping.days
|
|
79
|
+
days: globalCapping.days,
|
|
80
|
+
isInJourney: isInJourney
|
|
79
81
|
}, cappingOption === CappingTypes.GLOBAL && React.createElement(Link, {
|
|
80
82
|
href: `/applications/${applicationCode}/message-delivery-settings?tab=capping`,
|
|
81
83
|
title: globalCappingLinkText,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type CappingBase, type FrequencyCappingReadonlyProps } from './types';
|
|
3
|
-
export declare function FrequencyCappingReadonly<T extends CappingBase>({ capping, globalCapping, applicationCode, editGlobalClicked, }: FrequencyCappingReadonlyProps<T>): React.JSX.Element;
|
|
3
|
+
export declare function FrequencyCappingReadonly<T extends CappingBase>({ capping, globalCapping, applicationCode, editGlobalClicked, isInJourney, }: FrequencyCappingReadonlyProps<T>): React.JSX.Element;
|
|
@@ -3,26 +3,26 @@ import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
|
3
3
|
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
4
4
|
import { Link } from '../Link';
|
|
5
5
|
import { getCappingOption } from './helpers/getCappingOption';
|
|
6
|
-
import {
|
|
6
|
+
import { getReadonlyCappingLabel } from './helpers/getReadonlyCappingHelpers';
|
|
7
7
|
import { CappingTypes } from './types';
|
|
8
8
|
export function FrequencyCappingReadonly({
|
|
9
9
|
capping,
|
|
10
10
|
globalCapping,
|
|
11
11
|
applicationCode,
|
|
12
|
-
editGlobalClicked
|
|
12
|
+
editGlobalClicked,
|
|
13
|
+
isInJourney = false
|
|
13
14
|
}) {
|
|
14
15
|
const cappingOption = getCappingOption(capping === null || capping === void 0 ? void 0 : capping.enabled, capping === null || capping === void 0 ? void 0 : capping.ignoreGlobalCapping);
|
|
15
16
|
const isGlobalCappingDisabled = globalCapping.count === 0 && globalCapping.days === 0;
|
|
16
17
|
const globalCappingLinkText = isGlobalCappingDisabled ? 'Set up' : 'Settings';
|
|
17
|
-
const label = getReadonlyCappingLabel(cappingOption, isGlobalCappingDisabled, capping, globalCapping);
|
|
18
|
-
const checkIcon = getReadonlyCappingIcon(cappingOption, isGlobalCappingDisabled);
|
|
18
|
+
const label = getReadonlyCappingLabel(cappingOption, isGlobalCappingDisabled, capping, globalCapping, isInJourney);
|
|
19
19
|
return React.createElement(Vertical, {
|
|
20
20
|
"$gap": 24
|
|
21
21
|
}, React.createElement(Horizontal, {
|
|
22
22
|
"$gap": 8,
|
|
23
23
|
"$justifyContent": "start",
|
|
24
24
|
"$alignItems": "center"
|
|
25
|
-
},
|
|
25
|
+
}, label, cappingOption === CappingTypes.GLOBAL && React.createElement(Link, {
|
|
26
26
|
href: `/applications/${applicationCode}/message-delivery-settings?tab=capping`,
|
|
27
27
|
title: globalCappingLinkText,
|
|
28
28
|
target: "_blank",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
type
|
|
2
|
+
type ChipFrequencyCappingProps = {
|
|
3
3
|
messages: number;
|
|
4
4
|
days: number;
|
|
5
5
|
tooltip?: string;
|
|
6
|
+
$inText?: boolean;
|
|
6
7
|
};
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function ChipFrequencyCapping({ messages, days, tooltip, $inText }: ChipFrequencyCappingProps): React.JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -4,12 +4,15 @@ import { HelpRoundIcon } from '@pushwoosh/kit-icons';
|
|
|
4
4
|
import { ChipWithinTextContainer } from './styles';
|
|
5
5
|
import { Chip } from '../../../Chip';
|
|
6
6
|
import { Tooltip } from '../../../Tooltip';
|
|
7
|
-
export function
|
|
7
|
+
export function ChipFrequencyCapping({
|
|
8
8
|
messages,
|
|
9
9
|
days,
|
|
10
|
-
tooltip
|
|
10
|
+
tooltip,
|
|
11
|
+
$inText = false
|
|
11
12
|
}) {
|
|
12
|
-
return React.createElement(ChipWithinTextContainer,
|
|
13
|
+
return React.createElement(ChipWithinTextContainer, {
|
|
14
|
+
"$inText": $inText
|
|
15
|
+
}, tooltip ? React.createElement(Tooltip, {
|
|
13
16
|
content: tooltip,
|
|
14
17
|
position: "top-middle"
|
|
15
18
|
}, React.createElement(Chip, {
|
|
@@ -25,5 +28,5 @@ export function Condition({
|
|
|
25
28
|
"$variant": "primary",
|
|
26
29
|
"$readOnly": true,
|
|
27
30
|
as: "span"
|
|
28
|
-
}, `${messages} messages per ${days} ${days > 1 ? 'days' : 'day'}`));
|
|
31
|
+
}, messages === 0 && days === 0 ? 'unlimited' : `${messages} messages per ${days} ${days > 1 ? 'days' : 'day'}`));
|
|
29
32
|
}
|
|
@@ -2,4 +2,6 @@ import styled from 'styled-components';
|
|
|
2
2
|
export const ChipWithinTextContainer = styled.span.withConfig({
|
|
3
3
|
displayName: "ChipWithinTextContainer",
|
|
4
4
|
componentId: "sc-pqahx9-0"
|
|
5
|
-
})(["
|
|
5
|
+
})(["", ";span{line-height:1;}"], ({
|
|
6
|
+
$inText
|
|
7
|
+
}) => $inText && 'margin: 0 8px');
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
3
3
|
import { CappingTypes } from '../../types';
|
|
4
|
-
import {
|
|
4
|
+
import { ChipFrequencyCapping } from '../Condition';
|
|
5
5
|
export function Description(props) {
|
|
6
6
|
const {
|
|
7
7
|
cappingOption,
|
|
8
8
|
messages,
|
|
9
9
|
days,
|
|
10
|
-
children
|
|
10
|
+
children,
|
|
11
|
+
isInJourney
|
|
11
12
|
} = props;
|
|
12
13
|
if (cappingOption === CappingTypes.GLOBAL) {
|
|
13
14
|
if (messages === 0 && days === 0) {
|
|
14
|
-
return React.createElement(Paragraph, null, "
|
|
15
|
+
return React.createElement(Paragraph, null, "This message will use an", React.createElement(ChipFrequencyCapping, {
|
|
16
|
+
days: 0,
|
|
17
|
+
messages: 0,
|
|
18
|
+
"$inText": true
|
|
19
|
+
}), "global frequency capping because limit isn\u2019t set.", ' ', children);
|
|
15
20
|
}
|
|
16
|
-
return React.createElement(Paragraph, null, "Under the current setup, If the user receives more than", React.createElement(
|
|
21
|
+
return React.createElement(Paragraph, null, "Under the current setup, If the user receives more than", React.createElement(ChipFrequencyCapping, {
|
|
17
22
|
messages: messages,
|
|
18
|
-
days: days
|
|
19
|
-
|
|
23
|
+
days: days,
|
|
24
|
+
"$inText": true
|
|
25
|
+
}), `, this message will not be delivered${isInJourney ? ', and the user will proceed to the next step' : ''}. `, children);
|
|
20
26
|
}
|
|
21
27
|
if (cappingOption === CappingTypes.CUSTOM) {
|
|
22
|
-
return React.createElement(Paragraph, null,
|
|
28
|
+
return React.createElement(Paragraph, null, `Instead of Global frequency capping, the limit of sent messages you set will be used. If the
|
|
29
|
+
subscriber exceeds the limit of received messages, they will not receive this message${isInJourney ? ', and will proceed to the next step' : ''}. `, children);
|
|
23
30
|
}
|
|
24
31
|
if (cappingOption === CappingTypes.IGNORE) {
|
|
25
32
|
return React.createElement(Paragraph, null, "The user will receive this message regardless, even if they have exceeded the set message limits for the channel. Use with caution to avoid sending too many messages.", ' ', children);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CappingTypes } from './types';
|
|
2
|
+
export const cappingOptions = [{
|
|
3
|
+
value: CappingTypes.GLOBAL,
|
|
4
|
+
label: 'Use global frequency capping settings'
|
|
5
|
+
}, {
|
|
6
|
+
value: CappingTypes.IGNORE,
|
|
7
|
+
label: 'Send messages without global frequency capping'
|
|
8
|
+
}, {
|
|
9
|
+
value: CappingTypes.CUSTOM,
|
|
10
|
+
label: 'Use custom frequency capping'
|
|
11
|
+
}];
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { CappingTypes } from '../types';
|
|
2
2
|
export declare const getCappingOption: (enabled: boolean, ignoreGlobalCapping: boolean) => CappingTypes;
|
|
3
|
-
export declare const getCappingOptions: (isGlobalCappingDisabled: boolean) => {
|
|
4
|
-
value: CappingTypes;
|
|
5
|
-
label: string;
|
|
6
|
-
}[];
|
|
@@ -7,14 +7,4 @@ export const getCappingOption = (enabled, ignoreGlobalCapping) => {
|
|
|
7
7
|
return CappingTypes.IGNORE;
|
|
8
8
|
}
|
|
9
9
|
return CappingTypes.GLOBAL;
|
|
10
|
-
};
|
|
11
|
-
export const getCappingOptions = isGlobalCappingDisabled => [{
|
|
12
|
-
value: CappingTypes.GLOBAL,
|
|
13
|
-
label: `Use global frequency capping settings${isGlobalCappingDisabled ? ' (currently inactive)' : ''}`
|
|
14
|
-
}, {
|
|
15
|
-
value: CappingTypes.IGNORE,
|
|
16
|
-
label: 'Send messages without global frequency capping'
|
|
17
|
-
}, {
|
|
18
|
-
value: CappingTypes.CUSTOM,
|
|
19
|
-
label: 'Use custom frequency capping'
|
|
20
|
-
}];
|
|
10
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type CappingBase, CappingTypes } from '../types';
|
|
3
|
-
export declare function getReadonlyCappingIcon(cappingOption: CappingTypes, isGlobalCappingDisabled: boolean): React.JSX.Element;
|
|
4
3
|
export declare function getReadonlyCappingLabel<T extends CappingBase>(cappingOption: CappingTypes, isGlobalCappingDisabled: boolean, capping: T, globalCapping: {
|
|
5
4
|
count: number;
|
|
6
5
|
days: number;
|
|
7
|
-
}): React.JSX.Element;
|
|
6
|
+
}, isInJourney: boolean): React.JSX.Element;
|
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Color } from '@pushwoosh/kit-constants';
|
|
3
2
|
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
-
import {
|
|
5
|
-
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
3
|
+
import { HelpRoundIcon } from '@pushwoosh/kit-icons';
|
|
6
4
|
import { Tooltip } from '../../Tooltip';
|
|
7
|
-
import {
|
|
5
|
+
import { ChipFrequencyCapping } from '../components/Condition';
|
|
8
6
|
import { IconWrapper } from '../styles';
|
|
9
7
|
import { CappingTypes } from '../types';
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
return React.createElement(CloseRoundIcon, {
|
|
13
|
-
size: "small",
|
|
14
|
-
view: "filled",
|
|
15
|
-
color: Color.LOCKED
|
|
16
|
-
});
|
|
17
|
-
;
|
|
18
|
-
}
|
|
19
|
-
return React.createElement(CheckRoundIcon, {
|
|
20
|
-
size: "small",
|
|
21
|
-
view: "filled",
|
|
22
|
-
type: "fill",
|
|
23
|
-
color: Color.BRIGHT
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
export function getReadonlyCappingLabel(cappingOption, isGlobalCappingDisabled, capping, globalCapping) {
|
|
27
|
-
const tooltip = getReadonlyTooltip(cappingOption, isGlobalCappingDisabled);
|
|
8
|
+
export function getReadonlyCappingLabel(cappingOption, isGlobalCappingDisabled, capping, globalCapping, isInJourney) {
|
|
9
|
+
const tooltip = getReadonlyTooltip(cappingOption, isInJourney);
|
|
28
10
|
if (cappingOption === CappingTypes.CUSTOM) {
|
|
29
|
-
return React.createElement(
|
|
11
|
+
return React.createElement(React.Fragment, null, "Custom frequency capping for this message:", React.createElement(ChipFrequencyCapping, {
|
|
30
12
|
messages: capping.messages,
|
|
31
13
|
days: capping.days,
|
|
32
14
|
tooltip: tooltip
|
|
@@ -47,33 +29,21 @@ export function getReadonlyCappingLabel(cappingOption, isGlobalCappingDisabled,
|
|
|
47
29
|
view: "lined"
|
|
48
30
|
}))));
|
|
49
31
|
}
|
|
50
|
-
return isGlobalCappingDisabled ? React.createElement(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, "Global frequency capping is not active for this channel", React.createElement(Tooltip, {
|
|
55
|
-
content: tooltip,
|
|
56
|
-
position: "top-middle"
|
|
57
|
-
}, React.createElement(IconWrapper, {
|
|
58
|
-
"$padding": "4px 0"
|
|
59
|
-
}, React.createElement(HelpRoundIcon, {
|
|
60
|
-
size: "small",
|
|
61
|
-
view: "lined"
|
|
62
|
-
})))) : React.createElement(Paragraph, null, "Global frequency capping:", React.createElement(Condition, {
|
|
32
|
+
return isGlobalCappingDisabled ? React.createElement(React.Fragment, null, "Global frequency capping:", React.createElement(ChipFrequencyCapping, {
|
|
33
|
+
days: 0,
|
|
34
|
+
messages: 0
|
|
35
|
+
}), "because limit isn\u2019t set") : React.createElement(React.Fragment, null, "Global frequency capping:", React.createElement(ChipFrequencyCapping, {
|
|
63
36
|
messages: globalCapping.count,
|
|
64
37
|
days: globalCapping.days,
|
|
65
38
|
tooltip: tooltip
|
|
66
39
|
}));
|
|
67
40
|
}
|
|
68
|
-
function getReadonlyTooltip(cappingOption,
|
|
41
|
+
function getReadonlyTooltip(cappingOption, isInJourney) {
|
|
69
42
|
if (cappingOption === CappingTypes.CUSTOM) {
|
|
70
|
-
return 'If the subscriber exceeds the limit of received messages, they will not receive this message and will proceed to the next step';
|
|
43
|
+
return isInJourney ? 'If the subscriber exceeds the limit of received messages, they will not receive this message and will proceed to the next step' : 'If the subscriber exceeds the limit of received messages, they will not receive this message';
|
|
71
44
|
}
|
|
72
45
|
if (cappingOption === CappingTypes.IGNORE) {
|
|
73
46
|
return 'The user will receive this message regardless, even if they have exceeded the set limits for the channel';
|
|
74
47
|
}
|
|
75
|
-
|
|
76
|
-
return 'Messages will be sent without global limits because capping is currently not active for this channel';
|
|
77
|
-
}
|
|
78
|
-
return 'If the subscriber exceeds the limit of received messages, they will not receive this message and will proceed to the next step';
|
|
48
|
+
return isInJourney ? 'If the subscriber exceeds the limit of received messages, they will not receive this message and will proceed to the next step' : 'If the subscriber exceeds the limit of received messages, they will not receive this message';
|
|
79
49
|
}
|
|
@@ -22,6 +22,7 @@ export type FrequencyCappingEditProps<T extends CappingBase> = {
|
|
|
22
22
|
onChange: (newCappingState: T) => void;
|
|
23
23
|
editGlobalClicked: () => void;
|
|
24
24
|
applicationCode: string;
|
|
25
|
+
isInJourney?: boolean;
|
|
25
26
|
};
|
|
26
27
|
export type FrequencyCappingReadonlyProps<T extends CappingBase> = {
|
|
27
28
|
capping: T;
|
|
@@ -31,4 +32,5 @@ export type FrequencyCappingReadonlyProps<T extends CappingBase> = {
|
|
|
31
32
|
};
|
|
32
33
|
applicationCode: string;
|
|
33
34
|
editGlobalClicked: () => void;
|
|
35
|
+
isInJourney?: boolean;
|
|
34
36
|
};
|
package/SendRate/SendRateEdit.js
CHANGED
|
@@ -4,10 +4,10 @@ import { Vertical } from '@pushwoosh/kit-helpers';
|
|
|
4
4
|
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
5
5
|
import { Description } from './components/Description';
|
|
6
6
|
import { EditSendRateSettings } from './components/Settings';
|
|
7
|
-
import { getSendRateOptions } from './helpers/getSendRateOptions';
|
|
8
7
|
import { FieldBox } from '../FieldBox';
|
|
9
8
|
import { Link } from '../Link';
|
|
10
9
|
import { Select } from '../Select';
|
|
10
|
+
import { sendRateOptions } from './constants';
|
|
11
11
|
import { Container, LinkWrapper } from './styles';
|
|
12
12
|
export function SendRateEdit({
|
|
13
13
|
sendRate,
|
|
@@ -24,7 +24,6 @@ export function SendRateEdit({
|
|
|
24
24
|
} = sendRate;
|
|
25
25
|
const isGlobalSendRateDisabled = globalSendRate.count === 0 && globalSendRate.count === 0;
|
|
26
26
|
const globalSendRateLinkText = isGlobalSendRateDisabled ? 'Set up' : 'Settings';
|
|
27
|
-
const sendRateOptions = getSendRateOptions(isGlobalSendRateDisabled);
|
|
28
27
|
const onChangeSendRate = React.useCallback(value => {
|
|
29
28
|
if (value === 'CUSTOM') {
|
|
30
29
|
onChange({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type SendRateReadonlyProps, type SendRateBase } from './types';
|
|
3
|
-
export declare function SendRateReadonly<T extends SendRateBase>({ sendRate, globalSendRate, applicationCode, editGlobalClicked }: SendRateReadonlyProps<T>): React.JSX.Element;
|
|
3
|
+
export declare function SendRateReadonly<T extends SendRateBase>({ sendRate, globalSendRate, applicationCode, editGlobalClicked, }: SendRateReadonlyProps<T>): React.JSX.Element;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
3
3
|
import { OpenIcon } from '@pushwoosh/kit-icons';
|
|
4
4
|
import { Link } from '../Link';
|
|
5
|
-
import {
|
|
5
|
+
import { getReadonlySendRateLabel } from './helpers/getReadonlySendRateHelpers';
|
|
6
6
|
export function SendRateReadonly({
|
|
7
7
|
sendRate,
|
|
8
8
|
globalSendRate,
|
|
@@ -15,14 +15,13 @@ export function SendRateReadonly({
|
|
|
15
15
|
const isGlobalSendRateDisabled = globalSendRate.count === 0 && globalSendRate.seconds === 0;
|
|
16
16
|
const globalSendRateLinkText = isGlobalSendRateDisabled ? 'Set up' : 'Settings';
|
|
17
17
|
const label = getReadonlySendRateLabel(sendRate, isGlobalSendRateDisabled, globalSendRate);
|
|
18
|
-
const checkIcon = getReadonlySendRateIcon(policy, isGlobalSendRateDisabled);
|
|
19
18
|
return React.createElement(Vertical, {
|
|
20
19
|
"$gap": 24
|
|
21
20
|
}, React.createElement(Horizontal, {
|
|
22
21
|
"$gap": 8,
|
|
23
22
|
"$justifyContent": "start",
|
|
24
23
|
"$alignItems": "center"
|
|
25
|
-
},
|
|
24
|
+
}, label, policy === 'GLOBAL' && React.createElement(Link, {
|
|
26
25
|
href: `/applications/${applicationCode}/message-delivery-settings?tab=sendRate`,
|
|
27
26
|
title: globalSendRateLinkText,
|
|
28
27
|
target: "_blank",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
type
|
|
2
|
+
type ChipSendRateProps = {
|
|
3
3
|
messages: number;
|
|
4
4
|
tooltip?: string;
|
|
5
|
+
$inText?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare function
|
|
7
|
+
export declare function ChipSendRate({ messages, $inText }: ChipSendRateProps): React.JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChipWithinTextContainer } from './styles';
|
|
3
3
|
import { Chip } from '../../../Chip';
|
|
4
|
-
export function
|
|
5
|
-
messages
|
|
4
|
+
export function ChipSendRate({
|
|
5
|
+
messages,
|
|
6
|
+
$inText = false
|
|
6
7
|
}) {
|
|
7
|
-
return React.createElement(ChipWithinTextContainer,
|
|
8
|
+
return React.createElement(ChipWithinTextContainer, {
|
|
9
|
+
"$inText": $inText
|
|
10
|
+
}, React.createElement(Chip, {
|
|
8
11
|
"$variant": "primary",
|
|
9
12
|
"$readOnly": true,
|
|
10
13
|
as: "span"
|
|
11
|
-
}, `${messages} messages per 1 sec`));
|
|
14
|
+
}, messages === 0 ? 'unlimited' : `${messages} messages per 1 sec`));
|
|
12
15
|
}
|
|
@@ -2,4 +2,6 @@ import styled from 'styled-components';
|
|
|
2
2
|
export const ChipWithinTextContainer = styled.span.withConfig({
|
|
3
3
|
displayName: "ChipWithinTextContainer",
|
|
4
4
|
componentId: "sc-1emj3bf-0"
|
|
5
|
-
})(["
|
|
5
|
+
})(["", ";span{line-height:1;}"], ({
|
|
6
|
+
$inText
|
|
7
|
+
}) => $inText && 'margin: 0 8px');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
3
|
-
import {
|
|
3
|
+
import { ChipSendRate } from '../Condition';
|
|
4
4
|
export function Description(props) {
|
|
5
5
|
const {
|
|
6
6
|
sendRateOption,
|
|
@@ -10,10 +10,14 @@ export function Description(props) {
|
|
|
10
10
|
} = props;
|
|
11
11
|
if (sendRateOption === 'GLOBAL') {
|
|
12
12
|
if (messages === 0 && seconds === 0) {
|
|
13
|
-
return React.createElement(Paragraph, null, "
|
|
13
|
+
return React.createElement(Paragraph, null, "This message will use an", React.createElement(ChipSendRate, {
|
|
14
|
+
messages: 0,
|
|
15
|
+
"$inText": true
|
|
16
|
+
}), "global send rate because limit isn\u2019t set.", ' ', children);
|
|
14
17
|
}
|
|
15
|
-
return React.createElement(Paragraph, null, "This message will use the Global send rate limit of", React.createElement(
|
|
16
|
-
messages: messages
|
|
18
|
+
return React.createElement(Paragraph, null, "This message will use the Global send rate limit of", React.createElement(ChipSendRate, {
|
|
19
|
+
messages: messages,
|
|
20
|
+
"$inText": true
|
|
17
21
|
}), "to help reduce backend load.", ' ', children);
|
|
18
22
|
}
|
|
19
23
|
if (sendRateOption === 'CUSTOM') {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type SendRateBase
|
|
3
|
-
export declare function getReadonlySendRateIcon(sendRateOption: SendRatePolicy, isGlobalSendRateDisabled: boolean): React.JSX.Element;
|
|
2
|
+
import { type SendRateBase } from '../types';
|
|
4
3
|
export declare function getReadonlySendRateLabel<T extends SendRateBase>(sendRateOption: T, isGlobalSendRateDisabled: boolean, globalSendRate: {
|
|
5
4
|
count: number;
|
|
6
5
|
seconds: number;
|
|
@@ -1,35 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Color } from '@pushwoosh/kit-constants';
|
|
3
2
|
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
-
import {
|
|
5
|
-
import { Paragraph } from '@pushwoosh/kit-typography';
|
|
3
|
+
import { HelpRoundIcon } from '@pushwoosh/kit-icons';
|
|
6
4
|
import { Tooltip } from '../../Tooltip';
|
|
7
|
-
import {
|
|
5
|
+
import { ChipSendRate } from '../components/Condition';
|
|
8
6
|
import { IconWrapper } from '../styles';
|
|
9
|
-
export function getReadonlySendRateIcon(sendRateOption, isGlobalSendRateDisabled) {
|
|
10
|
-
if (sendRateOption === 'GLOBAL' && isGlobalSendRateDisabled) {
|
|
11
|
-
return React.createElement(CloseRoundIcon, {
|
|
12
|
-
size: "small",
|
|
13
|
-
view: "filled",
|
|
14
|
-
color: Color.LOCKED
|
|
15
|
-
});
|
|
16
|
-
;
|
|
17
|
-
}
|
|
18
|
-
return React.createElement(CheckRoundIcon, {
|
|
19
|
-
size: "small",
|
|
20
|
-
view: "filled",
|
|
21
|
-
type: "fill",
|
|
22
|
-
color: Color.BRIGHT
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
7
|
export function getReadonlySendRateLabel(sendRateOption, isGlobalSendRateDisabled, globalSendRate) {
|
|
26
8
|
const {
|
|
27
9
|
policy,
|
|
28
10
|
sendRate
|
|
29
11
|
} = sendRateOption;
|
|
30
|
-
const tooltip = getReadonlyTooltip(policy
|
|
12
|
+
const tooltip = getReadonlyTooltip(policy);
|
|
31
13
|
if (policy === 'CUSTOM') {
|
|
32
|
-
return React.createElement(
|
|
14
|
+
return React.createElement(React.Fragment, null, "Custom send rate for this message:", React.createElement(ChipSendRate, {
|
|
33
15
|
messages: sendRate
|
|
34
16
|
}));
|
|
35
17
|
}
|
|
@@ -38,7 +20,7 @@ export function getReadonlySendRateLabel(sendRateOption, isGlobalSendRateDisable
|
|
|
38
20
|
"$alignItems": "center",
|
|
39
21
|
"$gap": 4,
|
|
40
22
|
"$justifyContent": "start"
|
|
41
|
-
}, "Send messages without send rate", React.createElement(Tooltip, {
|
|
23
|
+
}, "Send messages without global send rate", React.createElement(Tooltip, {
|
|
42
24
|
content: tooltip,
|
|
43
25
|
position: "top-middle"
|
|
44
26
|
}, React.createElement(IconWrapper, {
|
|
@@ -48,31 +30,18 @@ export function getReadonlySendRateLabel(sendRateOption, isGlobalSendRateDisable
|
|
|
48
30
|
view: "lined"
|
|
49
31
|
}))));
|
|
50
32
|
}
|
|
51
|
-
return isGlobalSendRateDisabled ? React.createElement(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"$justifyContent": "start"
|
|
55
|
-
}, "Global send rate is not active for this channel", React.createElement(Tooltip, {
|
|
56
|
-
content: tooltip,
|
|
57
|
-
position: "top-middle"
|
|
58
|
-
}, React.createElement(IconWrapper, {
|
|
59
|
-
"$padding": "4px 0"
|
|
60
|
-
}, React.createElement(HelpRoundIcon, {
|
|
61
|
-
size: "small",
|
|
62
|
-
view: "lined"
|
|
63
|
-
})))) : React.createElement(Paragraph, null, "Global send rate:", React.createElement(Condition, {
|
|
33
|
+
return isGlobalSendRateDisabled ? React.createElement(React.Fragment, null, "Global send rate:", React.createElement(ChipSendRate, {
|
|
34
|
+
messages: 0
|
|
35
|
+
}), "because limit isn\u2019t set") : React.createElement(React.Fragment, null, "Global send rate:", React.createElement(ChipSendRate, {
|
|
64
36
|
messages: globalSendRate.count
|
|
65
37
|
}));
|
|
66
38
|
}
|
|
67
|
-
function getReadonlyTooltip(sendRateOption
|
|
39
|
+
function getReadonlyTooltip(sendRateOption) {
|
|
68
40
|
if (sendRateOption === 'CUSTOM') {
|
|
69
41
|
return '';
|
|
70
42
|
}
|
|
71
43
|
if (sendRateOption === 'IGNORE') {
|
|
72
44
|
return 'Messages will be sent without rate limits, if possible, because no send rate is applied to this message';
|
|
73
45
|
}
|
|
74
|
-
if (isGlobalSendRateDisabled) {
|
|
75
|
-
return 'Messages will be sent as fast as possible because the global send rate limit is currently not active for this channel';
|
|
76
|
-
}
|
|
77
46
|
return '';
|
|
78
47
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const getSendRateOptions = isGlobalSendRateDisabled => [{
|
|
2
|
-
value: 'GLOBAL',
|
|
3
|
-
label: `Use global send rate settings${isGlobalSendRateDisabled ? ' (currently inactive)' : ''}`
|
|
4
|
-
}, {
|
|
5
|
-
value: 'IGNORE',
|
|
6
|
-
label: 'Send messages without send rate'
|
|
7
|
-
}, {
|
|
8
|
-
value: 'CUSTOM',
|
|
9
|
-
label: 'Use custom send rate'
|
|
10
|
-
}];
|