mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
the template link in the left menu is only shown to owners/admins
This commit is contained in:
parent
c93c8b3f7d
commit
46377aea3d
3 changed files with 20 additions and 17 deletions
|
@ -110,12 +110,13 @@ aside#left-menu.full-size(
|
|||
)
|
||||
option(value="pdfjs") Built-In
|
||||
option(value="native") Native
|
||||
h4 Publish
|
||||
ul.list-unstyled.nav(ng-controller="TemplatesController")
|
||||
li
|
||||
a(ng-click="openPublishTemplateModal()")
|
||||
i.fa.fa-list-alt.fa-fw
|
||||
| Publish as Template
|
||||
span(ng-controller="TemplatesController", ng-show="hasPermission('admin')")
|
||||
h4() Publish
|
||||
ul.list-unstyled.nav()
|
||||
li
|
||||
a(ng-click="openPublishTemplateModal()")
|
||||
i.fa.fa-list-alt.fa-fw
|
||||
| Publish as Template
|
||||
|
||||
|
||||
#left-menu-mask(
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
define [], () ->
|
||||
class PermissionsManager
|
||||
constructor: (@ide, @$scope) ->
|
||||
@$scope.permissions =
|
||||
read: false
|
||||
write: false
|
||||
admin: false
|
||||
@$scope.$watch "permissionsLevel", (permissionsLevel) =>
|
||||
@$scope.permissions =
|
||||
read: false
|
||||
write: false
|
||||
admin: false
|
||||
|
||||
if permissionsLevel?
|
||||
if permissionsLevel == "readOnly"
|
||||
@$scope.permissions.read = true
|
||||
|
@ -17,3 +18,5 @@ define [], () ->
|
|||
@$scope.permissions.write = true
|
||||
@$scope.permissions.admin = true
|
||||
|
||||
@$scope.hasPermission = (requestedLevel)=>
|
||||
return @$scope.permissions[requestedLevel]
|
|
@ -1,7 +1,9 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
"ide/permissions/PermissionsManager"
|
||||
], (App, PermissionsManager) ->
|
||||
App.controller "TemplatesController", ($scope, $modal, ide) ->
|
||||
$scope.showPublishTemplateLinkInSideBar = ide.$scope.hasPermission("admin")
|
||||
|
||||
$scope.openPublishTemplateModal = () ->
|
||||
console.log "open"
|
||||
|
@ -12,8 +14,9 @@ define [
|
|||
diff: () -> $scope.trackChanges.diff
|
||||
}
|
||||
|
||||
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, diff, ide) ->
|
||||
user_id = window.user.id #TODO this is not correct, it needs to be the owners id
|
||||
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, ide) ->
|
||||
permissionsManager = new PermissionsManager(ide, $scope)
|
||||
user_id = ide.$scope.user.id
|
||||
$scope.template =
|
||||
description: window.project_description
|
||||
$scope.publishedDetails =
|
||||
|
@ -25,7 +28,6 @@ define [
|
|||
|
||||
refreshPublishedStatus = ->
|
||||
ide.socket.emit "getPublishedDetails", user_id, (err, data)->
|
||||
console.log "got published details"
|
||||
$scope.publishedDetails = data
|
||||
$scope.publishedDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
||||
|
||||
|
@ -35,19 +37,16 @@ define [
|
|||
description = $scope.template.description
|
||||
if description?
|
||||
ide.socket.emit 'updateProjectDescription', description, () =>
|
||||
console.log "updated"
|
||||
|
||||
$scope.publish = ->
|
||||
$scope.state.publishInflight = true
|
||||
ide.socket.emit 'publishProjectAsTemplate', user_id, (error, docLines, version) =>
|
||||
console.log "published"
|
||||
refreshPublishedStatus()
|
||||
$scope.state.publishInflight = false
|
||||
|
||||
$scope.unpublishTemplate = ->
|
||||
$scope.state.unpublishInflight = true
|
||||
ide.socket.emit 'unPublishProjectAsTemplate', user_id, (error, docLines, version) =>
|
||||
console.log "unpublished"
|
||||
refreshPublishedStatus()
|
||||
$scope.state.unpublishInflight = false
|
||||
|
||||
|
|
Loading…
Reference in a new issue