@plusscommunities/pluss-core-web 1.2.9 → 1.2.10
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/components/Comment.js +10 -1
- package/src/components/CommentSection.js +55 -2
- package/src/components/Text.js +1 -1
- package/src/helper/helper.js +0 -7
- package/src/helper/index.js +1 -0
- package/src/helper/strings/getFirstName.js +10 -0
package/dist/index.cjs.js
CHANGED
|
@@ -691,6 +691,14 @@ var isVideo = function isVideo(url) {
|
|
|
691
691
|
return ['mov', 'mp4'].includes(extension);
|
|
692
692
|
};
|
|
693
693
|
|
|
694
|
+
var getFirstName = function getFirstName(string) {
|
|
695
|
+
if (___default['default'].isEmpty(string)) {
|
|
696
|
+
return '';
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return string.split(' ')[0];
|
|
700
|
+
};
|
|
701
|
+
|
|
694
702
|
var isEmail = function isEmail(email) {
|
|
695
703
|
if (___default['default'].isEmpty(email)) return false;
|
|
696
704
|
var atpos = email.indexOf('@');
|
|
@@ -839,12 +847,6 @@ var setLocalStorage = function setLocalStorage(key, value, isJson) {
|
|
|
839
847
|
// }
|
|
840
848
|
// return string.charAt(0).toUpperCase() + string.slice(1);
|
|
841
849
|
// };
|
|
842
|
-
// export const getFirstName = (string) => {
|
|
843
|
-
// if (_.isEmpty(string)) {
|
|
844
|
-
// return '';
|
|
845
|
-
// }
|
|
846
|
-
// return string.split(' ')[0];
|
|
847
|
-
// };
|
|
848
850
|
// export const get300 = (url) => {
|
|
849
851
|
// if (!url) {
|
|
850
852
|
// return url;
|
|
@@ -1566,6 +1568,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
1566
1568
|
getFileName: getFileName,
|
|
1567
1569
|
getThumb300: getThumb300,
|
|
1568
1570
|
isVideo: isVideo,
|
|
1571
|
+
getFirstName: getFirstName,
|
|
1569
1572
|
isEmail: isEmail,
|
|
1570
1573
|
isUrl: isUrl,
|
|
1571
1574
|
randomString: randomString,
|
|
@@ -4342,10 +4345,10 @@ var Text = /*#__PURE__*/function (_Component) {
|
|
|
4342
4345
|
}, {
|
|
4343
4346
|
key: "render",
|
|
4344
4347
|
value: function render() {
|
|
4345
|
-
return /*#__PURE__*/React__default['default'].createElement("p", {
|
|
4348
|
+
return /*#__PURE__*/React__default['default'].createElement("p", _extends__default['default']({}, this.props, {
|
|
4346
4349
|
className: "text-".concat(this.props.type).concat(this.getClassName()),
|
|
4347
4350
|
style: this.props.style
|
|
4348
|
-
}, this.props.children);
|
|
4351
|
+
}), this.props.children);
|
|
4349
4352
|
}
|
|
4350
4353
|
}]);
|
|
4351
4354
|
|
|
@@ -4431,8 +4434,8 @@ var Comment = /*#__PURE__*/function (_Component) {
|
|
|
4431
4434
|
}
|
|
4432
4435
|
|
|
4433
4436
|
_createClass__default['default'](Comment, [{
|
|
4434
|
-
key: "
|
|
4435
|
-
value: function
|
|
4437
|
+
key: "renderComment",
|
|
4438
|
+
value: function renderComment() {
|
|
4436
4439
|
var comment = this.props.comment;
|
|
4437
4440
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4438
4441
|
key: comment.Id,
|
|
@@ -4451,6 +4454,11 @@ var Comment = /*#__PURE__*/function (_Component) {
|
|
|
4451
4454
|
className: "comment_time"
|
|
4452
4455
|
}, moment__default['default'].utc(comment.Timestamp).local().format('D MMM YYYY • h:mma'))));
|
|
4453
4456
|
}
|
|
4457
|
+
}, {
|
|
4458
|
+
key: "render",
|
|
4459
|
+
value: function render() {
|
|
4460
|
+
return /*#__PURE__*/React__default['default'].createElement("div", null, this.renderComment(), this.props.bottomContent);
|
|
4461
|
+
}
|
|
4454
4462
|
}]);
|
|
4455
4463
|
|
|
4456
4464
|
return Comment;
|
|
@@ -4501,6 +4509,58 @@ var CommentSection = /*#__PURE__*/function (_Component) {
|
|
|
4501
4509
|
}, _callee);
|
|
4502
4510
|
})));
|
|
4503
4511
|
|
|
4512
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "getComments", function () {
|
|
4513
|
+
if (!_this.props.onlyParents) {
|
|
4514
|
+
return _this.props.comments;
|
|
4515
|
+
}
|
|
4516
|
+
|
|
4517
|
+
return ___default['default'].filter(_this.props.comments, function (c) {
|
|
4518
|
+
return !c.ParentId;
|
|
4519
|
+
});
|
|
4520
|
+
});
|
|
4521
|
+
|
|
4522
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "renderReplyText", function (c) {
|
|
4523
|
+
if (!_this.props.onOpenThread) {
|
|
4524
|
+
return null;
|
|
4525
|
+
}
|
|
4526
|
+
|
|
4527
|
+
var threadComments = ___default['default'].filter(_this.props.comments, function (innerC) {
|
|
4528
|
+
return innerC.ParentId === c.Id;
|
|
4529
|
+
});
|
|
4530
|
+
|
|
4531
|
+
if (___default['default'].isEmpty(threadComments)) {
|
|
4532
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4533
|
+
className: "comment_reply"
|
|
4534
|
+
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
4535
|
+
className: "comment_reply_button",
|
|
4536
|
+
type: "button",
|
|
4537
|
+
onClick: function onClick() {
|
|
4538
|
+
_this.props.onOpenThread(c);
|
|
4539
|
+
}
|
|
4540
|
+
}, "Reply to ".concat(getFirstName(c.User ? c.User.displayName : 'comment'))));
|
|
4541
|
+
}
|
|
4542
|
+
|
|
4543
|
+
var profilePics = ___default['default'].take(___default['default'].uniqBy(threadComments, function (c) {
|
|
4544
|
+
return c.UserId;
|
|
4545
|
+
}), 3);
|
|
4546
|
+
|
|
4547
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4548
|
+
className: "comment_reply comment_reply-hasReplies"
|
|
4549
|
+
}, profilePics.map(function (c) {
|
|
4550
|
+
return /*#__PURE__*/React__default['default'].createElement(ProfilePic, {
|
|
4551
|
+
className: "comment_reply_profilePic",
|
|
4552
|
+
size: 20,
|
|
4553
|
+
image: c.User.profilePic
|
|
4554
|
+
});
|
|
4555
|
+
}), /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
4556
|
+
className: "comment_reply_button",
|
|
4557
|
+
type: "button",
|
|
4558
|
+
onClick: function onClick() {
|
|
4559
|
+
_this.props.onOpenThread(c);
|
|
4560
|
+
}
|
|
4561
|
+
}, "".concat(threadComments.length, " repl").concat(getPluralOptions(threadComments.length, 'y', 'ies'))));
|
|
4562
|
+
});
|
|
4563
|
+
|
|
4504
4564
|
_this.state = {
|
|
4505
4565
|
commentInput: ''
|
|
4506
4566
|
};
|
|
@@ -4517,10 +4577,11 @@ var CommentSection = /*#__PURE__*/function (_Component) {
|
|
|
4517
4577
|
className: "marginBottom-16"
|
|
4518
4578
|
}, "Comments"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4519
4579
|
className: "commentSection"
|
|
4520
|
-
}, this.
|
|
4580
|
+
}, this.getComments().map(function (c) {
|
|
4521
4581
|
return /*#__PURE__*/React__default['default'].createElement(Comment, {
|
|
4522
4582
|
key: c.Id,
|
|
4523
|
-
comment: c
|
|
4583
|
+
comment: c,
|
|
4584
|
+
bottomContent: _this2.renderReplyText(c)
|
|
4524
4585
|
});
|
|
4525
4586
|
})), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4526
4587
|
className: "commentReply"
|
package/dist/index.esm.js
CHANGED
|
@@ -664,6 +664,14 @@ var isVideo = function isVideo(url) {
|
|
|
664
664
|
return ['mov', 'mp4'].includes(extension);
|
|
665
665
|
};
|
|
666
666
|
|
|
667
|
+
var getFirstName = function getFirstName(string) {
|
|
668
|
+
if (_.isEmpty(string)) {
|
|
669
|
+
return '';
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
return string.split(' ')[0];
|
|
673
|
+
};
|
|
674
|
+
|
|
667
675
|
var isEmail = function isEmail(email) {
|
|
668
676
|
if (_.isEmpty(email)) return false;
|
|
669
677
|
var atpos = email.indexOf('@');
|
|
@@ -812,12 +820,6 @@ var setLocalStorage = function setLocalStorage(key, value, isJson) {
|
|
|
812
820
|
// }
|
|
813
821
|
// return string.charAt(0).toUpperCase() + string.slice(1);
|
|
814
822
|
// };
|
|
815
|
-
// export const getFirstName = (string) => {
|
|
816
|
-
// if (_.isEmpty(string)) {
|
|
817
|
-
// return '';
|
|
818
|
-
// }
|
|
819
|
-
// return string.split(' ')[0];
|
|
820
|
-
// };
|
|
821
823
|
// export const get300 = (url) => {
|
|
822
824
|
// if (!url) {
|
|
823
825
|
// return url;
|
|
@@ -1539,6 +1541,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
1539
1541
|
getFileName: getFileName,
|
|
1540
1542
|
getThumb300: getThumb300,
|
|
1541
1543
|
isVideo: isVideo,
|
|
1544
|
+
getFirstName: getFirstName,
|
|
1542
1545
|
isEmail: isEmail,
|
|
1543
1546
|
isUrl: isUrl,
|
|
1544
1547
|
randomString: randomString,
|
|
@@ -4315,10 +4318,10 @@ var Text = /*#__PURE__*/function (_Component) {
|
|
|
4315
4318
|
}, {
|
|
4316
4319
|
key: "render",
|
|
4317
4320
|
value: function render() {
|
|
4318
|
-
return /*#__PURE__*/React.createElement("p", {
|
|
4321
|
+
return /*#__PURE__*/React.createElement("p", _extends({}, this.props, {
|
|
4319
4322
|
className: "text-".concat(this.props.type).concat(this.getClassName()),
|
|
4320
4323
|
style: this.props.style
|
|
4321
|
-
}, this.props.children);
|
|
4324
|
+
}), this.props.children);
|
|
4322
4325
|
}
|
|
4323
4326
|
}]);
|
|
4324
4327
|
|
|
@@ -4404,8 +4407,8 @@ var Comment = /*#__PURE__*/function (_Component) {
|
|
|
4404
4407
|
}
|
|
4405
4408
|
|
|
4406
4409
|
_createClass(Comment, [{
|
|
4407
|
-
key: "
|
|
4408
|
-
value: function
|
|
4410
|
+
key: "renderComment",
|
|
4411
|
+
value: function renderComment() {
|
|
4409
4412
|
var comment = this.props.comment;
|
|
4410
4413
|
return /*#__PURE__*/React.createElement("div", {
|
|
4411
4414
|
key: comment.Id,
|
|
@@ -4424,6 +4427,11 @@ var Comment = /*#__PURE__*/function (_Component) {
|
|
|
4424
4427
|
className: "comment_time"
|
|
4425
4428
|
}, moment.utc(comment.Timestamp).local().format('D MMM YYYY • h:mma'))));
|
|
4426
4429
|
}
|
|
4430
|
+
}, {
|
|
4431
|
+
key: "render",
|
|
4432
|
+
value: function render() {
|
|
4433
|
+
return /*#__PURE__*/React.createElement("div", null, this.renderComment(), this.props.bottomContent);
|
|
4434
|
+
}
|
|
4427
4435
|
}]);
|
|
4428
4436
|
|
|
4429
4437
|
return Comment;
|
|
@@ -4474,6 +4482,58 @@ var CommentSection = /*#__PURE__*/function (_Component) {
|
|
|
4474
4482
|
}, _callee);
|
|
4475
4483
|
})));
|
|
4476
4484
|
|
|
4485
|
+
_defineProperty(_assertThisInitialized(_this), "getComments", function () {
|
|
4486
|
+
if (!_this.props.onlyParents) {
|
|
4487
|
+
return _this.props.comments;
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4490
|
+
return _.filter(_this.props.comments, function (c) {
|
|
4491
|
+
return !c.ParentId;
|
|
4492
|
+
});
|
|
4493
|
+
});
|
|
4494
|
+
|
|
4495
|
+
_defineProperty(_assertThisInitialized(_this), "renderReplyText", function (c) {
|
|
4496
|
+
if (!_this.props.onOpenThread) {
|
|
4497
|
+
return null;
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4500
|
+
var threadComments = _.filter(_this.props.comments, function (innerC) {
|
|
4501
|
+
return innerC.ParentId === c.Id;
|
|
4502
|
+
});
|
|
4503
|
+
|
|
4504
|
+
if (_.isEmpty(threadComments)) {
|
|
4505
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4506
|
+
className: "comment_reply"
|
|
4507
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
4508
|
+
className: "comment_reply_button",
|
|
4509
|
+
type: "button",
|
|
4510
|
+
onClick: function onClick() {
|
|
4511
|
+
_this.props.onOpenThread(c);
|
|
4512
|
+
}
|
|
4513
|
+
}, "Reply to ".concat(getFirstName(c.User ? c.User.displayName : 'comment'))));
|
|
4514
|
+
}
|
|
4515
|
+
|
|
4516
|
+
var profilePics = _.take(_.uniqBy(threadComments, function (c) {
|
|
4517
|
+
return c.UserId;
|
|
4518
|
+
}), 3);
|
|
4519
|
+
|
|
4520
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4521
|
+
className: "comment_reply comment_reply-hasReplies"
|
|
4522
|
+
}, profilePics.map(function (c) {
|
|
4523
|
+
return /*#__PURE__*/React.createElement(ProfilePic, {
|
|
4524
|
+
className: "comment_reply_profilePic",
|
|
4525
|
+
size: 20,
|
|
4526
|
+
image: c.User.profilePic
|
|
4527
|
+
});
|
|
4528
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
4529
|
+
className: "comment_reply_button",
|
|
4530
|
+
type: "button",
|
|
4531
|
+
onClick: function onClick() {
|
|
4532
|
+
_this.props.onOpenThread(c);
|
|
4533
|
+
}
|
|
4534
|
+
}, "".concat(threadComments.length, " repl").concat(getPluralOptions(threadComments.length, 'y', 'ies'))));
|
|
4535
|
+
});
|
|
4536
|
+
|
|
4477
4537
|
_this.state = {
|
|
4478
4538
|
commentInput: ''
|
|
4479
4539
|
};
|
|
@@ -4490,10 +4550,11 @@ var CommentSection = /*#__PURE__*/function (_Component) {
|
|
|
4490
4550
|
className: "marginBottom-16"
|
|
4491
4551
|
}, "Comments"), /*#__PURE__*/React.createElement("div", {
|
|
4492
4552
|
className: "commentSection"
|
|
4493
|
-
}, this.
|
|
4553
|
+
}, this.getComments().map(function (c) {
|
|
4494
4554
|
return /*#__PURE__*/React.createElement(Comment, {
|
|
4495
4555
|
key: c.Id,
|
|
4496
|
-
comment: c
|
|
4556
|
+
comment: c,
|
|
4557
|
+
bottomContent: _this2.renderReplyText(c)
|
|
4497
4558
|
});
|
|
4498
4559
|
})), /*#__PURE__*/React.createElement("div", {
|
|
4499
4560
|
className: "commentReply"
|
package/dist/index.umd.js
CHANGED
|
@@ -666,6 +666,14 @@
|
|
|
666
666
|
return ['mov', 'mp4'].includes(extension);
|
|
667
667
|
};
|
|
668
668
|
|
|
669
|
+
var getFirstName = function getFirstName(string) {
|
|
670
|
+
if (___default['default'].isEmpty(string)) {
|
|
671
|
+
return '';
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
return string.split(' ')[0];
|
|
675
|
+
};
|
|
676
|
+
|
|
669
677
|
var isEmail = function isEmail(email) {
|
|
670
678
|
if (___default['default'].isEmpty(email)) return false;
|
|
671
679
|
var atpos = email.indexOf('@');
|
|
@@ -814,12 +822,6 @@
|
|
|
814
822
|
// }
|
|
815
823
|
// return string.charAt(0).toUpperCase() + string.slice(1);
|
|
816
824
|
// };
|
|
817
|
-
// export const getFirstName = (string) => {
|
|
818
|
-
// if (_.isEmpty(string)) {
|
|
819
|
-
// return '';
|
|
820
|
-
// }
|
|
821
|
-
// return string.split(' ')[0];
|
|
822
|
-
// };
|
|
823
825
|
// export const get300 = (url) => {
|
|
824
826
|
// if (!url) {
|
|
825
827
|
// return url;
|
|
@@ -1541,6 +1543,7 @@
|
|
|
1541
1543
|
getFileName: getFileName,
|
|
1542
1544
|
getThumb300: getThumb300,
|
|
1543
1545
|
isVideo: isVideo,
|
|
1546
|
+
getFirstName: getFirstName,
|
|
1544
1547
|
isEmail: isEmail,
|
|
1545
1548
|
isUrl: isUrl,
|
|
1546
1549
|
randomString: randomString,
|
|
@@ -4317,10 +4320,10 @@
|
|
|
4317
4320
|
}, {
|
|
4318
4321
|
key: "render",
|
|
4319
4322
|
value: function render() {
|
|
4320
|
-
return /*#__PURE__*/React__default['default'].createElement("p", {
|
|
4323
|
+
return /*#__PURE__*/React__default['default'].createElement("p", _extends__default['default']({}, this.props, {
|
|
4321
4324
|
className: "text-".concat(this.props.type).concat(this.getClassName()),
|
|
4322
4325
|
style: this.props.style
|
|
4323
|
-
}, this.props.children);
|
|
4326
|
+
}), this.props.children);
|
|
4324
4327
|
}
|
|
4325
4328
|
}]);
|
|
4326
4329
|
|
|
@@ -4406,8 +4409,8 @@
|
|
|
4406
4409
|
}
|
|
4407
4410
|
|
|
4408
4411
|
_createClass__default['default'](Comment, [{
|
|
4409
|
-
key: "
|
|
4410
|
-
value: function
|
|
4412
|
+
key: "renderComment",
|
|
4413
|
+
value: function renderComment() {
|
|
4411
4414
|
var comment = this.props.comment;
|
|
4412
4415
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4413
4416
|
key: comment.Id,
|
|
@@ -4426,6 +4429,11 @@
|
|
|
4426
4429
|
className: "comment_time"
|
|
4427
4430
|
}, moment__default['default'].utc(comment.Timestamp).local().format('D MMM YYYY • h:mma'))));
|
|
4428
4431
|
}
|
|
4432
|
+
}, {
|
|
4433
|
+
key: "render",
|
|
4434
|
+
value: function render() {
|
|
4435
|
+
return /*#__PURE__*/React__default['default'].createElement("div", null, this.renderComment(), this.props.bottomContent);
|
|
4436
|
+
}
|
|
4429
4437
|
}]);
|
|
4430
4438
|
|
|
4431
4439
|
return Comment;
|
|
@@ -4476,6 +4484,58 @@
|
|
|
4476
4484
|
}, _callee);
|
|
4477
4485
|
})));
|
|
4478
4486
|
|
|
4487
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "getComments", function () {
|
|
4488
|
+
if (!_this.props.onlyParents) {
|
|
4489
|
+
return _this.props.comments;
|
|
4490
|
+
}
|
|
4491
|
+
|
|
4492
|
+
return ___default['default'].filter(_this.props.comments, function (c) {
|
|
4493
|
+
return !c.ParentId;
|
|
4494
|
+
});
|
|
4495
|
+
});
|
|
4496
|
+
|
|
4497
|
+
_defineProperty__default['default'](_assertThisInitialized__default['default'](_this), "renderReplyText", function (c) {
|
|
4498
|
+
if (!_this.props.onOpenThread) {
|
|
4499
|
+
return null;
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
var threadComments = ___default['default'].filter(_this.props.comments, function (innerC) {
|
|
4503
|
+
return innerC.ParentId === c.Id;
|
|
4504
|
+
});
|
|
4505
|
+
|
|
4506
|
+
if (___default['default'].isEmpty(threadComments)) {
|
|
4507
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4508
|
+
className: "comment_reply"
|
|
4509
|
+
}, /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
4510
|
+
className: "comment_reply_button",
|
|
4511
|
+
type: "button",
|
|
4512
|
+
onClick: function onClick() {
|
|
4513
|
+
_this.props.onOpenThread(c);
|
|
4514
|
+
}
|
|
4515
|
+
}, "Reply to ".concat(getFirstName(c.User ? c.User.displayName : 'comment'))));
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4518
|
+
var profilePics = ___default['default'].take(___default['default'].uniqBy(threadComments, function (c) {
|
|
4519
|
+
return c.UserId;
|
|
4520
|
+
}), 3);
|
|
4521
|
+
|
|
4522
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4523
|
+
className: "comment_reply comment_reply-hasReplies"
|
|
4524
|
+
}, profilePics.map(function (c) {
|
|
4525
|
+
return /*#__PURE__*/React__default['default'].createElement(ProfilePic, {
|
|
4526
|
+
className: "comment_reply_profilePic",
|
|
4527
|
+
size: 20,
|
|
4528
|
+
image: c.User.profilePic
|
|
4529
|
+
});
|
|
4530
|
+
}), /*#__PURE__*/React__default['default'].createElement(Text, {
|
|
4531
|
+
className: "comment_reply_button",
|
|
4532
|
+
type: "button",
|
|
4533
|
+
onClick: function onClick() {
|
|
4534
|
+
_this.props.onOpenThread(c);
|
|
4535
|
+
}
|
|
4536
|
+
}, "".concat(threadComments.length, " repl").concat(getPluralOptions(threadComments.length, 'y', 'ies'))));
|
|
4537
|
+
});
|
|
4538
|
+
|
|
4479
4539
|
_this.state = {
|
|
4480
4540
|
commentInput: ''
|
|
4481
4541
|
};
|
|
@@ -4492,10 +4552,11 @@
|
|
|
4492
4552
|
className: "marginBottom-16"
|
|
4493
4553
|
}, "Comments"), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4494
4554
|
className: "commentSection"
|
|
4495
|
-
}, this.
|
|
4555
|
+
}, this.getComments().map(function (c) {
|
|
4496
4556
|
return /*#__PURE__*/React__default['default'].createElement(Comment, {
|
|
4497
4557
|
key: c.Id,
|
|
4498
|
-
comment: c
|
|
4558
|
+
comment: c,
|
|
4559
|
+
bottomContent: _this2.renderReplyText(c)
|
|
4499
4560
|
});
|
|
4500
4561
|
})), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4501
4562
|
className: "commentReply"
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import { toParagraphed } from '../helper';
|
|
|
4
4
|
import { ProfilePic } from './ProfilePic';
|
|
5
5
|
|
|
6
6
|
class Comment extends Component {
|
|
7
|
-
|
|
7
|
+
renderComment() {
|
|
8
8
|
const { comment } = this.props;
|
|
9
9
|
return (
|
|
10
10
|
<div key={comment.Id} className="comment">
|
|
@@ -17,6 +17,15 @@ class Comment extends Component {
|
|
|
17
17
|
</div>
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
render() {
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
{this.renderComment()}
|
|
25
|
+
{this.props.bottomContent}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
20
29
|
}
|
|
21
30
|
|
|
22
31
|
export { Comment };
|
|
@@ -4,6 +4,8 @@ import _ from 'lodash';
|
|
|
4
4
|
import Textarea from 'react-textarea-autosize';
|
|
5
5
|
import { Text } from './Text';
|
|
6
6
|
import { Comment } from './Comment';
|
|
7
|
+
import { getFirstName, getPluralOptions } from '../helper';
|
|
8
|
+
import { ProfilePic } from './ProfilePic';
|
|
7
9
|
|
|
8
10
|
class CommentSection extends Component {
|
|
9
11
|
constructor(props) {
|
|
@@ -26,6 +28,57 @@ class CommentSection extends Component {
|
|
|
26
28
|
this.props.onAddComment(commentInput);
|
|
27
29
|
};
|
|
28
30
|
|
|
31
|
+
getComments = () => {
|
|
32
|
+
if (!this.props.onlyParents) {
|
|
33
|
+
return this.props.comments;
|
|
34
|
+
}
|
|
35
|
+
return _.filter(this.props.comments, (c) => {
|
|
36
|
+
return !c.ParentId;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
renderReplyText = (c) => {
|
|
41
|
+
if (!this.props.onOpenThread) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const threadComments = _.filter(this.props.comments, (innerC) => {
|
|
46
|
+
return innerC.ParentId === c.Id;
|
|
47
|
+
});
|
|
48
|
+
if (_.isEmpty(threadComments)) {
|
|
49
|
+
return (
|
|
50
|
+
<div className="comment_reply">
|
|
51
|
+
<Text
|
|
52
|
+
className="comment_reply_button"
|
|
53
|
+
type="button"
|
|
54
|
+
onClick={() => {
|
|
55
|
+
this.props.onOpenThread(c);
|
|
56
|
+
}}
|
|
57
|
+
>{`Reply to ${getFirstName(c.User ? c.User.displayName : 'comment')}`}</Text>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const profilePics = _.take(
|
|
63
|
+
_.uniqBy(threadComments, (c) => c.UserId),
|
|
64
|
+
3,
|
|
65
|
+
);
|
|
66
|
+
return (
|
|
67
|
+
<div className="comment_reply comment_reply-hasReplies">
|
|
68
|
+
{profilePics.map((c) => {
|
|
69
|
+
return <ProfilePic className="comment_reply_profilePic" size={20} image={c.User.profilePic} />;
|
|
70
|
+
})}
|
|
71
|
+
<Text
|
|
72
|
+
className="comment_reply_button"
|
|
73
|
+
type="button"
|
|
74
|
+
onClick={() => {
|
|
75
|
+
this.props.onOpenThread(c);
|
|
76
|
+
}}
|
|
77
|
+
>{`${threadComments.length} repl${getPluralOptions(threadComments.length, 'y', 'ies')}`}</Text>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
29
82
|
render() {
|
|
30
83
|
return (
|
|
31
84
|
<div>
|
|
@@ -35,8 +88,8 @@ class CommentSection extends Component {
|
|
|
35
88
|
</Text>
|
|
36
89
|
)}
|
|
37
90
|
<div className="commentSection">
|
|
38
|
-
{this.
|
|
39
|
-
<Comment key={c.Id} comment={c} />
|
|
91
|
+
{this.getComments().map((c) => (
|
|
92
|
+
<Comment key={c.Id} comment={c} bottomContent={this.renderReplyText(c)} />
|
|
40
93
|
))}
|
|
41
94
|
</div>
|
|
42
95
|
<div className="commentReply">
|
package/src/components/Text.js
CHANGED
|
@@ -10,7 +10,7 @@ class Text extends Component {
|
|
|
10
10
|
|
|
11
11
|
render() {
|
|
12
12
|
return (
|
|
13
|
-
<p className={`text-${this.props.type}${this.getClassName()}`} style={this.props.style}>
|
|
13
|
+
<p {...this.props} className={`text-${this.props.type}${this.getClassName()}`} style={this.props.style}>
|
|
14
14
|
{this.props.children}
|
|
15
15
|
</p>
|
|
16
16
|
);
|
package/src/helper/helper.js
CHANGED
|
@@ -67,13 +67,6 @@ import moment from 'moment';
|
|
|
67
67
|
// return string.charAt(0).toUpperCase() + string.slice(1);
|
|
68
68
|
// };
|
|
69
69
|
|
|
70
|
-
// export const getFirstName = (string) => {
|
|
71
|
-
// if (_.isEmpty(string)) {
|
|
72
|
-
// return '';
|
|
73
|
-
// }
|
|
74
|
-
// return string.split(' ')[0];
|
|
75
|
-
// };
|
|
76
|
-
|
|
77
70
|
// export const get300 = (url) => {
|
|
78
71
|
// if (!url) {
|
|
79
72
|
// return url;
|
package/src/helper/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export { default as getThumb300 } from './files/getThumb300';
|
|
|
18
18
|
export { default as isVideo } from './files/isVideo';
|
|
19
19
|
|
|
20
20
|
// strings
|
|
21
|
+
export { default as getFirstName } from './strings/getFirstName';
|
|
21
22
|
export { default as isEmail } from './strings/isEmail';
|
|
22
23
|
export { default as isUrl } from './strings/isUrl';
|
|
23
24
|
export { default as randomString } from './strings/randomString';
|