Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

react-cimpress-comment

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cimpress-comment - npm Package Compare versions

Comparing version 0.8.6 to 0.8.7

@@ -9,14 +9,4 @@ 'use strict';

var _FetchClient3 = require('./_FetchClient');
var _FetchClient4 = _interopRequireDefault(_FetchClient3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var fetch = require('fetch-retry');

@@ -26,17 +16,34 @@

var CommentsClient = function (_FetchClient2) {
_inherits(CommentsClient, _FetchClient2);
var CommentsClient = function () {
function CommentsClient(accessToken, resourceUri, commentServiceUrl) {
_classCallCheck(this, CommentsClient);
var _this = _possibleConstructorReturn(this, (CommentsClient.__proto__ || Object.getPrototypeOf(CommentsClient)).call(this, accessToken));
_this.commentServiceUrl = commentServiceUrl || 'https://comment.trdlnk.cimpress.io';
_this.resourceUri = resourceUri;
_this.encodedResourceUri = encodeURIComponent(resourceUri);
return _this;
this.accessToken = accessToken;
this.commentServiceUrl = commentServiceUrl || 'https://comment.trdlnk.cimpress.io';
this.resourceUri = resourceUri;
this.encodedResourceUri = encodeURIComponent(resourceUri);
}
_createClass(CommentsClient, [{
key: 'getDefaultConfig',
value: function getDefaultConfig(method, jsonPayload) {
var headers = new Headers();
headers.append('Authorization', 'Bearer ' + this.accessToken);
headers.append('x-cimpress-comments-client-version', version);
if (method !== 'GET') {
headers.append('Content-Type', 'application/json');
}
return {
method: method,
headers: headers,
mode: 'cors',
cache: 'default',
retries: 3,
retryDela: 500,
retryOn: [429, 500, 502, 503],
body: jsonPayload ? JSON.stringify(jsonPayload) : undefined
};
}
}, {
key: 'getResourceUri',

@@ -65,6 +72,4 @@ value: function getResourceUri(resourceUri) {

var url = this.commentServiceUrl + '/v0/resources/' + this.encodedResourceUri;
var init = this.getDefaultConfig('GET');
init.headers.append('x-cimpress-comments-client-version', version);
return fetch(url, init).then(function (response) {
return fetch(url, this.getDefaultConfig('GET')).then(function (response) {
if (response.status === 200) {

@@ -94,3 +99,3 @@ return response.json().then(function (responseJson) {

value: function postComment(comment, visibility) {
var _this2 = this;
var _this = this;

@@ -102,3 +107,2 @@ var url = this.commentServiceUrl + '/v0/resources/' + this.encodedResourceUri + '/comments';

});
init.headers.append('x-cimpress-comments-client-version', version);

@@ -113,3 +117,3 @@ return fetch(url, init).then(function (response) {

} else {
throw new Error('Unable to create comment for: ' + _this2.resourceUri + ' Status code: ' + response.status + ')');
throw new Error('Unable to create comment for: ' + _this.resourceUri + ' Status code: ' + response.status + ')');
}

@@ -121,6 +125,3 @@ });

value: function fetchComment(commentUri) {
var init = this.getDefaultConfig('GET');
init.headers.append('x-cimpress-comments-client-version', version);
return fetch(commentUri, init).then(function (response) {
return fetch(commentUri, this.getDefaultConfig('GET')).then(function (response) {
if (response.status === 200) {

@@ -140,3 +141,3 @@ return response.json();

value: function putComment(commentUri, comment, visibility) {
var _this3 = this;
var _this2 = this;

@@ -147,7 +148,6 @@ var init = this.getDefaultConfig('PUT', {

});
init.headers.append('x-cimpress-comments-client-version', version);
return fetch(commentUri, init).then(function (response) {
if (response.status === 200) {
return _this3.fetchComment(commentUri).catch(function () {
return _this2.fetchComment(commentUri).catch(function () {
throw new Error('Error retrieving the comment after putting it');

@@ -171,3 +171,2 @@ });

});
init.headers.append('x-cimpress-comments-client-version', version);

@@ -189,6 +188,4 @@ return fetch(url, init).then(function (response) {

value: function getUserInfo() {
var init = this.getDefaultConfig('GET');
init.headers.append('x-cimpress-comments-client-version', version);
var url = this.commentServiceUrl + '/v0/resources/' + this.encodedResourceUri + '/userinfo';
return fetch(url, init).then(function (response) {
return fetch(url, this.getDefaultConfig('GET')).then(function (response) {
if (response.status === 200) {

@@ -212,4 +209,4 @@ return response.json();

return CommentsClient;
}(_FetchClient4.default);
}();
exports.default = CommentsClient;

@@ -33,6 +33,2 @@ 'use strict';

var _MentionsClient = require('./clients/MentionsClient');
var _MentionsClient2 = _interopRequireDefault(_MentionsClient);
var _i18n = require('./tools/i18n');

@@ -69,3 +65,2 @@

_this.commentsClient = new _CommentsClient2.default(props.accessToken, props.resourceUri);
_this.mentionsClient = new _MentionsClient2.default(props.accessToken);
_this.jwtSub = (0, _helper.getSubFromJWT)(_this.props.accessToken);

@@ -101,3 +96,2 @@

if (this.props.accessToken !== prevProps.accessToken) {
this.mentionsClient = new _MentionsClient2.default(this.props.accessToken);
this.jwtSub = (0, _helper.getSubFromJWT)(this.props.accessToken);

@@ -135,3 +129,2 @@ }

// Creating these clients is inexpensive and do not clear caching
this.mentionsClient = new _MentionsClient2.default(this.props.accessToken);
this.commentsClient = new _CommentsClient2.default(this.props.accessToken, this.props.resourceUri);

@@ -303,2 +296,3 @@ }

var uri = this.commentsClient.getResourceCommentsUri();
var jwt = (0, _helper.getSubFromJWT)(this.props.accessToken);

@@ -310,5 +304,5 @@ return commentIds.map(function (commentId, index) {

locale: _this5.props.locale,
accessToken: _this5.props.accessToken,
className: className,
jwtSub: (0, _helper.getSubFromJWT)(_this5.props.accessToken),
mentionsClient: _this5.mentionsClient,
jwtSub: jwt,
commentsClient: _this5.commentsClient,

@@ -399,3 +393,2 @@ commentUri: uri + '/' + commentId,

accessToken: this.props.accessToken,
mentionsClient: this.mentionsClient,
commentsClient: this.commentsClient,

@@ -402,0 +395,0 @@ resourceUri: this.props.resourceUri,

@@ -25,2 +25,6 @@ 'use strict';

var _renderCoamMentionSuggestion = require('../renderers/renderCoamMentionSuggestion');
var _renderCoamMentionSuggestion2 = _interopRequireDefault(_renderCoamMentionSuggestion);
var _visibility = require('../tools/visibility');

@@ -40,2 +44,4 @@

var _mentions = require('../clients/mentions');
var _reactCimpressBaywatch = require('react-cimpress-baywatch');

@@ -182,21 +188,2 @@

}, {
key: 'renderSuggestion',
value: function renderSuggestion(entry, search, highlightedDisplay, index) {
return _react2.default.createElement(
'span',
null,
highlightedDisplay,
' ',
_react2.default.createElement(
'i',
null,
_react2.default.createElement(
'small',
null,
entry.email
)
)
);
}
}, {
key: 'render',

@@ -262,5 +249,5 @@ value: function render() {

data: function data(search, callback) {
_this5.props.mentionsClient.fetchMatchingMentions(search).then(callback);
(0, _mentions.fetchMatchingMentions)(_this5.props.accessToken, search).then(callback);
},
renderSuggestion: this.renderSuggestion
renderSuggestion: _renderCoamMentionSuggestion2.default
})

@@ -311,3 +298,2 @@ ),

onPostComment: _propTypes2.default.func,
mentionsClient: _propTypes2.default.any,
commentsClient: _propTypes2.default.any

@@ -314,0 +300,0 @@ };

@@ -35,2 +35,6 @@ 'use strict';

var _renderCoamMentionSuggestion = require('../renderers/renderCoamMentionSuggestion');
var _renderCoamMentionSuggestion2 = _interopRequireDefault(_renderCoamMentionSuggestion);
var _reactComponents = require('@cimpress/react-components');

@@ -44,2 +48,4 @@

var _mentions = require('../clients/mentions');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -115,3 +121,3 @@

this.props.mentionsClient.fetchUserName(userId).then(function (responseJson) {
(0, _mentions.fetchUserName)(this.props.accessToken, userId).then(function (responseJson) {
_this2.safeSetState(_defineProperty({}, stateToUpdate, responseJson.profile.name));

@@ -271,4 +277,6 @@ });

_react2.default.createElement(_reactMentions.Mention, { trigger: '@', data: function data(search, callback) {
_this5.props.mentionsClient.fetchMatchingMentions(search).then(callback);
} })
(0, _mentions.fetchMatchingMentions)(_this5.props.accessToken, search).then(callback);
},
renderSuggestion: _renderCoamMentionSuggestion2.default
})
),

@@ -338,2 +346,3 @@ this.renderError(this.state.errorPut, this.tt('unable_to_edit_comment')),

locale: _propTypes2.default.string,
accessToken: _propTypes2.default.string,
className: _propTypes2.default.string,

@@ -346,3 +355,2 @@ jwtSub: _propTypes2.default.string,

commentVisibilityLevels: _propTypes2.default.array,
mentionsClient: _propTypes2.default.any,
commentsClient: _propTypes2.default.any

@@ -349,0 +357,0 @@ };

@@ -12,6 +12,10 @@ 'use strict';

var _pl = require('react-timeago/lib/language-strings/pl');
var _fr = require('react-timeago/lib/language-strings/fr');
var _pl2 = _interopRequireDefault(_pl);
var _fr2 = _interopRequireDefault(_fr);
var _bg = require('react-timeago/lib/language-strings/bg');
var _bg2 = _interopRequireDefault(_bg);
var _de = require('react-timeago/lib/language-strings/de');

@@ -21,2 +25,6 @@

var _pl = require('react-timeago/lib/language-strings/pl');
var _pl2 = _interopRequireDefault(_pl);
var _es = require('react-timeago/lib/language-strings/es');

@@ -26,10 +34,2 @@

var _bg = require('react-timeago/lib/language-strings/bg');
var _bg2 = _interopRequireDefault(_bg);
var _fr = require('react-timeago/lib/language-strings/fr');
var _fr2 = _interopRequireDefault(_fr);
var _buildFormatter = require('react-timeago/lib/formatters/buildFormatter');

@@ -43,9 +43,9 @@

eng: (0, _buildFormatter2.default)(_en2.default),
fra: (0, _buildFormatter2.default)(_fr2.default),
bul: (0, _buildFormatter2.default)(_bg2.default),
deu: (0, _buildFormatter2.default)(_de2.default),
pol: (0, _buildFormatter2.default)(_pl2.default),
deu: (0, _buildFormatter2.default)(_de2.default),
spa: (0, _buildFormatter2.default)(_es2.default),
bul: (0, _buildFormatter2.default)(_bg2.default),
fra: (0, _buildFormatter2.default)(_fr2.default)
spa: (0, _buildFormatter2.default)(_es2.default)
};
// import language files for react-timeago component
exports.reactTimeAgoFormatters = reactTimeAgoFormatters;

@@ -25,23 +25,44 @@ {

},
"pol": {
"fra": {
"translations": {
"show_my_comment_to": "Kto może zobaczyć mój komentarz",
"use_at_char_for_mentions": "Użyj znaku <strong>@</ strong>, by wspomnieć konkretne osoby w swoim komentarzu, a powiadomimy je o nim przy pomocy e-mail'a.",
"visibility_option_internal_label": "Tylko użytkownicy z uprawnieniami do zasobu",
"btn_post": "Wyślij",
"Forbidden": "Dostęp zabroniony",
"unable_to_retrieve_comments": "Nie udało się pobrać komentarzy.",
"unable_to_read_comment": "Nie można pobrać komentarzy.",
"retrieving_comments": "Trwa pobieranie komentarzy ...",
"no_comments_exist": "Nie ma jeszcze żadnych komentarzy.",
"visibility_option_internal_description": "Użytkownicy mający dostęp do odczytywania zasobu który jest przedmiotem komentowania",
"visibility_option_public_description": "Każda osoba posiadająca konto na platformie",
"by": "przez",
"modified": "zmodyfikowany",
"unable_to_post_comment": "Nie można opublikować komentarza",
"visibility_option_public_label": "Wszyscy",
"btn_close": "Zamknij",
"header_comments": "Komentarze"
"show_my_comment_to": "Montrer mon commentaire à",
"use_at_char_for_mentions": "Utilisez le caractère <0>@</0> pour mentionner les personnes. Nous les informerons par e-mail de ce sujet.",
"visibility_option_internal_label": "Seules les personnes autorisées",
"btn_post": "Poster",
"Forbidden": "Interdit",
"unable_to_retrieve_comments": "Impossible de récupérer des commentaires.",
"unable_to_read_comment": "Impossible de récupérer le commentaire.",
"retrieving_comments": "Récupération des commentaires ...",
"no_comments_exist": "Pas encore de commentaires ici.",
"visibility_option_internal_description": "Ceux qui ont accès à la ressource que je commente",
"visibility_option_public_description": "Chaque personne dans Cimpress",
"by": "par",
"modified": "modifié",
"unable_to_post_comment": "Impossible de poster un commentaire",
"visibility_option_public_label": "Toutes les personnes",
"btn_close": "Fermer",
"header_comments": "Commentaires"
}
},
"bul": {
"translations": {
"show_my_comment_to": "Коментарът да бъде видим до",
"use_at_char_for_mentions": "Използвайте <0>@</0> за да споменете някого. Те ще получат известие за вашия коментар.",
"visibility_option_internal_label": "Само упълномощени хора",
"btn_post": "Публикувай",
"Forbidden": "Недостатъчни права",
"unable_to_retrieve_comments": "Коментарите не могат да бъдат извлечени.",
"unable_to_read_comment": "Коментарът не може да бъде извлечен.",
"retrieving_comments": "Зареждане, моля изчакайте...",
"no_comments_exist": "Няма налични коментари.",
"visibility_option_internal_description": "Тези, които имат достъп до ресурса, който коментирам",
"visibility_option_public_description": "Всеки в Cimpress",
"by": "от",
"modified": "променено",
"unable_to_post_comment": "Добавянето на коментар беше неуспешно",
"visibility_option_public_label": "Всеки",
"btn_close": "Затвори",
"header_comments": "Коментари"
}
},
"deu": {

@@ -68,2 +89,23 @@ "translations": {

},
"pol": {
"translations": {
"show_my_comment_to": "Kto może zobaczyć mój komentarz",
"use_at_char_for_mentions": "Użyj znaku <strong>@</ strong>, by wspomnieć konkretne osoby w swoim komentarzu, a powiadomimy je o nim przy pomocy e-mail'a.",
"visibility_option_internal_label": "Tylko użytkownicy z uprawnieniami do zasobu",
"btn_post": "Wyślij",
"Forbidden": "Dostęp zabroniony",
"unable_to_retrieve_comments": "Nie udało się pobrać komentarzy.",
"unable_to_read_comment": "Nie można pobrać komentarzy.",
"retrieving_comments": "Trwa pobieranie komentarzy ...",
"no_comments_exist": "Nie ma jeszcze żadnych komentarzy.",
"visibility_option_internal_description": "Użytkownicy mający dostęp do odczytywania zasobu który jest przedmiotem komentowania",
"visibility_option_public_description": "Każda osoba posiadająca konto na platformie",
"by": "przez",
"modified": "zmodyfikowany",
"unable_to_post_comment": "Nie można opublikować komentarza",
"visibility_option_public_label": "Wszyscy",
"btn_close": "Zamknij",
"header_comments": "Komentarze"
}
},
"spa": {

@@ -89,45 +131,3 @@ "translations": {

}
},
"bul": {
"translations": {
"show_my_comment_to": "Коментарът да бъде видим до",
"use_at_char_for_mentions": "Използвайте <0>@</0> за да споменете някого. Те ще получат известие за вашия коментар.",
"visibility_option_internal_label": "Само упълномощени хора",
"btn_post": "Публикувай",
"Forbidden": "Недостатъчни права",
"unable_to_retrieve_comments": "Коментарите не могат да бъдат извлечени.",
"unable_to_read_comment": "Коментарът не може да бъде извлечен.",
"retrieving_comments": "Зареждане, моля изчакайте...",
"no_comments_exist": "Няма налични коментари.",
"visibility_option_internal_description": "Тези, които имат достъп до ресурса, който коментирам",
"visibility_option_public_description": "Всеки в Cimpress",
"by": "от",
"modified": "променено",
"unable_to_post_comment": "Добавянето на коментар беше неуспешно",
"visibility_option_public_label": "Всеки",
"btn_close": "Затвори",
"header_comments": "Коментари"
}
},
"fra": {
"translations": {
"show_my_comment_to": "Montrer mon commentaire à",
"use_at_char_for_mentions": "Utilisez le caractère <0>@</0> pour mentionner les personnes. Nous les informerons par e-mail de ce sujet.",
"visibility_option_internal_label": "Seules les personnes autorisées",
"btn_post": "Poster",
"Forbidden": "Interdit",
"unable_to_retrieve_comments": "Impossible de récupérer des commentaires.",
"unable_to_read_comment": "Impossible de récupérer le commentaire.",
"retrieving_comments": "Récupération des commentaires ...",
"no_comments_exist": "Pas encore de commentaires ici.",
"visibility_option_internal_description": "Ceux qui ont accès à la ressource que je commente",
"visibility_option_public_description": "Chaque personne dans Cimpress",
"by": "par",
"modified": "modifié",
"unable_to_post_comment": "Impossible de poster un commentaire",
"visibility_option_public_label": "Toutes les personnes",
"btn_close": "Fermer",
"header_comments": "Commentaires"
}
}
}
{
"name": "react-cimpress-comment",
"version": "0.8.6",
"version": "0.8.7",
"description": "Visualizes comment(s) for a particular platform resource",

@@ -40,3 +40,2 @@ "main": "./lib/index.js",

"aws-sdk": "^2.243.1",
"axios-mock-adapter": "^1.15.0",
"babel": "^6.23.0",

@@ -56,3 +55,3 @@ "babel-cli": "^6.24.1",

"eslint-plugin-react": "^7.10.0",
"fetch-mock": "^6.4.4",
"fetch-mock": "^7.2.5",
"iso-639": "^0.2.2",

@@ -63,7 +62,9 @@ "jsonwebtoken": "^8.2.1",

"react-dom": "^15.0.0-0 || ^16.0.0-0 || ^17.0.0-0",
"request-promise-native": "^1.0.5"
"request-promise-native": "^1.0.5",
"xhr-mock": "^2.4.1"
},
"dependencies": {
"atob": "^2.1.1",
"cimpress-customizr": "^1.1.1",
"cimpress-customizr": "~1",
"coam-client": "^0.1.2",
"deepmerge": "^2.1.1",

@@ -74,3 +75,3 @@ "fetch-retry": "^2.0.0",

"prop-types": "^15.6.2",
"react-cimpress-baywatch": "0.0.5",
"react-cimpress-baywatch": "~0",
"react-i18next": "^7.6.1",

@@ -77,0 +78,0 @@ "react-mentions": "^1.2.2",

@@ -91,3 +91,3 @@ # react-cimpress-comment [![Build Status](https://travis-ci.org/Cimpress/react-cimpress-comment.svg?branch=master)](https://travis-ci.org/Cimpress/react-cimpress-comment) [![NPM version](https://img.shields.io/npm/v/react-cimpress-comment.svg)](https://www.npmjs.com/package/react-cimpress-comment)

npm sun storybook
npm run storybook

@@ -94,0 +94,0 @@ This command will run the Storybook in the background. You can later stop it by running `npm run storybookstop`.

Sorry, the diff of this file is not supported yet