@capillarytech/creatives-library 2.0.84 → 2.0.86

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.
Files changed (87) hide show
  1. package/app.js +9 -2
  2. package/config/app.js +4 -4
  3. package/config/path.js +1 -0
  4. package/index.js +4 -4
  5. package/package.json +2 -3
  6. package/routes.js +5 -0
  7. package/v2Components/EmailPreviewV2/index.js +3 -3
  8. package/v2Components/FormBuilder/index.js +6 -6
  9. package/v2Components/NavigationBar/index.js +235 -0
  10. package/v2Components/NavigationBar/messages.js +20 -0
  11. package/v2Components/NavigationBar/tests/index.test.js +11 -0
  12. package/v2Components/TopBar/index.js +63 -106
  13. package/v2Components/TopBar/messages.js +8 -0
  14. package/v2Containers/CallTask/index.js +1 -1
  15. package/v2Containers/CallTask/sagas.js +1 -1
  16. package/v2Containers/Cap/actions.js +12 -0
  17. package/v2Containers/Cap/constants.js +10 -0
  18. package/v2Containers/Cap/index.js +26 -142
  19. package/v2Containers/Cap/reducer.js +14 -0
  20. package/v2Containers/Cap/sagas.js +24 -0
  21. package/v2Containers/Cap/tests/selectors.test.js +1 -1
  22. package/v2Containers/ChannelTemplates/sagas.js +1 -1
  23. package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -0
  24. package/v2Containers/CreativesContainer/index.js +15 -2
  25. package/v2Containers/CreativesContainer/sagas.js +1 -1
  26. package/v2Containers/Dashboard/sagas.js +1 -1
  27. package/v2Containers/Ebill/constants.js +11 -11
  28. package/v2Containers/Ebill/index.js +1 -1
  29. package/v2Containers/Email/constants.js +24 -24
  30. package/v2Containers/Email/index.js +1 -1
  31. package/v2Containers/EmailWrapper/sagas.js +1 -1
  32. package/v2Containers/Line/Create/constants.js +22 -22
  33. package/v2Containers/Line/Create/index.js +1 -1
  34. package/v2Containers/Line/Edit/constants.js +16 -16
  35. package/v2Containers/Login/index.js +2 -2
  36. package/v2Containers/MobilePush/Create/constants.js +14 -14
  37. package/v2Containers/MobilePush/Create/index.js +1 -1
  38. package/v2Containers/MobilePush/Edit/constants.js +23 -23
  39. package/v2Containers/MobilepushWrapper/index.js +8 -0
  40. package/v2Containers/Sms/Create/constants.js +6 -6
  41. package/v2Containers/Sms/Create/index.js +6 -5
  42. package/v2Containers/Sms/Create/messages.js +8 -0
  43. package/v2Containers/Sms/Edit/constants.js +8 -8
  44. package/v2Containers/Sms/Edit/index.js +6 -6
  45. package/v2Containers/Sms/commonMethods.js +18 -0
  46. package/v2Containers/TagList/index.js +1 -1
  47. package/v2Containers/TagList/sagas.js +1 -1
  48. package/v2Containers/Templates/constants.js +37 -37
  49. package/v2Containers/Templates/index.js +6 -1
  50. package/v2Containers/TestPage/constants.js +1 -1
  51. package/v2Containers/TestPage/sagas.js +1 -1
  52. package/v2Containers/Testv2/sagas.js +1 -1
  53. package/v2Containers/WeChat/MapTemplates/constants.js +16 -16
  54. package/v2Containers/WeChat/MapTemplates/index.js +1 -1
  55. package/v2Containers/WeChat/RichmediaTemplates/Create/constants.js +9 -9
  56. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +2 -2
  57. package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +1 -1
  58. package/v2Containers/WeChat/RichmediaTemplates/Edit/constants.js +3 -3
  59. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +1 -1
  60. package/v2Containers/WeChat/RichmediaTemplates/View/sagas.js +1 -1
  61. package/assets/android-message-gui-2.svg +0 -55
  62. package/components/CallTaskPreview/_callTaskPreview.scss +0 -17
  63. package/components/CallTaskPreview/images/Footer.png +0 -0
  64. package/components/CallTaskPreview/images/Header.png +0 -0
  65. package/components/CallTaskPreview/index.js +0 -37
  66. package/components/CallTaskPreview/messages.js +0 -13
  67. package/components/CallTaskPreview/tests/index.test.js +0 -15
  68. package/components/CmsTemplatesComponent/index.js +0 -33
  69. package/components/CmsTemplatesComponent/messages.js +0 -17
  70. package/components/CmsTemplatesComponent/tests/index.test.js +0 -10
  71. package/components/EmailMobilePreview/index.js +0 -129
  72. package/components/EmailMobilePreview/index.scss +0 -55
  73. package/components/EmailPreviewV2/_emailPreviewV2.scss +0 -69
  74. package/components/EmailPreviewV2/index.js +0 -132
  75. package/components/EmailPreviewV2/messages.js +0 -41
  76. package/components/EmailPreviewV2/tests/index.test.js +0 -10
  77. package/components/MobilePushPreviewV2/index.js +0 -120
  78. package/components/MobilePushPreviewV2/messages.js +0 -13
  79. package/components/MobilePushPreviewV2/tests/index.test.js +0 -10
  80. package/components/NewCallTask/_newCallTask.scss +0 -9
  81. package/components/NewCallTask/index.js +0 -152
  82. package/components/NewCallTask/messages.js +0 -29
  83. package/components/NewCallTask/tests/index.test.js +0 -10
  84. package/components/SmsPreviewV2/_smsPreviewV2.scss +0 -353
  85. package/components/SmsPreviewV2/index.js +0 -69
  86. package/components/SmsPreviewV2/messages.js +0 -13
  87. package/components/SmsPreviewV2/tests/index.test.js +0 -10
package/app.js CHANGED
@@ -6,7 +6,8 @@ import createHistory from 'history/lib/createBrowserHistory';
6
6
  import { applyRouterMiddleware, Router, useRouterHistory } from 'react-router';
7
7
  import { syncHistoryWithStore } from 'react-router-redux';
8
8
  import { useScroll } from 'react-router-scroll';
9
- import Cap from 'v2Containers/Cap';
9
+ import CapV2 from 'v2Containers/Cap';
10
+ import Cap from 'containers/Cap';
10
11
  import { LocaleProvider } from 'antd';
11
12
  import { makeSelectLocationState } from 'containers/Cap/selectors';
12
13
  import LanguageProvider from 'containers/LanguageProvider';
@@ -35,7 +36,13 @@ const history = syncHistoryWithStore(browserHistory, store, {
35
36
  });
36
37
 
37
38
  const rootRoute = {
38
- component: Cap,
39
+ component: (props) => {
40
+ // eslint-disable-next-line react/prop-types
41
+ if (props.location.pathname === 'v2') {
42
+ return <CapV2 {...props} />;
43
+ }
44
+ return <Cap {...props} />;
45
+ },
39
46
  childRoutes: createRoutes(store),
40
47
  };
41
48
 
package/config/app.js CHANGED
@@ -6,16 +6,16 @@ const config = {
6
6
  api_endpoint: '/arya/api/v1/creatives',
7
7
  auth_endpoint: '/arya/api/v1/auth',
8
8
  login_url: 'auth/login',
9
- //dashboard_url: '/sms',
10
- dashboard_url: '/v2',
9
+ dashboard_url: '/sms',
10
+ dashboard_url_v2: '/v2',
11
11
  accountConfig: (strs, accountId) => `org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
12
12
  },
13
13
  development: {
14
14
  api_endpoint: 'https://nightly.capillary.in/arya/api/v1/creatives',
15
15
  auth_endpoint: 'https://nightly.capillary.in/arya/api/v1/auth',
16
16
  login_url: 'auth/login',
17
- // dashboard_url: '/sms',
18
- dashboard_url: '/v2',
17
+ dashboard_url: '/sms',
18
+ dashboard_url_v2: '/v2',
19
19
  },
20
20
  testing: {
21
21
  api_endpoint: '',
package/config/path.js CHANGED
@@ -1,3 +1,4 @@
1
1
  module.exports = {
2
2
  publicPath: '/creatives/ui/',
3
+ engagePlusPublicPath: '/campaigns/ui',
3
4
  };
package/index.js CHANGED
@@ -72,10 +72,10 @@ export {default as TagListSaga} from './v2Containers/TagList/sagas';
72
72
  export {default as TagListReducer} from './v2Containers/TagList/reducer';
73
73
  export {default as TemplatePreview} from './components/TemplatePreview';
74
74
  export {default as EmailPreview} from './components/EmailPreview';
75
- export {default as EmailPreviewV2} from './components/EmailPreviewV2';
76
- export {default as CallTaskPreview} from './components/CallTaskPreview';
77
- export {default as EmailMobilePreview} from './components/EmailMobilePreview';
78
- export {default as MobilePushPreview} from './components/MobilePushPreviewV2';
75
+ export {default as EmailPreviewV2} from './v2Components/EmailPreviewV2';
76
+ export {default as CallTaskPreview} from './v2Components/CallTaskPreview';
77
+ export {default as EmailMobilePreview} from './v2Components/EmailMobilePreview';
78
+ export {default as MobilePushPreview} from './v2Components/MobilePushPreviewV2';
79
79
  CreativesContainer.CreativesContainerReducer = CreativesContainerReducer;
80
80
 
81
81
  export { CapContainer,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "2.0.84",
4
+ "version": "2.0.86",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -12,8 +12,7 @@
12
12
  },
13
13
  "license": "LicenseRef-LICENSE",
14
14
  "dependencies": {
15
- "@capillarytech/cap-react-ui-library": "^1.11.14",
16
- "@capillarytech/cap-ui-library": "^1.0.144",
15
+ "@capillarytech/cap-ui-library": "^1.0.168",
17
16
  "antd": "3.19.6",
18
17
  "axios": "^0.16.2",
19
18
  "babel-polyfill": "6.20.0",
package/routes.js CHANGED
@@ -602,6 +602,8 @@ export default function createRoutes(store) {
602
602
  import('v2Containers/Templates/reducer'),
603
603
  import('v2Containers/Templates/sagas'),
604
604
  import('v2Containers/TemplatesV2'),
605
+ import('v2Containers/Cap/reducer'),
606
+ import('v2Containers/Cap/sagas'),
605
607
  import('v2Containers/Email/sagas'),
606
608
  import('v2Containers/CreativesContainer/reducer'),
607
609
  import('v2Containers/Sms/Create/reducer'),
@@ -624,6 +626,7 @@ export default function createRoutes(store) {
624
626
 
625
627
  importModules.then(([reducer,
626
628
  sagas, component,
629
+ capReducer, capSagas,
627
630
  emailContainerSagas, creativesContainerReducer,
628
631
  smsCreateReducer, smsCreateSaga, smsEditReducer, smsEditSaga,
629
632
  emailReducer, emailSaga,
@@ -633,6 +636,7 @@ export default function createRoutes(store) {
633
636
  galleryReducer, gallerySagas,
634
637
  ]) => {
635
638
  injectReducer('templates', reducer.default);
639
+ injectReducer('cap', capReducer.default);
636
640
  injectReducer('create', smsCreateReducer.default);
637
641
  injectReducer('creativesContainer', creativesContainerReducer.default);
638
642
  injectReducer('edit', smsEditReducer.default);
@@ -643,6 +647,7 @@ export default function createRoutes(store) {
643
647
  injectReducer('gallery', galleryReducer.default);
644
648
  injectSagas(gallerySagas.default);
645
649
  injectSagas(sagas.default);
650
+ injectSagas(capSagas.default);
646
651
  injectSagas(emailContainerSagas.default);
647
652
  injectSagas(smsCreateSaga.default);
648
653
  injectSagas(smsEditSaga.default);
@@ -19,8 +19,8 @@ import './_emailPreviewV2.scss';
19
19
  import tabletBody from '../../assets/iPad.svg';
20
20
  import mobileBody from '../../assets/mobile.png';
21
21
 
22
- import {selectTemplateContent} from '../../containers/Templates/selectors';
23
- import * as templateActions from '../../containers/Templates/actions';
22
+ import {selectTemplateContent} from '../../v2Containers/Templates/selectors';
23
+ import * as templateActions from '../../v2Containers/Templates/actions';
24
24
 
25
25
  const deviceAspectRatio = {
26
26
  desktop: {
@@ -99,7 +99,7 @@ class EmailPreviewV2 extends React.Component {
99
99
  </div>
100
100
  </div>
101
101
  </div>
102
- {this.props.templateData &&
102
+ {this.props.templateData && this.props.templateData.updatedByName &&
103
103
  [
104
104
  <p className="preview-info" key="lastModified"><FormattedMessage {...messages.lastModified} />: {moment(this.props.templateData.updatedAt).format('MM-DD-YYYY')}</p>,
105
105
  <p style={{marginBottom: '8px'}} key="uploadedBy" className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>,
@@ -14,14 +14,14 @@ import _ from 'lodash';
14
14
  import { Tabs, Table, Modal} from 'antd';
15
15
  import { CapButton, CapInput, CapPopover, CapCheckbox, CapRadio, CapSelect, CapTable, CapRow, CapColumn, CapNotification} from '@capillarytech/cap-ui-library';
16
16
  import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
17
- import TemplatePreview from '../../components/TemplatePreview';
18
- import TagList from '../../containers/TagList';
17
+ import TemplatePreview from '../TemplatePreview';
18
+ import TagList from '../../v2Containers/TagList';
19
19
  import SmsEditor from '../SmsEditor';
20
20
  import SlideBox from '../SlideBox';
21
21
  import CardGrid from '../CardGrid';
22
- import CKEditor from "../../components/Ckeditor/";
23
- import EDMEditor from "../../components/Edmeditor";
24
- import CustomPopOver from '../../components/CustomPopOver';
22
+ import CKEditor from "../Ckeditor/";
23
+ import EDMEditor from "../Edmeditor";
24
+ import CustomPopOver from '../CustomPopOver';
25
25
  import './_formBuilder.scss';
26
26
  import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
27
27
  const TabPane = Tabs.TabPane;
@@ -451,7 +451,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
451
451
  if (tagValidationResponse.valid) {
452
452
  errorData[count][`sms-editor${index > 1 ? index : ''}`] = false;
453
453
  } else {
454
-
454
+ errorData[count]['invalid-tags'] = tagValidationResponse.unsupportedTags;
455
455
  errorData[count][`sms-editor${index > 1 ? index : ''}`] = true;
456
456
  isValid = false;
457
457
  }
@@ -0,0 +1,235 @@
1
+ /**
2
+ *
3
+ * NavigationBar
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import styled from 'styled-components';
10
+ import { isEmpty, forEach } from 'lodash';
11
+ import { loadItem } from 'services/localStorageApi';
12
+ import { intlShape, injectIntl } from 'react-intl';
13
+ import TopBar from '../TopBar';
14
+ import messages from './messages';
15
+
16
+ const EMBEDDED = 'embedded';
17
+
18
+ const CapWrapper = styled.div`
19
+ position: absolute;
20
+ padding: 0;
21
+ background-color: #ffffff;
22
+ width: 100%;
23
+ display: flex;
24
+ margin-top: ${(props) => props.isEmbedded ? '0px' : '64px'}
25
+ `;
26
+
27
+ const ComponentWrapper = styled.div`
28
+ max-width: 1140px;
29
+ margin: 0 auto;
30
+ width: 100%;
31
+ padding: 24px 0;
32
+ `;
33
+
34
+ class NavigationBar extends React.Component {
35
+ constructor(props) {
36
+ super(props);
37
+ this.state = {
38
+ selectedProduct: '',
39
+ };
40
+ }
41
+
42
+ onBrandSettingsClick = () => {
43
+ const { brandSettingsUrl } = this.props;
44
+ if (brandSettingsUrl) {
45
+ const stateObj = {
46
+ page: "brand settings",
47
+ };
48
+ window.history.pushState(stateObj, 'BrandSettings', window.location.replace(brandSettingsUrl));
49
+ }
50
+ };
51
+
52
+ onProfileSettingsClick = () => {
53
+ const { profileSettingsUrl } = this.props;
54
+ if (profileSettingsUrl) {
55
+ const stateObj = {
56
+ page: "profile settings",
57
+ };
58
+ window.history.pushState(stateObj, 'ProfileSettings', window.location.replace(profileSettingsUrl));
59
+ }
60
+ };
61
+
62
+ onSettingsIconClick = () => {
63
+ const { settingsUrl } = this.props;
64
+ if (settingsUrl) {
65
+ const stateObj = {
66
+ page: "settings",
67
+ };
68
+ window.history.pushState(stateObj, 'Settings', window.location.replace(settingsUrl));
69
+ }
70
+ };
71
+
72
+ onHelpIconClick = () => {
73
+ const { helpUrl } = this.props;
74
+ if (helpUrl) {
75
+ const stateObj = {
76
+ page: "help",
77
+ };
78
+ window.history.pushState(stateObj, 'Help', window.location.replace(helpUrl));
79
+ }
80
+ };
81
+
82
+ getProxyOrgList = () => {
83
+ const { userData } = this.props;
84
+ const proxyOrgList = [];
85
+ if (userData && userData.user && userData.user !== '') {
86
+ const defaultOrgName = userData.user.orgName;
87
+ const defaultOrgId = userData.user.orgID;
88
+ proxyOrgList.push({ label: defaultOrgName, value: defaultOrgId, key: defaultOrgId });
89
+ const orgList = userData.user.proxyOrgList;
90
+ if (!isEmpty(orgList)) {
91
+ forEach(orgList, (item) => {
92
+ const id = item.orgID;
93
+ let name = item.orgName;
94
+ if (id === 486) {
95
+ name = 'Demo Org';
96
+ }
97
+ if (id !== defaultOrgId) {
98
+ proxyOrgList.push({ label: name, value: id, key: id });
99
+ }
100
+ });
101
+ }
102
+ }
103
+ return proxyOrgList;
104
+ };
105
+
106
+ getProductsList = () => {
107
+ const { currentOrgDetails } = this.props.userData;
108
+ const productsList = [];
109
+ if (currentOrgDetails) {
110
+ forEach(currentOrgDetails.module_details, (module) => {
111
+ if (module.name.toLowerCase() !== 'masters') {
112
+ productsList.push({
113
+ value: module.name.toLowerCase(),
114
+ url: module.url,
115
+ key: module.code,
116
+ });
117
+ }
118
+ });
119
+ }
120
+ return productsList;
121
+ };
122
+
123
+ getTopbarIcons = () => [
124
+ {
125
+ iconType: 'help',
126
+ key: 'help',
127
+ onClickHandler: () => this.onHelpIconClick(),
128
+ },
129
+ {
130
+ iconType: 'settings',
131
+ key: 'settings',
132
+ onClickHandler: () => this.onSettingsIconClick(),
133
+ },
134
+ ];
135
+
136
+ getDropdownMenu = () => [
137
+ {
138
+ label: 'Profile Settings',
139
+ key: 'Profile Settings',
140
+ onClickHandler: () => this.onProfileSettingsClick(),
141
+ },
142
+ {
143
+ label: 'Brand Settings',
144
+ key: 'Brand Settings',
145
+ onClickHandler: () => this.onBrandSettingsClick(),
146
+ },
147
+ {
148
+ label: 'Logout',
149
+ key: 'Logout',
150
+ onClickHandler: () => this.props.logout(),
151
+ },
152
+ ];
153
+
154
+ handleTopbarMenuChange = (option) => {
155
+ window.location.pathname = option.link;
156
+ };
157
+
158
+ handleOrgChange = (orgId) => {
159
+ const selectedOrg = loadItem('orgID');
160
+ if (selectedOrg !== orgId) {
161
+ this.props.changeOrg(orgId);
162
+ }
163
+ };
164
+
165
+ handleProductChange = (product) => {
166
+ const { location } = this.props;
167
+ const { basename } = location;
168
+ this.setState({ selectedProduct: product.value }, () => {
169
+ if (product.url !== `${basename}/index`) {
170
+ window.location.pathname = product.url;
171
+ }
172
+ });
173
+ };
174
+
175
+ render() {
176
+ const {
177
+ topbarMenuData,
178
+ loggedIn,
179
+ intl,
180
+ type,
181
+ } = this.props;
182
+ const productsList = this.getProductsList();
183
+ const proxyOrgList = this.getProxyOrgList();
184
+ const selectedOrg = loadItem('orgID');
185
+ const dropdownMenuProps = this.getDropdownMenu();
186
+ const topbarIcons = this.getTopbarIcons();
187
+ const { selectedProduct } = this.state;
188
+ const customTopBarProps = {};
189
+ return (
190
+ <div>
191
+ {loggedIn && type !== EMBEDDED &&
192
+ <TopBar
193
+ productsList={productsList}
194
+ selectedProduct={
195
+ selectedProduct ||
196
+ intl.formatMessage(messages.selectedProductDefault)
197
+ }
198
+ handleProductChange={this.handleProductChange}
199
+ proxyOrgList={proxyOrgList}
200
+ selectedOrg={selectedOrg}
201
+ handleOrgChange={this.handleOrgChange}
202
+ topbarMenuData={topbarMenuData}
203
+ handleTopbarMenuChange={this.handleTopbarMenuChange}
204
+ dropdownMenuProps={dropdownMenuProps}
205
+ topbarIcons={topbarIcons}
206
+ {...customTopBarProps}
207
+ />
208
+ }
209
+ <CapWrapper isEmbedded={type === EMBEDDED}>
210
+ <ComponentWrapper>
211
+ {React.Children.toArray(this.props.children)}
212
+ </ComponentWrapper>
213
+ </CapWrapper>
214
+ </div>
215
+ );
216
+ }
217
+ }
218
+
219
+ NavigationBar.propTypes = {
220
+ userData: PropTypes.object,
221
+ topbarMenuData: PropTypes.array,
222
+ logout: PropTypes.func,
223
+ changeOrg: PropTypes.func,
224
+ settingsUrl: PropTypes.string,
225
+ children: PropTypes.node,
226
+ helpUrl: PropTypes.string,
227
+ profileSettingsUrl: PropTypes.string,
228
+ brandSettingsUrl: PropTypes.string,
229
+ loggedIn: PropTypes.bool,
230
+ intl: intlShape.isRequired,
231
+ location: PropTypes.object,
232
+ type: PropTypes.string,
233
+ };
234
+
235
+ export default injectIntl(NavigationBar);
@@ -0,0 +1,20 @@
1
+ /*
2
+ * NavigationBar Messages
3
+ *
4
+ * This contains all the text for the NavigationBar component.
5
+ */
6
+
7
+ import { defineMessages } from 'react-intl';
8
+
9
+ export const scope = 'app.components.NavigationBar';
10
+
11
+ export default defineMessages({
12
+ header: {
13
+ id: `${scope}.header`,
14
+ defaultMessage: 'This is the NavigationBar component!',
15
+ },
16
+ selectedProductDefault: {
17
+ id: `${scope}.selectedProductDefault`,
18
+ defaultMessage: 'Campaigns',
19
+ },
20
+ });
@@ -0,0 +1,11 @@
1
+ // import React from 'react';
2
+ // import { mount } from 'enzyme';
3
+ // import { enzymeFind } from 'styled-components/test-utils';
4
+
5
+ // import NavigationBar from '../index';
6
+
7
+ describe('<NavigationBar />', () => {
8
+ it('Expect to have unit tests specified', () => {
9
+ expect(true).toEqual(true); // this component will be replaced so just this test case
10
+ });
11
+ });
@@ -1,113 +1,70 @@
1
- import PropTypes from 'prop-types';
2
1
  import React from 'react';
3
- // import styled from 'styled-components';
4
-
5
- import { Menu, Image, Dropdown, Popup } from 'semantic-ui-react';
6
- import { FormattedMessage } from 'react-intl';
7
- import { Link } from 'react-router';
8
-
9
- import { loadItem } from 'services/localStorageApi';
2
+ import PropTypes from 'prop-types';
3
+ import { CapTopBar, CapHeading } from '@capillarytech/cap-ui-library';
4
+ import { CAP_SPACE_24 } from '@capillarytech/cap-ui-library/styled/variables';
5
+ import { intlShape, injectIntl } from 'react-intl';
10
6
  import messages from './messages';
11
- import './_topbar.scss';
12
-
13
- const logo = require('./assets/images/capillary_logo.png');
14
-
15
- class TopBar extends React.Component { // eslint-disable-line react/prefer-stateless-function
16
- constructor(props) {
17
- super(props);
18
- this.state = {
19
- activeItem: '',
20
- orgList: [],
21
- selectedOrg: loadItem('orgID'),
22
- };
23
- this.handleItemClick = this.handleItemClick.bind(this);
24
- this.logout = this.logout.bind(this);
25
- this.handleOrgChange = this.handleOrgChange.bind(this);
26
- }
27
-
28
- componentDidUpdate(prevProps) {
29
- if (prevProps.orgID !== this.props.orgID) {
30
- this.props.navigateToDashboard();
31
- }
32
- }
33
-
34
- handleOrgChange(data) {
35
- const orgId = data.value;
36
- if (this.state.selectedOrg !== orgId) {
37
- this.props.changeOrg(orgId);
38
- this.setState({ selectedOrg: orgId });
39
- }
40
- }
7
+ const drawerPlacement = 'left';
41
8
 
42
- handleItemClick(e) {
43
- this.setState({ activeItem: e.target.id });
44
- }
45
-
46
- logout(e) {
47
- e.preventDefault();
48
- this.props.logout();
49
- }
50
-
51
- render() {
52
- const proxyOrgList = this.props.proxyOrgList;
53
- const defaultOrgName = this.props.orgName;
54
- const selectedOrg = loadItem('orgID');
55
- return (
56
- <Menu className="navbar" key="navbar">
57
-
58
- <Menu.Item key="logo" as={Link} to="/" name="logo" className="logo-container" onClick={this.handleItemClick}>
59
- <Image className="logo" src={logo} alt="Capillary Technologies" />
60
- </Menu.Item>
61
-
62
- { proxyOrgList.length > 1 ?
63
- <Menu.Item className="dropdownItem" key="orgSelection">
64
- <FormattedMessage {...messages.dropdownMessage}>
65
- {(message) => <Dropdown
66
- placeholder={message}
67
- className="org-list-drp-dwn"
68
- defaultValue={selectedOrg}
69
- search
70
- options={proxyOrgList}
71
- selection
72
- onChange={(event, data) => this.handleOrgChange(data)}
73
- />}
74
- </FormattedMessage>
75
- </Menu.Item> :
76
- <Menu.Item key="default-org">
77
- {defaultOrgName}
78
- </Menu.Item>
79
- }
80
-
81
- <Menu.Menu position="right">
82
- <Menu.Item key="first-name">
83
- <FormattedMessage {...messages.hi} />&nbsp;{this.props.userName}!
84
- </Menu.Item>
85
- <Menu.Item key="user-details">
86
- <Popup
87
- trigger={<i className="material-icons">person</i>}
88
- content={< div className="ui secondary vertical menu">
89
- <a href="" className="item hide"><FormattedMessage {...messages.profile} /><i className="user icon" /></a>
90
- <a href="" className="item hide"><FormattedMessage {...messages.settings} /> <i className="settings icon" /></a>
91
- <a href="" className="item" onClick={this.logout}><FormattedMessage {...messages.logout} />
92
- <i className="sign out icon" /></a> </div >}
93
- on="click" position="bottom right" offset={7}
94
- />
95
- </Menu.Item>
96
- </Menu.Menu>
97
- </Menu>
98
-
99
- );
100
- }
101
- }
9
+ const TopBar = (props) => {
10
+ const {
11
+ productsList,
12
+ selectedProduct,
13
+ handleProductChange,
14
+ proxyOrgList,
15
+ selectedOrg,
16
+ handleOrgChange,
17
+ topbarMenuData,
18
+ handleTopbarMenuChange,
19
+ dropdownMenuProps,
20
+ topbarIcons,
21
+ intl,
22
+ } = props;
23
+ return (
24
+ <CapTopBar
25
+ drawerListProps={{
26
+ productsList,
27
+ selectedProduct,
28
+ handleProductChange,
29
+ title: (
30
+ <CapHeading type="h5" style={{ margin: `${CAP_SPACE_24} 0` }}>
31
+ {intl.formatMessage(messages.selectProduct)}
32
+ </CapHeading>
33
+ ),
34
+ closable: false,
35
+ placement: drawerPlacement,
36
+ width: 320,
37
+ }}
38
+ selectProps={{
39
+ items: proxyOrgList,
40
+ selectedItem: selectedOrg,
41
+ handleItemChange: handleOrgChange,
42
+ selectPlaceholder: intl.formatMessage(messages.selectOrganization),
43
+ showSearch: true,
44
+ showHeader: true,
45
+ }}
46
+ menuProps={{
47
+ items: topbarMenuData,
48
+ defaultSelectedKeys: ['creatives'],
49
+ onMenuItemClick: handleTopbarMenuChange,
50
+ }}
51
+ dropdownMenuProps={dropdownMenuProps}
52
+ topbarIcons={topbarIcons}
53
+ />
54
+ );
55
+ };
102
56
 
103
57
  TopBar.propTypes = {
104
- userName: PropTypes.string,
58
+ productsList: PropTypes.array,
59
+ selectedProduct: PropTypes.string,
60
+ handleProductChange: PropTypes.func,
105
61
  proxyOrgList: PropTypes.array,
106
- orgName: PropTypes.string,
107
- orgID: PropTypes.number,
108
- navigateToDashboard: PropTypes.func,
109
- changeOrg: PropTypes.func,
110
- logout: PropTypes.func,
62
+ selectedOrg: PropTypes.number,
63
+ handleOrgChange: PropTypes.func,
64
+ topbarMenuData: PropTypes.array,
65
+ handleTopbarMenuChange: PropTypes.func,
66
+ topbarIcons: PropTypes.array,
67
+ dropdownMenuProps: PropTypes.array,
68
+ intl: intlShape.isRequired,
111
69
  };
112
-
113
- export default TopBar;
70
+ export default injectIntl(TopBar);
@@ -26,4 +26,12 @@ export default defineMessages({
26
26
  id: 'app.components.TopBar.brand.dropdown',
27
27
  defaultMessage: 'Hi',
28
28
  },
29
+ selectOrganization: {
30
+ id: 'app.components.TopBar.brand.selectOrganization',
31
+ defaultMessage: 'Select Organization',
32
+ },
33
+ selectProduct: {
34
+ id: 'app.components.TopBar.brand.selectProduct',
35
+ defaultMessage: 'Select Product',
36
+ },
29
37
  });
@@ -17,7 +17,7 @@ import {
17
17
  import { injectIntl, intlShape } from 'react-intl';
18
18
  import { createStructuredSelector } from 'reselect';
19
19
  import { makeSelectMetaEntities, isLoadingMetaEntities } from '../Cap/selectors';
20
- import * as globalActions from '../../containers/Cap/actions';
20
+ import * as globalActions from '../Cap/actions';
21
21
  import * as actions from "./actions";
22
22
  import makeSelectCallTask from './selectors';
23
23
  import NewCallTask from '../../v2Components/NewCallTask';
@@ -2,7 +2,7 @@
2
2
 
3
3
  // Individual exports for testing
4
4
  export function* defaultSaga() {
5
- // See example in containers/HomePage/sagas.js
5
+ // See example in v2Containers/HomePage/sagas.js
6
6
  }
7
7
 
8
8
  // All sagas to be loaded
@@ -62,3 +62,15 @@ export function setInjectedTags(injectedTags) {
62
62
  };
63
63
  }
64
64
 
65
+ export function getTopbarMenuData() {
66
+ return {
67
+ type: types.GET_TOPBAR_MENU_DATA_REQUEST,
68
+ };
69
+ }
70
+
71
+ export function clearTopbarMenuData() {
72
+ return {
73
+ type: types.CLEAR_TOPBAR_MENU_DATA,
74
+ };
75
+ }
76
+