@capillarytech/creatives-library 3.0.6 → 3.0.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "3.0.6",
4
+ "version": "3.0.7",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -49,6 +49,7 @@ function SlideBoxContent(props) {
49
49
  setIsLoadingContent,
50
50
  showTemplateName,
51
51
  onValidationFail,
52
+ hideChannel,
52
53
  } = props;
53
54
  const type = messageDetails.type.toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
54
55
  const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'defualt' : 'library'};
@@ -95,6 +96,7 @@ function SlideBoxContent(props) {
95
96
  onChannelChange={onChannelChange}
96
97
  onCallTaskSubmit={onCallTaskSubmit}
97
98
  cap={cap}
99
+ hideChannel={hideChannel}
98
100
  />
99
101
  )}
100
102
  {isPreview && (
@@ -268,5 +270,6 @@ SlideBoxContent.propTypes = {
268
270
  mobilePushCreateMode: PropTypes.string,
269
271
  showTemplateName: PropTypes.func,
270
272
  onValidationFail: PropTypes.func,
273
+ hideChannel: PropTypes.array,
271
274
  };
272
275
  export default SlideBoxContent;
@@ -253,6 +253,7 @@ class Creatives extends React.Component {
253
253
  );
254
254
  }
255
255
  };
256
+
256
257
  setIsLoadingContent = (isLoadingContent) => {
257
258
  if (this.state.isLoadingContent !== isLoadingContent) {
258
259
  this.setState({isLoadingContent });
@@ -406,7 +407,7 @@ class Creatives extends React.Component {
406
407
  }
407
408
  render() {
408
409
  const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep, isLoadingContent, mobilePushCreateMode, isDiscardMessage} = this.state;
409
- const {isFullMode, creativesMode, cap, isUploading} = this.props;
410
+ const {isFullMode, creativesMode, cap, isUploading, channelsToHide} = this.props;
410
411
  return (
411
412
  <SlideBoxWrapper className={classnames(`${classPrefix} ${isFullMode ? 'creatives-full-mode' : 'creatives-library-mode'}`)}>
412
413
  <CapSlideBox
@@ -456,6 +457,7 @@ class Creatives extends React.Component {
456
457
  mobilePushCreateMode={mobilePushCreateMode}
457
458
  showTemplateName={this.showTemplateName}
458
459
  onValidationFail={this.onValidationFail}
460
+ channelsToHide={channelsToHide}
459
461
  />
460
462
  }
461
463
  footer={this.shouldShowFooter() &&
@@ -500,6 +502,7 @@ Creatives.propTypes = {
500
502
  templateUserList: PropTypes.array,
501
503
  isUploading: PropTypes.bool,
502
504
  EmailLayout: PropTypes.string,
505
+ channelsToHide: PropTypes.array,
503
506
  };
504
507
  const mapStatesToProps = () => createStructuredSelector({
505
508
  isLoading: isLoadingSelector(),
@@ -51,19 +51,27 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
51
51
  constructor(props) {
52
52
  super(props);
53
53
  const defaultChannel = get(this, 'props.channel') || get(this, 'props.params.channel') || 'sms';
54
- const defaultPanes = [
55
- {content: <div></div>, tab: 'SMS', key: 'sms'},
56
- {content: <div></div>, tab: 'Email', key: 'email'},
57
- // {content: this.getTemplatesComponent('wechat'), tab: 'Wechat', key: 'wechat'},
58
- {content: <div></div>, tab: 'Push notification', key: 'mobilepush'},
59
- ];
60
- if (props.isFullMode) {
61
- defaultPanes.push({content: <div></div>, tab: 'Gallery', key: 'assets'});
62
- }
63
- if (!props.isFullMode) {
64
- defaultPanes.push({content: <div></div>, tab: 'Call Task', key: 'call_task'});
54
+ const defaultPanes = {
55
+ sms: {content: <div></div>, tab: 'SMS', key: 'sms'},
56
+ email: {content: <div></div>, tab: 'Email', key: 'email'},
57
+ //'wechat': {content: this.getTemplatesComponent('wechat'), tab: 'Wechat', key: 'wechat'},
58
+ mPush: {content: <div></div>, tab: 'Push notification', key: 'mobilepush'},
59
+ };
60
+ const channelsToHide = this.props.channelsToHide || [];
61
+
62
+ const filteredPanes = Object.keys(defaultPanes)
63
+ .filter((key) => !channelsToHide.includes(key)).reduce((obj = [], key) => {
64
+ obj.push(defaultPanes[key]);
65
+ return obj;
66
+ }, []);
67
+
68
+ if (props.isFullMode ) {
69
+ filteredPanes.push({content: <div></div>, tab: 'Gallery', key: 'assets'});
70
+ } else if (!channelsToHide.includes('callTask')) {
71
+ filteredPanes.push({content: <div></div>, tab: 'Call Task', key: 'call_task'});
65
72
  }
66
- const panes = this.setChannelContent(defaultChannel, defaultPanes);
73
+
74
+ const panes = this.setChannelContent(defaultChannel, filteredPanes);
67
75
  this.state = {
68
76
  selectedChannel: defaultChannel,
69
77
  panes,
@@ -197,6 +205,7 @@ TemplatesV2.propTypes = {
197
205
  onCallTaskSubmit: PropTypes.func,
198
206
  intl: intlShape,
199
207
  onChannelChange: PropTypes.func,
208
+ channelsToHide: PropTypes.array,
200
209
  };
201
210
 
202
211
  TemplatesV2.defaultProps = {