@plusscommunities/pluss-circles-web 1.0.8 → 1.0.9
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/dist/index.cjs.js +73 -12
- package/dist/index.esm.js +73 -12
- package/dist/index.umd.js +73 -12
- package/package.json +1 -1
- package/src/actions/CirclesActions.js +8 -1
- package/src/actions/types.js +1 -0
- package/src/apis/circleActions.js +9 -0
- package/src/reducers/CircleReducer.js +8 -1
- package/src/screens/Circles.js +52 -16
package/dist/index.cjs.js
CHANGED
|
@@ -127,6 +127,7 @@ var FeatureConfig = {
|
|
|
127
127
|
|
|
128
128
|
var CIRCLES_LOADED = 'CIRCLES_LOADED';
|
|
129
129
|
var CIRCLE_UPDATED = 'CIRCLE_UPDATED';
|
|
130
|
+
var CIRCLE_REMOVED = 'CIRCLE_REMOVED';
|
|
130
131
|
|
|
131
132
|
var circlesLoaded = function circlesLoaded(circles) {
|
|
132
133
|
return {
|
|
@@ -140,6 +141,12 @@ var circleUpdated = function circleUpdated(circle) {
|
|
|
140
141
|
payload: circle
|
|
141
142
|
};
|
|
142
143
|
};
|
|
144
|
+
var circleRemoved = function circleRemoved(circleId) {
|
|
145
|
+
return {
|
|
146
|
+
type: CIRCLE_REMOVED,
|
|
147
|
+
payload: circleId
|
|
148
|
+
};
|
|
149
|
+
};
|
|
143
150
|
|
|
144
151
|
var Helper$3 = PlussCore__namespace.Helper,
|
|
145
152
|
Session$3 = PlussCore__namespace.Session;
|
|
@@ -192,6 +199,15 @@ var circleActions = {
|
|
|
192
199
|
}
|
|
193
200
|
});
|
|
194
201
|
},
|
|
202
|
+
delete: function _delete(circleId) {
|
|
203
|
+
return Session$3.authedFunction({
|
|
204
|
+
method: 'POST',
|
|
205
|
+
url: Helper$3.getUrl('circles', 'update/delete'),
|
|
206
|
+
data: {
|
|
207
|
+
circleId: circleId
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
},
|
|
195
211
|
addAdmin: function addAdmin(circleId, userId) {
|
|
196
212
|
return Session$3.authedFunction({
|
|
197
213
|
method: 'POST',
|
|
@@ -424,6 +440,18 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
424
440
|
_this.setState(stateChange);
|
|
425
441
|
});
|
|
426
442
|
|
|
443
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "removeCircle", function (circle) {
|
|
444
|
+
if (window.confirm("Are you sure you want to delete that circle? You will no longer be able to access the messages in the circle.")) {
|
|
445
|
+
_this.props.circleRemoved(circle.Id);
|
|
446
|
+
|
|
447
|
+
circleActions.delete(circle.Id).then(function (res) {
|
|
448
|
+
_this.getData();
|
|
449
|
+
}).catch(function (res) {
|
|
450
|
+
alert('Something went wrong with the request. Please try again.');
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
427
455
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "getTypeFilterText", function (type) {
|
|
428
456
|
if (type === 'private') {
|
|
429
457
|
return 'Private Message';
|
|
@@ -500,13 +528,17 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
500
528
|
}
|
|
501
529
|
}, {
|
|
502
530
|
key: "validateCircleAdmin",
|
|
503
|
-
value: function validateCircleAdmin(circle) {
|
|
531
|
+
value: function validateCircleAdmin(circle, onlyCreator) {
|
|
504
532
|
var _this4 = this;
|
|
505
533
|
|
|
506
534
|
if (Session$2.validateAccess(this.props.auth.site, 'circles', this.props.auth)) {
|
|
507
535
|
return true;
|
|
508
536
|
}
|
|
509
537
|
|
|
538
|
+
if (onlyCreator) {
|
|
539
|
+
return circle.Creator && circle.Creator.userId === this.props.user.Id || circle.CreatorId === this.props.user.Id;
|
|
540
|
+
}
|
|
541
|
+
|
|
510
542
|
return ___default['default'].some(circle.Audience, function (user) {
|
|
511
543
|
return user.userId === _this4.props.user.Id && user.isAdmin;
|
|
512
544
|
});
|
|
@@ -514,6 +546,8 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
514
546
|
}, {
|
|
515
547
|
key: "renderRow",
|
|
516
548
|
value: function renderRow(circle) {
|
|
549
|
+
var _this5 = this;
|
|
550
|
+
|
|
517
551
|
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
518
552
|
key: circle.Id
|
|
519
553
|
}, /*#__PURE__*/React__default['default'].createElement("td", {
|
|
@@ -527,7 +561,14 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
527
561
|
hoverText: user.displayName,
|
|
528
562
|
containerClass: "circleTableProfilePic"
|
|
529
563
|
});
|
|
530
|
-
})), /*#__PURE__*/React__default['default'].createElement("td",
|
|
564
|
+
})), /*#__PURE__*/React__default['default'].createElement("td", {
|
|
565
|
+
className: "table-options"
|
|
566
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
567
|
+
style: {
|
|
568
|
+
display: 'flex',
|
|
569
|
+
alignItems: 'center'
|
|
570
|
+
}
|
|
571
|
+
}, this.validateCircleAdmin(circle) && !circle.IsPrivate && /*#__PURE__*/React__default['default'].createElement(reactRouterDom.Link, {
|
|
531
572
|
to: "/circles/edit/".concat(circle.Id)
|
|
532
573
|
}, /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
533
574
|
style: {
|
|
@@ -537,7 +578,19 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
537
578
|
cursor: 'pointer'
|
|
538
579
|
},
|
|
539
580
|
name: "pencil"
|
|
540
|
-
})))
|
|
581
|
+
})), this.validateCircleAdmin(circle, true) && !circle.IsPrivate && /*#__PURE__*/React__default['default'].createElement("a", {
|
|
582
|
+
onClick: function onClick() {
|
|
583
|
+
_this5.removeCircle(circle);
|
|
584
|
+
}
|
|
585
|
+
}, /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
586
|
+
style: {
|
|
587
|
+
fontSize: 20,
|
|
588
|
+
padding: 5,
|
|
589
|
+
marginLeft: 12,
|
|
590
|
+
cursor: 'pointer'
|
|
591
|
+
},
|
|
592
|
+
name: "minus-circle"
|
|
593
|
+
})))));
|
|
541
594
|
}
|
|
542
595
|
}, {
|
|
543
596
|
key: "renderFilters",
|
|
@@ -586,7 +639,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
586
639
|
}, {
|
|
587
640
|
key: "renderUserFilterPopup",
|
|
588
641
|
value: function renderUserFilterPopup() {
|
|
589
|
-
var
|
|
642
|
+
var _this6 = this;
|
|
590
643
|
|
|
591
644
|
if (!this.state.userFilterOpen) {
|
|
592
645
|
return null;
|
|
@@ -606,7 +659,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
606
659
|
placeholder: "Enter name",
|
|
607
660
|
value: this.state.userSearch,
|
|
608
661
|
onChange: function onChange(e) {
|
|
609
|
-
return
|
|
662
|
+
return _this6.onHandleChange(e);
|
|
610
663
|
},
|
|
611
664
|
alwaysShowLabel: true
|
|
612
665
|
}), this.getUsers().map(function (user) {
|
|
@@ -614,7 +667,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
614
667
|
key: user.userId,
|
|
615
668
|
user: user,
|
|
616
669
|
onClick: function onClick() {
|
|
617
|
-
|
|
670
|
+
_this6.selectUserFilter(user);
|
|
618
671
|
}
|
|
619
672
|
});
|
|
620
673
|
}));
|
|
@@ -622,7 +675,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
622
675
|
}, {
|
|
623
676
|
key: "renderTypeFilterPopup",
|
|
624
677
|
value: function renderTypeFilterPopup() {
|
|
625
|
-
var
|
|
678
|
+
var _this7 = this;
|
|
626
679
|
|
|
627
680
|
if (!this.state.typeFilterOpen) {
|
|
628
681
|
return null;
|
|
@@ -636,13 +689,13 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
636
689
|
onClose: this.closeTypeFilter
|
|
637
690
|
}, /*#__PURE__*/React__default['default'].createElement(Components$2.Tag, {
|
|
638
691
|
onClick: function onClick() {
|
|
639
|
-
|
|
692
|
+
_this7.selectTypeFilter('circle');
|
|
640
693
|
},
|
|
641
694
|
text: "Circle",
|
|
642
695
|
className: "marginRight-10"
|
|
643
696
|
}), /*#__PURE__*/React__default['default'].createElement(Components$2.Tag, {
|
|
644
697
|
onClick: function onClick() {
|
|
645
|
-
|
|
698
|
+
_this7.selectTypeFilter('private');
|
|
646
699
|
},
|
|
647
700
|
text: "Private Message"
|
|
648
701
|
}));
|
|
@@ -650,7 +703,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
650
703
|
}, {
|
|
651
704
|
key: "render",
|
|
652
705
|
value: function render() {
|
|
653
|
-
var
|
|
706
|
+
var _this8 = this;
|
|
654
707
|
|
|
655
708
|
return /*#__PURE__*/React__default['default'].createElement("div", null, this.renderTypeFilterPopup(), this.renderUserFilterPopup(), /*#__PURE__*/React__default['default'].createElement(Components$2.Header, null, this.canAddNew() && /*#__PURE__*/React__default['default'].createElement(Components$2.AddButton, {
|
|
656
709
|
onClick: this.onAddNew,
|
|
@@ -674,7 +727,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
674
727
|
width: 50
|
|
675
728
|
}
|
|
676
729
|
}))), /*#__PURE__*/React__default['default'].createElement("tbody", null, this.getCircles().map(function (circle) {
|
|
677
|
-
return
|
|
730
|
+
return _this8.renderRow(circle);
|
|
678
731
|
}))), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
679
732
|
className: "hub_tidioPadding"
|
|
680
733
|
})));
|
|
@@ -695,7 +748,8 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
695
748
|
};
|
|
696
749
|
|
|
697
750
|
var Circles$1 = reactRedux.connect(mapStateToProps$2, {
|
|
698
|
-
circlesLoaded: circlesLoaded
|
|
751
|
+
circlesLoaded: circlesLoaded,
|
|
752
|
+
circleRemoved: circleRemoved
|
|
699
753
|
})(Circles);
|
|
700
754
|
|
|
701
755
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
@@ -2561,6 +2615,13 @@ var CircleReducer = (function () {
|
|
|
2561
2615
|
})
|
|
2562
2616
|
});
|
|
2563
2617
|
|
|
2618
|
+
case CIRCLE_REMOVED:
|
|
2619
|
+
return _objectSpread$2(_objectSpread$2({}, state), {}, {
|
|
2620
|
+
circles: ___default['default'].filter(state.circles, function (c) {
|
|
2621
|
+
return c.Id !== action.payload;
|
|
2622
|
+
})
|
|
2623
|
+
});
|
|
2624
|
+
|
|
2564
2625
|
default:
|
|
2565
2626
|
return state;
|
|
2566
2627
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -85,6 +85,7 @@ var FeatureConfig = {
|
|
|
85
85
|
|
|
86
86
|
var CIRCLES_LOADED = 'CIRCLES_LOADED';
|
|
87
87
|
var CIRCLE_UPDATED = 'CIRCLE_UPDATED';
|
|
88
|
+
var CIRCLE_REMOVED = 'CIRCLE_REMOVED';
|
|
88
89
|
|
|
89
90
|
var circlesLoaded = function circlesLoaded(circles) {
|
|
90
91
|
return {
|
|
@@ -98,6 +99,12 @@ var circleUpdated = function circleUpdated(circle) {
|
|
|
98
99
|
payload: circle
|
|
99
100
|
};
|
|
100
101
|
};
|
|
102
|
+
var circleRemoved = function circleRemoved(circleId) {
|
|
103
|
+
return {
|
|
104
|
+
type: CIRCLE_REMOVED,
|
|
105
|
+
payload: circleId
|
|
106
|
+
};
|
|
107
|
+
};
|
|
101
108
|
|
|
102
109
|
var Helper$3 = PlussCore.Helper,
|
|
103
110
|
Session$3 = PlussCore.Session;
|
|
@@ -150,6 +157,15 @@ var circleActions = {
|
|
|
150
157
|
}
|
|
151
158
|
});
|
|
152
159
|
},
|
|
160
|
+
delete: function _delete(circleId) {
|
|
161
|
+
return Session$3.authedFunction({
|
|
162
|
+
method: 'POST',
|
|
163
|
+
url: Helper$3.getUrl('circles', 'update/delete'),
|
|
164
|
+
data: {
|
|
165
|
+
circleId: circleId
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
},
|
|
153
169
|
addAdmin: function addAdmin(circleId, userId) {
|
|
154
170
|
return Session$3.authedFunction({
|
|
155
171
|
method: 'POST',
|
|
@@ -382,6 +398,18 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
382
398
|
_this.setState(stateChange);
|
|
383
399
|
});
|
|
384
400
|
|
|
401
|
+
_defineProperty(_assertThisInitialized(_this), "removeCircle", function (circle) {
|
|
402
|
+
if (window.confirm("Are you sure you want to delete that circle? You will no longer be able to access the messages in the circle.")) {
|
|
403
|
+
_this.props.circleRemoved(circle.Id);
|
|
404
|
+
|
|
405
|
+
circleActions.delete(circle.Id).then(function (res) {
|
|
406
|
+
_this.getData();
|
|
407
|
+
}).catch(function (res) {
|
|
408
|
+
alert('Something went wrong with the request. Please try again.');
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
|
|
385
413
|
_defineProperty(_assertThisInitialized(_this), "getTypeFilterText", function (type) {
|
|
386
414
|
if (type === 'private') {
|
|
387
415
|
return 'Private Message';
|
|
@@ -458,13 +486,17 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
458
486
|
}
|
|
459
487
|
}, {
|
|
460
488
|
key: "validateCircleAdmin",
|
|
461
|
-
value: function validateCircleAdmin(circle) {
|
|
489
|
+
value: function validateCircleAdmin(circle, onlyCreator) {
|
|
462
490
|
var _this4 = this;
|
|
463
491
|
|
|
464
492
|
if (Session$2.validateAccess(this.props.auth.site, 'circles', this.props.auth)) {
|
|
465
493
|
return true;
|
|
466
494
|
}
|
|
467
495
|
|
|
496
|
+
if (onlyCreator) {
|
|
497
|
+
return circle.Creator && circle.Creator.userId === this.props.user.Id || circle.CreatorId === this.props.user.Id;
|
|
498
|
+
}
|
|
499
|
+
|
|
468
500
|
return _.some(circle.Audience, function (user) {
|
|
469
501
|
return user.userId === _this4.props.user.Id && user.isAdmin;
|
|
470
502
|
});
|
|
@@ -472,6 +504,8 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
472
504
|
}, {
|
|
473
505
|
key: "renderRow",
|
|
474
506
|
value: function renderRow(circle) {
|
|
507
|
+
var _this5 = this;
|
|
508
|
+
|
|
475
509
|
return /*#__PURE__*/React.createElement("tr", {
|
|
476
510
|
key: circle.Id
|
|
477
511
|
}, /*#__PURE__*/React.createElement("td", {
|
|
@@ -485,7 +519,14 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
485
519
|
hoverText: user.displayName,
|
|
486
520
|
containerClass: "circleTableProfilePic"
|
|
487
521
|
});
|
|
488
|
-
})), /*#__PURE__*/React.createElement("td",
|
|
522
|
+
})), /*#__PURE__*/React.createElement("td", {
|
|
523
|
+
className: "table-options"
|
|
524
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
525
|
+
style: {
|
|
526
|
+
display: 'flex',
|
|
527
|
+
alignItems: 'center'
|
|
528
|
+
}
|
|
529
|
+
}, this.validateCircleAdmin(circle) && !circle.IsPrivate && /*#__PURE__*/React.createElement(Link, {
|
|
489
530
|
to: "/circles/edit/".concat(circle.Id)
|
|
490
531
|
}, /*#__PURE__*/React.createElement(FontAwesome, {
|
|
491
532
|
style: {
|
|
@@ -495,7 +536,19 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
495
536
|
cursor: 'pointer'
|
|
496
537
|
},
|
|
497
538
|
name: "pencil"
|
|
498
|
-
})))
|
|
539
|
+
})), this.validateCircleAdmin(circle, true) && !circle.IsPrivate && /*#__PURE__*/React.createElement("a", {
|
|
540
|
+
onClick: function onClick() {
|
|
541
|
+
_this5.removeCircle(circle);
|
|
542
|
+
}
|
|
543
|
+
}, /*#__PURE__*/React.createElement(FontAwesome, {
|
|
544
|
+
style: {
|
|
545
|
+
fontSize: 20,
|
|
546
|
+
padding: 5,
|
|
547
|
+
marginLeft: 12,
|
|
548
|
+
cursor: 'pointer'
|
|
549
|
+
},
|
|
550
|
+
name: "minus-circle"
|
|
551
|
+
})))));
|
|
499
552
|
}
|
|
500
553
|
}, {
|
|
501
554
|
key: "renderFilters",
|
|
@@ -544,7 +597,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
544
597
|
}, {
|
|
545
598
|
key: "renderUserFilterPopup",
|
|
546
599
|
value: function renderUserFilterPopup() {
|
|
547
|
-
var
|
|
600
|
+
var _this6 = this;
|
|
548
601
|
|
|
549
602
|
if (!this.state.userFilterOpen) {
|
|
550
603
|
return null;
|
|
@@ -564,7 +617,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
564
617
|
placeholder: "Enter name",
|
|
565
618
|
value: this.state.userSearch,
|
|
566
619
|
onChange: function onChange(e) {
|
|
567
|
-
return
|
|
620
|
+
return _this6.onHandleChange(e);
|
|
568
621
|
},
|
|
569
622
|
alwaysShowLabel: true
|
|
570
623
|
}), this.getUsers().map(function (user) {
|
|
@@ -572,7 +625,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
572
625
|
key: user.userId,
|
|
573
626
|
user: user,
|
|
574
627
|
onClick: function onClick() {
|
|
575
|
-
|
|
628
|
+
_this6.selectUserFilter(user);
|
|
576
629
|
}
|
|
577
630
|
});
|
|
578
631
|
}));
|
|
@@ -580,7 +633,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
580
633
|
}, {
|
|
581
634
|
key: "renderTypeFilterPopup",
|
|
582
635
|
value: function renderTypeFilterPopup() {
|
|
583
|
-
var
|
|
636
|
+
var _this7 = this;
|
|
584
637
|
|
|
585
638
|
if (!this.state.typeFilterOpen) {
|
|
586
639
|
return null;
|
|
@@ -594,13 +647,13 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
594
647
|
onClose: this.closeTypeFilter
|
|
595
648
|
}, /*#__PURE__*/React.createElement(Components$2.Tag, {
|
|
596
649
|
onClick: function onClick() {
|
|
597
|
-
|
|
650
|
+
_this7.selectTypeFilter('circle');
|
|
598
651
|
},
|
|
599
652
|
text: "Circle",
|
|
600
653
|
className: "marginRight-10"
|
|
601
654
|
}), /*#__PURE__*/React.createElement(Components$2.Tag, {
|
|
602
655
|
onClick: function onClick() {
|
|
603
|
-
|
|
656
|
+
_this7.selectTypeFilter('private');
|
|
604
657
|
},
|
|
605
658
|
text: "Private Message"
|
|
606
659
|
}));
|
|
@@ -608,7 +661,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
608
661
|
}, {
|
|
609
662
|
key: "render",
|
|
610
663
|
value: function render() {
|
|
611
|
-
var
|
|
664
|
+
var _this8 = this;
|
|
612
665
|
|
|
613
666
|
return /*#__PURE__*/React.createElement("div", null, this.renderTypeFilterPopup(), this.renderUserFilterPopup(), /*#__PURE__*/React.createElement(Components$2.Header, null, this.canAddNew() && /*#__PURE__*/React.createElement(Components$2.AddButton, {
|
|
614
667
|
onClick: this.onAddNew,
|
|
@@ -632,7 +685,7 @@ var Circles = /*#__PURE__*/function (_Component) {
|
|
|
632
685
|
width: 50
|
|
633
686
|
}
|
|
634
687
|
}))), /*#__PURE__*/React.createElement("tbody", null, this.getCircles().map(function (circle) {
|
|
635
|
-
return
|
|
688
|
+
return _this8.renderRow(circle);
|
|
636
689
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
637
690
|
className: "hub_tidioPadding"
|
|
638
691
|
})));
|
|
@@ -653,7 +706,8 @@ var mapStateToProps$2 = function mapStateToProps(state) {
|
|
|
653
706
|
};
|
|
654
707
|
|
|
655
708
|
var Circles$1 = connect(mapStateToProps$2, {
|
|
656
|
-
circlesLoaded: circlesLoaded
|
|
709
|
+
circlesLoaded: circlesLoaded,
|
|
710
|
+
circleRemoved: circleRemoved
|
|
657
711
|
})(Circles);
|
|
658
712
|
|
|
659
713
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -2519,6 +2573,13 @@ var CircleReducer = (function () {
|
|
|
2519
2573
|
})
|
|
2520
2574
|
});
|
|
2521
2575
|
|
|
2576
|
+
case CIRCLE_REMOVED:
|
|
2577
|
+
return _objectSpread$2(_objectSpread$2({}, state), {}, {
|
|
2578
|
+
circles: _.filter(state.circles, function (c) {
|
|
2579
|
+
return c.Id !== action.payload;
|
|
2580
|
+
})
|
|
2581
|
+
});
|
|
2582
|
+
|
|
2522
2583
|
default:
|
|
2523
2584
|
return state;
|
|
2524
2585
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -109,6 +109,7 @@
|
|
|
109
109
|
|
|
110
110
|
var CIRCLES_LOADED = 'CIRCLES_LOADED';
|
|
111
111
|
var CIRCLE_UPDATED = 'CIRCLE_UPDATED';
|
|
112
|
+
var CIRCLE_REMOVED = 'CIRCLE_REMOVED';
|
|
112
113
|
|
|
113
114
|
var circlesLoaded = function circlesLoaded(circles) {
|
|
114
115
|
return {
|
|
@@ -122,6 +123,12 @@
|
|
|
122
123
|
payload: circle
|
|
123
124
|
};
|
|
124
125
|
};
|
|
126
|
+
var circleRemoved = function circleRemoved(circleId) {
|
|
127
|
+
return {
|
|
128
|
+
type: CIRCLE_REMOVED,
|
|
129
|
+
payload: circleId
|
|
130
|
+
};
|
|
131
|
+
};
|
|
125
132
|
|
|
126
133
|
var Helper$3 = PlussCore__namespace.Helper,
|
|
127
134
|
Session$3 = PlussCore__namespace.Session;
|
|
@@ -174,6 +181,15 @@
|
|
|
174
181
|
}
|
|
175
182
|
});
|
|
176
183
|
},
|
|
184
|
+
delete: function _delete(circleId) {
|
|
185
|
+
return Session$3.authedFunction({
|
|
186
|
+
method: 'POST',
|
|
187
|
+
url: Helper$3.getUrl('circles', 'update/delete'),
|
|
188
|
+
data: {
|
|
189
|
+
circleId: circleId
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
},
|
|
177
193
|
addAdmin: function addAdmin(circleId, userId) {
|
|
178
194
|
return Session$3.authedFunction({
|
|
179
195
|
method: 'POST',
|
|
@@ -406,6 +422,18 @@
|
|
|
406
422
|
_this.setState(stateChange);
|
|
407
423
|
});
|
|
408
424
|
|
|
425
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "removeCircle", function (circle) {
|
|
426
|
+
if (window.confirm("Are you sure you want to delete that circle? You will no longer be able to access the messages in the circle.")) {
|
|
427
|
+
_this.props.circleRemoved(circle.Id);
|
|
428
|
+
|
|
429
|
+
circleActions.delete(circle.Id).then(function (res) {
|
|
430
|
+
_this.getData();
|
|
431
|
+
}).catch(function (res) {
|
|
432
|
+
alert('Something went wrong with the request. Please try again.');
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
|
|
409
437
|
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "getTypeFilterText", function (type) {
|
|
410
438
|
if (type === 'private') {
|
|
411
439
|
return 'Private Message';
|
|
@@ -482,13 +510,17 @@
|
|
|
482
510
|
}
|
|
483
511
|
}, {
|
|
484
512
|
key: "validateCircleAdmin",
|
|
485
|
-
value: function validateCircleAdmin(circle) {
|
|
513
|
+
value: function validateCircleAdmin(circle, onlyCreator) {
|
|
486
514
|
var _this4 = this;
|
|
487
515
|
|
|
488
516
|
if (Session$2.validateAccess(this.props.auth.site, 'circles', this.props.auth)) {
|
|
489
517
|
return true;
|
|
490
518
|
}
|
|
491
519
|
|
|
520
|
+
if (onlyCreator) {
|
|
521
|
+
return circle.Creator && circle.Creator.userId === this.props.user.Id || circle.CreatorId === this.props.user.Id;
|
|
522
|
+
}
|
|
523
|
+
|
|
492
524
|
return ___default['default'].some(circle.Audience, function (user) {
|
|
493
525
|
return user.userId === _this4.props.user.Id && user.isAdmin;
|
|
494
526
|
});
|
|
@@ -496,6 +528,8 @@
|
|
|
496
528
|
}, {
|
|
497
529
|
key: "renderRow",
|
|
498
530
|
value: function renderRow(circle) {
|
|
531
|
+
var _this5 = this;
|
|
532
|
+
|
|
499
533
|
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
500
534
|
key: circle.Id
|
|
501
535
|
}, /*#__PURE__*/React__default['default'].createElement("td", {
|
|
@@ -509,7 +543,14 @@
|
|
|
509
543
|
hoverText: user.displayName,
|
|
510
544
|
containerClass: "circleTableProfilePic"
|
|
511
545
|
});
|
|
512
|
-
})), /*#__PURE__*/React__default['default'].createElement("td",
|
|
546
|
+
})), /*#__PURE__*/React__default['default'].createElement("td", {
|
|
547
|
+
className: "table-options"
|
|
548
|
+
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
549
|
+
style: {
|
|
550
|
+
display: 'flex',
|
|
551
|
+
alignItems: 'center'
|
|
552
|
+
}
|
|
553
|
+
}, this.validateCircleAdmin(circle) && !circle.IsPrivate && /*#__PURE__*/React__default['default'].createElement(reactRouterDom.Link, {
|
|
513
554
|
to: "/circles/edit/".concat(circle.Id)
|
|
514
555
|
}, /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
515
556
|
style: {
|
|
@@ -519,7 +560,19 @@
|
|
|
519
560
|
cursor: 'pointer'
|
|
520
561
|
},
|
|
521
562
|
name: "pencil"
|
|
522
|
-
})))
|
|
563
|
+
})), this.validateCircleAdmin(circle, true) && !circle.IsPrivate && /*#__PURE__*/React__default['default'].createElement("a", {
|
|
564
|
+
onClick: function onClick() {
|
|
565
|
+
_this5.removeCircle(circle);
|
|
566
|
+
}
|
|
567
|
+
}, /*#__PURE__*/React__default['default'].createElement(FontAwesome__default['default'], {
|
|
568
|
+
style: {
|
|
569
|
+
fontSize: 20,
|
|
570
|
+
padding: 5,
|
|
571
|
+
marginLeft: 12,
|
|
572
|
+
cursor: 'pointer'
|
|
573
|
+
},
|
|
574
|
+
name: "minus-circle"
|
|
575
|
+
})))));
|
|
523
576
|
}
|
|
524
577
|
}, {
|
|
525
578
|
key: "renderFilters",
|
|
@@ -568,7 +621,7 @@
|
|
|
568
621
|
}, {
|
|
569
622
|
key: "renderUserFilterPopup",
|
|
570
623
|
value: function renderUserFilterPopup() {
|
|
571
|
-
var
|
|
624
|
+
var _this6 = this;
|
|
572
625
|
|
|
573
626
|
if (!this.state.userFilterOpen) {
|
|
574
627
|
return null;
|
|
@@ -588,7 +641,7 @@
|
|
|
588
641
|
placeholder: "Enter name",
|
|
589
642
|
value: this.state.userSearch,
|
|
590
643
|
onChange: function onChange(e) {
|
|
591
|
-
return
|
|
644
|
+
return _this6.onHandleChange(e);
|
|
592
645
|
},
|
|
593
646
|
alwaysShowLabel: true
|
|
594
647
|
}), this.getUsers().map(function (user) {
|
|
@@ -596,7 +649,7 @@
|
|
|
596
649
|
key: user.userId,
|
|
597
650
|
user: user,
|
|
598
651
|
onClick: function onClick() {
|
|
599
|
-
|
|
652
|
+
_this6.selectUserFilter(user);
|
|
600
653
|
}
|
|
601
654
|
});
|
|
602
655
|
}));
|
|
@@ -604,7 +657,7 @@
|
|
|
604
657
|
}, {
|
|
605
658
|
key: "renderTypeFilterPopup",
|
|
606
659
|
value: function renderTypeFilterPopup() {
|
|
607
|
-
var
|
|
660
|
+
var _this7 = this;
|
|
608
661
|
|
|
609
662
|
if (!this.state.typeFilterOpen) {
|
|
610
663
|
return null;
|
|
@@ -618,13 +671,13 @@
|
|
|
618
671
|
onClose: this.closeTypeFilter
|
|
619
672
|
}, /*#__PURE__*/React__default['default'].createElement(Components$2.Tag, {
|
|
620
673
|
onClick: function onClick() {
|
|
621
|
-
|
|
674
|
+
_this7.selectTypeFilter('circle');
|
|
622
675
|
},
|
|
623
676
|
text: "Circle",
|
|
624
677
|
className: "marginRight-10"
|
|
625
678
|
}), /*#__PURE__*/React__default['default'].createElement(Components$2.Tag, {
|
|
626
679
|
onClick: function onClick() {
|
|
627
|
-
|
|
680
|
+
_this7.selectTypeFilter('private');
|
|
628
681
|
},
|
|
629
682
|
text: "Private Message"
|
|
630
683
|
}));
|
|
@@ -632,7 +685,7 @@
|
|
|
632
685
|
}, {
|
|
633
686
|
key: "render",
|
|
634
687
|
value: function render() {
|
|
635
|
-
var
|
|
688
|
+
var _this8 = this;
|
|
636
689
|
|
|
637
690
|
return /*#__PURE__*/React__default['default'].createElement("div", null, this.renderTypeFilterPopup(), this.renderUserFilterPopup(), /*#__PURE__*/React__default['default'].createElement(Components$2.Header, null, this.canAddNew() && /*#__PURE__*/React__default['default'].createElement(Components$2.AddButton, {
|
|
638
691
|
onClick: this.onAddNew,
|
|
@@ -656,7 +709,7 @@
|
|
|
656
709
|
width: 50
|
|
657
710
|
}
|
|
658
711
|
}))), /*#__PURE__*/React__default['default'].createElement("tbody", null, this.getCircles().map(function (circle) {
|
|
659
|
-
return
|
|
712
|
+
return _this8.renderRow(circle);
|
|
660
713
|
}))), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
661
714
|
className: "hub_tidioPadding"
|
|
662
715
|
})));
|
|
@@ -677,7 +730,8 @@
|
|
|
677
730
|
};
|
|
678
731
|
|
|
679
732
|
var Circles$1 = reactRedux.connect(mapStateToProps$2, {
|
|
680
|
-
circlesLoaded: circlesLoaded
|
|
733
|
+
circlesLoaded: circlesLoaded,
|
|
734
|
+
circleRemoved: circleRemoved
|
|
681
735
|
})(Circles);
|
|
682
736
|
|
|
683
737
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf__default['default'](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default['default'](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default['default'](this, result); }; }
|
|
@@ -2543,6 +2597,13 @@
|
|
|
2543
2597
|
})
|
|
2544
2598
|
});
|
|
2545
2599
|
|
|
2600
|
+
case CIRCLE_REMOVED:
|
|
2601
|
+
return _objectSpread$2(_objectSpread$2({}, state), {}, {
|
|
2602
|
+
circles: ___default['default'].filter(state.circles, function (c) {
|
|
2603
|
+
return c.Id !== action.payload;
|
|
2604
|
+
})
|
|
2605
|
+
});
|
|
2606
|
+
|
|
2546
2607
|
default:
|
|
2547
2608
|
return state;
|
|
2548
2609
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { CIRCLES_LOADED, CIRCLE_UPDATED } from './types';
|
|
2
|
+
import { CIRCLES_LOADED, CIRCLE_UPDATED, CIRCLE_REMOVED } from './types';
|
|
3
3
|
|
|
4
4
|
export const circlesLoaded = (circles) => {
|
|
5
5
|
return {
|
|
@@ -14,3 +14,10 @@ export const circleUpdated = (circle) => {
|
|
|
14
14
|
payload: circle,
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
|
+
|
|
18
|
+
export const circleRemoved = (circleId) => {
|
|
19
|
+
return {
|
|
20
|
+
type: CIRCLE_REMOVED,
|
|
21
|
+
payload: circleId,
|
|
22
|
+
};
|
|
23
|
+
};
|
package/src/actions/types.js
CHANGED
|
@@ -45,6 +45,15 @@ export const circleActions = {
|
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
|
+
delete: (circleId) => {
|
|
49
|
+
return Session.authedFunction({
|
|
50
|
+
method: 'POST',
|
|
51
|
+
url: Helper.getUrl('circles', 'update/delete'),
|
|
52
|
+
data: {
|
|
53
|
+
circleId,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
},
|
|
48
57
|
addAdmin: (circleId, userId) => {
|
|
49
58
|
return Session.authedFunction({
|
|
50
59
|
method: 'POST',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { CIRCLES_LOADED, CIRCLE_UPDATED } from '../actions/types';
|
|
2
|
+
import { CIRCLES_LOADED, CIRCLE_UPDATED, CIRCLE_REMOVED } from '../actions/types';
|
|
3
3
|
|
|
4
4
|
const INITIAL_STATE = {
|
|
5
5
|
circles: [],
|
|
@@ -11,6 +11,13 @@ export default (state = INITIAL_STATE, action) => {
|
|
|
11
11
|
return { ...state, circles: action.payload };
|
|
12
12
|
case CIRCLE_UPDATED:
|
|
13
13
|
return { ...state, circles: _.uniqBy([action.payload, ...state.circles], (c) => c.Id) };
|
|
14
|
+
case CIRCLE_REMOVED:
|
|
15
|
+
return {
|
|
16
|
+
...state,
|
|
17
|
+
circles: _.filter(state.circles, (c) => {
|
|
18
|
+
return c.Id !== action.payload;
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
14
21
|
default:
|
|
15
22
|
return state;
|
|
16
23
|
}
|
package/src/screens/Circles.js
CHANGED
|
@@ -4,7 +4,7 @@ import _ from 'lodash';
|
|
|
4
4
|
import moment from 'moment';
|
|
5
5
|
import { Link } from 'react-router-dom';
|
|
6
6
|
import { PlussCore } from '../feature.config';
|
|
7
|
-
import { circlesLoaded } from '../actions';
|
|
7
|
+
import { circlesLoaded, circleRemoved } from '../actions';
|
|
8
8
|
import { circleActions } from '../apis';
|
|
9
9
|
import { Table } from 'react-bootstrap';
|
|
10
10
|
import FontAwesome from 'react-fontawesome';
|
|
@@ -76,10 +76,13 @@ class Circles extends Component {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
validateCircleAdmin(circle) {
|
|
79
|
+
validateCircleAdmin(circle, onlyCreator) {
|
|
80
80
|
if (Session.validateAccess(this.props.auth.site, 'circles', this.props.auth)) {
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
|
+
if (onlyCreator) {
|
|
84
|
+
return (circle.Creator && circle.Creator.userId === this.props.user.Id) || circle.CreatorId === this.props.user.Id;
|
|
85
|
+
}
|
|
83
86
|
return _.some(circle.Audience, (user) => {
|
|
84
87
|
return user.userId === this.props.user.Id && user.isAdmin;
|
|
85
88
|
});
|
|
@@ -155,6 +158,20 @@ class Circles extends Component {
|
|
|
155
158
|
this.setState(stateChange);
|
|
156
159
|
};
|
|
157
160
|
|
|
161
|
+
removeCircle = (circle) => {
|
|
162
|
+
if (window.confirm(`Are you sure you want to delete that circle? You will no longer be able to access the messages in the circle.`)) {
|
|
163
|
+
this.props.circleRemoved(circle.Id);
|
|
164
|
+
circleActions
|
|
165
|
+
.delete(circle.Id)
|
|
166
|
+
.then((res) => {
|
|
167
|
+
this.getData();
|
|
168
|
+
})
|
|
169
|
+
.catch((res) => {
|
|
170
|
+
alert('Something went wrong with the request. Please try again.');
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
158
175
|
getTypeFilterText = (type) => {
|
|
159
176
|
if (type === 'private') {
|
|
160
177
|
return 'Private Message';
|
|
@@ -190,20 +207,39 @@ class Circles extends Component {
|
|
|
190
207
|
);
|
|
191
208
|
})}
|
|
192
209
|
</td>
|
|
193
|
-
<td>
|
|
194
|
-
{
|
|
195
|
-
|
|
196
|
-
<
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
210
|
+
<td className="table-options">
|
|
211
|
+
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
212
|
+
{this.validateCircleAdmin(circle) && !circle.IsPrivate && (
|
|
213
|
+
<Link to={`/circles/edit/${circle.Id}`}>
|
|
214
|
+
<FontAwesome
|
|
215
|
+
style={{
|
|
216
|
+
fontSize: 20,
|
|
217
|
+
padding: 5,
|
|
218
|
+
marginLeft: 12,
|
|
219
|
+
cursor: 'pointer',
|
|
220
|
+
}}
|
|
221
|
+
name="pencil"
|
|
222
|
+
/>
|
|
223
|
+
</Link>
|
|
224
|
+
)}
|
|
225
|
+
{this.validateCircleAdmin(circle, true) && !circle.IsPrivate && (
|
|
226
|
+
<a
|
|
227
|
+
onClick={() => {
|
|
228
|
+
this.removeCircle(circle);
|
|
202
229
|
}}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
230
|
+
>
|
|
231
|
+
<FontAwesome
|
|
232
|
+
style={{
|
|
233
|
+
fontSize: 20,
|
|
234
|
+
padding: 5,
|
|
235
|
+
marginLeft: 12,
|
|
236
|
+
cursor: 'pointer',
|
|
237
|
+
}}
|
|
238
|
+
name="minus-circle"
|
|
239
|
+
/>
|
|
240
|
+
</a>
|
|
241
|
+
)}
|
|
242
|
+
</div>
|
|
207
243
|
</td>
|
|
208
244
|
</tr>
|
|
209
245
|
);
|
|
@@ -342,4 +378,4 @@ const mapStateToProps = (state) => {
|
|
|
342
378
|
};
|
|
343
379
|
};
|
|
344
380
|
|
|
345
|
-
export default connect(mapStateToProps, { circlesLoaded })(Circles);
|
|
381
|
+
export default connect(mapStateToProps, { circlesLoaded, circleRemoved })(Circles);
|