diff --git a/client/coral-embed-stream/src/components/Comment.js b/client/coral-embed-stream/src/components/Comment.js index cda85f49d..b80a62b28 100644 --- a/client/coral-embed-stream/src/components/Comment.js +++ b/client/coral-embed-stream/src/components/Comment.js @@ -22,7 +22,7 @@ import {TopRightMenu} from './TopRightMenu'; import classnames from 'classnames'; import {EditableCommentContent} from './EditableCommentContent'; import {getActionSummary, iPerformedThisAction} from 'coral-framework/utils'; - +import {getEditableUntilDate} from './util'; import styles from './Comment.css'; const isStaff = tags => !tags.every(t => t.name !== 'STAFF'); @@ -415,13 +415,6 @@ class Comment extends React.Component { export default Comment; -// return a Date instance representing end of edit window for comment -const getEditableUntilDate = (comment) => { - const editing = comment && comment.editing; - const editableUntil = editing && editing.editableUntil && new Date(Date.parse(editing.editableUntil)); - return editableUntil; -}; - // return whether the comment is editable function commentIsStillEditable (comment) { const editing = comment && comment.editing; diff --git a/client/coral-embed-stream/src/components/EditableCommentContent.js b/client/coral-embed-stream/src/components/EditableCommentContent.js index 1f14613c0..03b61edce 100644 --- a/client/coral-embed-stream/src/components/EditableCommentContent.js +++ b/client/coral-embed-stream/src/components/EditableCommentContent.js @@ -3,18 +3,13 @@ import {notifyForNewCommentStatus} from 'coral-plugin-commentbox/CommentBox'; import {CommentForm} from 'coral-plugin-commentbox/CommentForm'; import styles from './Comment.css'; import {CountdownSeconds} from './CountdownSeconds'; +import {getEditableUntilDate} from './util'; import {Icon} from 'coral-ui'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from 'coral-framework/translations'; const lang = new I18n(translations); -const getEditableUntilDate = (comment) => { - const editing = comment && comment.editing; - const editableUntil = editing && editing.editableUntil && new Date(Date.parse(editing.editableUntil)); - return editableUntil; -}; - /** * Renders a Comment's body in such a way that the end-user can edit it and save changes */ diff --git a/client/coral-embed-stream/src/components/util.js b/client/coral-embed-stream/src/components/util.js new file mode 100644 index 000000000..fe5258853 --- /dev/null +++ b/client/coral-embed-stream/src/components/util.js @@ -0,0 +1,10 @@ +/** + * Given a comment, return when the comment can no longer be edited + * @param {Object} comment + * @returns {Date} when the comment can no longer be edited. + */ +export const getEditableUntilDate = (comment) => { + const editing = comment && comment.editing; + const editableUntil = editing && editing.editableUntil && new Date(Date.parse(editing.editableUntil)); + return editableUntil; +};