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,8 +110,9 @@ aside#left-menu.full-size(
|
||||||
)
|
)
|
||||||
option(value="pdfjs") Built-In
|
option(value="pdfjs") Built-In
|
||||||
option(value="native") Native
|
option(value="native") Native
|
||||||
h4 Publish
|
span(ng-controller="TemplatesController", ng-show="hasPermission('admin')")
|
||||||
ul.list-unstyled.nav(ng-controller="TemplatesController")
|
h4() Publish
|
||||||
|
ul.list-unstyled.nav()
|
||||||
li
|
li
|
||||||
a(ng-click="openPublishTemplateModal()")
|
a(ng-click="openPublishTemplateModal()")
|
||||||
i.fa.fa-list-alt.fa-fw
|
i.fa.fa-list-alt.fa-fw
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
define [], () ->
|
define [], () ->
|
||||||
class PermissionsManager
|
class PermissionsManager
|
||||||
constructor: (@ide, @$scope) ->
|
constructor: (@ide, @$scope) ->
|
||||||
@$scope.$watch "permissionsLevel", (permissionsLevel) =>
|
|
||||||
@$scope.permissions =
|
@$scope.permissions =
|
||||||
read: false
|
read: false
|
||||||
write: false
|
write: false
|
||||||
admin: false
|
admin: false
|
||||||
|
@$scope.$watch "permissionsLevel", (permissionsLevel) =>
|
||||||
|
|
||||||
if permissionsLevel?
|
if permissionsLevel?
|
||||||
if permissionsLevel == "readOnly"
|
if permissionsLevel == "readOnly"
|
||||||
@$scope.permissions.read = true
|
@$scope.permissions.read = true
|
||||||
|
@ -17,3 +18,5 @@ define [], () ->
|
||||||
@$scope.permissions.write = true
|
@$scope.permissions.write = true
|
||||||
@$scope.permissions.admin = true
|
@$scope.permissions.admin = true
|
||||||
|
|
||||||
|
@$scope.hasPermission = (requestedLevel)=>
|
||||||
|
return @$scope.permissions[requestedLevel]
|
|
@ -1,7 +1,9 @@
|
||||||
define [
|
define [
|
||||||
"base"
|
"base"
|
||||||
], (App) ->
|
"ide/permissions/PermissionsManager"
|
||||||
|
], (App, PermissionsManager) ->
|
||||||
App.controller "TemplatesController", ($scope, $modal, ide) ->
|
App.controller "TemplatesController", ($scope, $modal, ide) ->
|
||||||
|
$scope.showPublishTemplateLinkInSideBar = ide.$scope.hasPermission("admin")
|
||||||
|
|
||||||
$scope.openPublishTemplateModal = () ->
|
$scope.openPublishTemplateModal = () ->
|
||||||
console.log "open"
|
console.log "open"
|
||||||
|
@ -12,8 +14,9 @@ define [
|
||||||
diff: () -> $scope.trackChanges.diff
|
diff: () -> $scope.trackChanges.diff
|
||||||
}
|
}
|
||||||
|
|
||||||
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, diff, ide) ->
|
App.controller "PublishProjectAsTemplateModalController", ($scope, $modalInstance, ide) ->
|
||||||
user_id = window.user.id #TODO this is not correct, it needs to be the owners id
|
permissionsManager = new PermissionsManager(ide, $scope)
|
||||||
|
user_id = ide.$scope.user.id
|
||||||
$scope.template =
|
$scope.template =
|
||||||
description: window.project_description
|
description: window.project_description
|
||||||
$scope.publishedDetails =
|
$scope.publishedDetails =
|
||||||
|
@ -25,7 +28,6 @@ define [
|
||||||
|
|
||||||
refreshPublishedStatus = ->
|
refreshPublishedStatus = ->
|
||||||
ide.socket.emit "getPublishedDetails", user_id, (err, data)->
|
ide.socket.emit "getPublishedDetails", user_id, (err, data)->
|
||||||
console.log "got published details"
|
|
||||||
$scope.publishedDetails = data
|
$scope.publishedDetails = data
|
||||||
$scope.publishedDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
$scope.publishedDetails.publishedDate = moment(data.publishedDate).format("Do MMM YYYY, h:mm a")
|
||||||
|
|
||||||
|
@ -35,19 +37,16 @@ define [
|
||||||
description = $scope.template.description
|
description = $scope.template.description
|
||||||
if description?
|
if description?
|
||||||
ide.socket.emit 'updateProjectDescription', description, () =>
|
ide.socket.emit 'updateProjectDescription', description, () =>
|
||||||
console.log "updated"
|
|
||||||
|
|
||||||
$scope.publish = ->
|
$scope.publish = ->
|
||||||
$scope.state.publishInflight = true
|
$scope.state.publishInflight = true
|
||||||
ide.socket.emit 'publishProjectAsTemplate', user_id, (error, docLines, version) =>
|
ide.socket.emit 'publishProjectAsTemplate', user_id, (error, docLines, version) =>
|
||||||
console.log "published"
|
|
||||||
refreshPublishedStatus()
|
refreshPublishedStatus()
|
||||||
$scope.state.publishInflight = false
|
$scope.state.publishInflight = false
|
||||||
|
|
||||||
$scope.unpublishTemplate = ->
|
$scope.unpublishTemplate = ->
|
||||||
$scope.state.unpublishInflight = true
|
$scope.state.unpublishInflight = true
|
||||||
ide.socket.emit 'unPublishProjectAsTemplate', user_id, (error, docLines, version) =>
|
ide.socket.emit 'unPublishProjectAsTemplate', user_id, (error, docLines, version) =>
|
||||||
console.log "unpublished"
|
|
||||||
refreshPublishedStatus()
|
refreshPublishedStatus()
|
||||||
$scope.state.unpublishInflight = false
|
$scope.state.unpublishInflight = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue