Merge pull request #2587 from overleaf/msm-ns-disable-comment-button

disable "add comment" button if feature is not available

GitOrigin-RevId: e054f138a84ec634cc777d76e8a288ba2c1b2ee3
This commit is contained in:
Simon Detheridge 2020-02-12 15:13:34 +00:00 committed by Copybot
parent 96cd1c869e
commit 72c5286622
2 changed files with 43 additions and 36 deletions

View file

@ -21,6 +21,10 @@ const supportModuleAvailable = fs.existsSync(
`${__dirname}/../../../modules/support`
)
const trackChangesModuleAvailable = fs.existsSync(
`${__dirname}/../../../modules/track-changes`
)
module.exports = Features = {
externalAuthenticationSystemUsed() {
return (
@ -69,6 +73,8 @@ module.exports = Features = {
return publicRegistrationModuleAvailable
case 'support':
return supportModuleAvailable
case 'track-changes':
return trackChangesModuleAvailable
default:
throw new Error(`unknown feature: ${feature}`)
}

View file

@ -10,7 +10,7 @@
href
ng-if="reviewPanel.nVisibleSelectedChanges > 1"
ng-click="showBulkAcceptDialog();"
)
)
i.fa.fa-check
|  #{translate("accept_all")}
| ({{ reviewPanel.nVisibleSelectedChanges }})
@ -18,17 +18,18 @@
href
ng-if="reviewPanel.nVisibleSelectedChanges > 1"
ng-click="showBulkRejectDialog();"
)
)
i.fa.fa-times
|  #{translate("reject_all")}
| ({{ reviewPanel.nVisibleSelectedChanges }})
a.rp-add-comment-btn(
href
ng-if="reviewPanel.entries[editor.open_doc_id]['add-comment'] != null && permissions.comment"
ng-click="addNewComment();"
)
i.fa.fa-comment
|  #{translate("add_comment")}
if hasFeature('track-changes')
a.rp-add-comment-btn(
href
ng-if="reviewPanel.entries[editor.open_doc_id]['add-comment'] != null && permissions.comment"
ng-click="addNewComment();"
)
i.fa.fa-comment
|  #{translate("add_comment")}
a.review-panel-toggler(
href
ng-click="handleTogglerClick($event);"
@ -152,7 +153,7 @@
permissions="permissions"
ng-if="!reviewPanel.loadingThreads"
)
div(ng-if="entry.type === 'add-comment' && permissions.comment")
add-comment-entry(
on-start-new="startNewComment();"
@ -283,12 +284,12 @@ script(type='text/ng-template', id='changeEntryTemplate')
) {{ isCollapsed ? '... (#{translate("show_all")})' : ' (#{translate("show_less")})' }}
.rp-entry-metadata
| {{ entry.metadata.ts | date : 'MMM d, y h:mm a' }} • 
span.rp-entry-user(style="color: hsl({{ user.hue }}, 70%, 40%);") {{ user.name }}
span.rp-entry-user(style="color: hsl({{ user.hue }}, 70%, 40%);") {{ user.name }}
.rp-entry-actions(ng-if="permissions.write")
a.rp-entry-button(href, ng-click="onReject();")
a.rp-entry-button(href, ng-click="onReject();")
i.fa.fa-times
|  #{translate("reject")}
a.rp-entry-button(href, ng-click="onAccept();")
a.rp-entry-button(href, ng-click="onAccept();")
i.fa.fa-check
|  #{translate("accept")}
@ -308,7 +309,7 @@ script(type='text/ng-template', id='aggregateChangeEntryTemplate')
i.fa.fa-pencil
.rp-entry-details
.rp-entry-description
| #{translate("aggregate_changed")}
| #{translate("aggregate_changed")}
del.rp-content-highlight
| {{ entry.metadata.replaced_content | limitTo:(isDeletionCollapsed ? contentLimit : entry.metadata.replaced_contentlength) }}
a.rp-collapse-toggle(
@ -316,7 +317,7 @@ script(type='text/ng-template', id='aggregateChangeEntryTemplate')
ng-if="deletionNeedsCollapsing"
ng-click="toggleDeletionCollapse();"
) {{ isDeletionCollapsed ? '... (#{translate("show_all")})' : ' (#{translate("show_less")})' }}
| #{translate("aggregate_to")}
| #{translate("aggregate_to")}
ins.rp-content-highlight
| {{ entry.content | limitTo:(isInsertionCollapsed ? contentLimit : entry.contentlength) }}
a.rp-collapse-toggle(
@ -326,12 +327,12 @@ script(type='text/ng-template', id='aggregateChangeEntryTemplate')
) {{ isInsertionCollapsed ? '... (#{translate("show_all")})' : ' (#{translate("show_less")})' }}
.rp-entry-metadata
| {{ entry.metadata.ts | date : 'MMM d, y h:mm a' }} • 
span.rp-entry-user(style="color: hsl({{ user.hue }}, 70%, 40%);") {{ user.name }}
span.rp-entry-user(style="color: hsl({{ user.hue }}, 70%, 40%);") {{ user.name }}
.rp-entry-actions(ng-if="permissions.write")
a.rp-entry-button(href, ng-click="onReject();")
a.rp-entry-button(href, ng-click="onReject();")
i.fa.fa-times
|  #{translate("reject")}
a.rp-entry-button(href, ng-click="onAccept();")
a.rp-entry-button(href, ng-click="onAccept();")
i.fa.fa-check
|  #{translate("accept")}
@ -399,7 +400,7 @@ script(type='text/ng-template', id='commentEntryTemplate')
button.rp-entry-button(
ng-click="animateAndCallOnResolve();"
ng-if="permissions.comment && permissions.write"
)
)
i.fa.fa-inbox
|  #{translate("resolve")}
button.rp-entry-button(
@ -409,7 +410,7 @@ script(type='text/ng-template', id='commentEntryTemplate')
)
i.fa.fa-reply
|  #{translate("reply")}
script(type='text/ng-template', id='resolvedCommentEntryTemplate')
.rp-resolved-comment
div
@ -426,7 +427,7 @@ script(type='text/ng-template', id='resolvedCommentEntryTemplate')
.rp-comment(
ng-repeat="comment in thread.messages track by comment.id"
)
p.rp-comment-content
p.rp-comment-content
span.rp-entry-user(
style="color: hsl({{ comment.user.hue }}, 70%, 40%);"
ng-if="$first || comment.user.id !== thread.messages[$index - 1].user.id"
@ -435,19 +436,19 @@ script(type='text/ng-template', id='resolvedCommentEntryTemplate')
.rp-entry-metadata
| {{ comment.timestamp | date : 'MMM d, y h:mm a' }}
.rp-comment.rp-comment-resolver
p.rp-comment-resolver-content
p.rp-comment-resolver-content
span.rp-entry-user(
style="color: hsl({{ thread.resolved_by_user.hue }}, 70%, 40%);"
) {{ thread.resolved_by_user.name }}: 
| #{translate("mark_as_resolved")}.
.rp-entry-metadata
| {{ thread.resolved_at | date : 'MMM d, y h:mm a' }}
.rp-entry-actions(ng-if="permissions.comment && permissions.write")
a.rp-entry-button(
href
ng-click="onUnresolve({ 'threadId': thread.threadId });"
)
)
|  #{translate("reopen")}
a.rp-entry-button(
href
@ -466,7 +467,7 @@ script(type='text/ng-template', id='addCommentEntryTemplate')
href
ng-if="!state.isAdding"
ng-click="startNewComment();"
)
)
i.fa.fa-comment
|  #{translate("add_comment")}
div(ng-if="state.isAdding")
@ -481,13 +482,13 @@ script(type='text/ng-template', id='addCommentEntryTemplate')
.rp-entry-actions
button.rp-entry-button.rp-entry-button-cancel(
ng-click="cancelNewComment();"
)
)
i.fa.fa-times
|  #{translate("cancel")}
button.rp-entry-button(
ng-click="submitNewComment()"
ng-disabled="!state.content.length"
)
)
i.fa.fa-comment
|  #{translate("comment")}
@ -498,18 +499,18 @@ script(type='text/ng-template', id='bulkActionsEntryTemplate')
a.rp-bulk-actions-btn(
href
ng-click="bulkReject();"
)
)
i.fa.fa-times
|  #{translate("reject_all")}
| ({{ nEntries }})
a.rp-bulk-actions-btn(
href
ng-click="bulkAccept();"
)
)
i.fa.fa-check
|  #{translate("accept_all")}
| ({{ nEntries }})
script(type='text/ng-template', id='resolvedCommentsDropdownTemplate')
.resolved-comments
.resolved-comments-backdrop(
@ -541,7 +542,7 @@ script(type='text/ng-template', id='resolvedCommentsDropdownTemplate')
)
.rp-loading(ng-if="!resolvedComments.length")
| #{translate("no_resolved_threads")}.
script(type="text/ng-template", id="trackChangesUpgradeModalTemplate")
.modal-header
button.close(
@ -557,9 +558,9 @@ script(type="text/ng-template", id="trackChangesUpgradeModalTemplate")
video.teaser-video(autoplay, loop)
source(ng-src="{{ '/img/teasers/track-changes/teaser-track-changes.mp4' }}", type="video/mp4")
img(src="/img/teasers/track-changes/teaser-track-changes.gif")
h4.teaser-title #{translate("see_changes_in_your_documents_live")}
p.small(ng-show="startedFreeTrial")
| #{translate("refresh_page_after_starting_free_trial")}
@ -569,7 +570,7 @@ script(type="text/ng-template", id="trackChangesUpgradeModalTemplate")
li
i.fa.fa-check  
| #{translate("track_any_change_in_real_time")}
li
i.fa.fa-check  
| #{translate("review_your_peers_work")}
@ -577,7 +578,7 @@ script(type="text/ng-template", id="trackChangesUpgradeModalTemplate")
li
i.fa.fa-check  
| #{translate("accept_or_reject_each_changes_individually")}
.row.text-center(ng-controller="FreeTrialModalController")
a.btn.btn-success(
@ -603,7 +604,7 @@ script(type="text/ng-template", id="bulkActionsModalTemplate")
)
span(aria-hidden="true") ×
h3 {{ isAccept ? '#{translate("accept_all")}' : '#{translate("reject_all")}' }}
.modal-body
.modal-body
p(ng-if="isAccept") #{translate("bulk_accept_confirm", { nChanges: "{{ nChanges }}"})}
p(ng-if="!isAccept") #{translate("bulk_reject_confirm", { nChanges: "{{ nChanges }}"})}
.modal-footer()