Merge pull request #292 from sharelatex/ja-v1-ownership

Fallback to project creator when there is no owner
This commit is contained in:
James Allen 2018-01-24 09:50:20 +00:00 committed by GitHub
commit 28deb4e107
4 changed files with 34 additions and 21 deletions

View file

@ -395,19 +395,27 @@ module.exports = ProjectController =
return model
_buildV1ProjectViewModel: (project) ->
{
projectViewModel = {
id: project.id
name: project.title
lastUpdated: new Date(project.updated_at * 1000) # Convert from epoch
accessLevel: if project.owner?.user_is_owner then "owner" else "readOnly"
archived: project.removed || project.archived
owner: {
# Unlisted V1 projects don't have an owner, so just show N/A
first_name: if project.owner then project.owner.name else 'N/A'
last_name: ''
}
isV1Project: true
}
if (project.owner? and project.owner.user_is_owner) or (project.creator? and project.creator.user_is_creator)
projectViewModel.accessLevel = "owner"
else
projectViewModel.accessLevel = "readOnly"
if project.owner?
projectViewModel.owner = {
first_name: project.owner.name
}
else if project.creator?
projectViewModel.owner = {
first_name: project.creator.name
}
return projectViewModel
_injectProjectOwners: (projects, callback = (error, projects) ->) ->
users = {}

View file

@ -1,20 +1,22 @@
.col-xs-6
span.v1-badge(
aria-label=translate("v1_badge")
tooltip-template="'v1ProjectTooltipTemplate'"
tooltip-append-to-body="true"
)
.select-item
span.v1-badge(
aria-label=translate("v1_badge")
tooltip-template="'v1ProjectTooltipTemplate'"
tooltip-append-to-body="true"
)
span
if settings.overleaf && settings.overleaf.host
button.btn.btn-link.projectName(
ng-click="openV1ImportModal(project)"
stop-propagation="click"
ng-show="project.accessLevel == 'owner'"
) {{project.name}}
a.projectName(
href=settings.overleaf.host + "/{{project.id}}"
target="_blank"
ng-hide="project.accessLevel == 'owner'"
) {{project.name}}
//- To re-enable the import dialog (may need style changing for padding/line-height):
//- button.btn.btn-link.projectName(
//- ng-click="openV1ImportModal(project)"
//- stop-propagation="click"
//- ) {{project.name}}
.col-xs-2
span.owner {{ownerName()}}

View file

@ -480,9 +480,9 @@ define [
if $scope.project.accessLevel == "owner"
return "You"
else if $scope.project.owner?
return "#{$scope.project.owner.first_name} #{$scope.project.owner.last_name}"
return [$scope.project.owner.first_name, $scope.project.owner.last_name].filter((n) -> n?).join(" ")
else
return "?"
return "None"
$scope.$watch "project.selected", (value) ->
if value?

View file

@ -336,6 +336,10 @@ ul.project-list {
}
.projectName {
margin-right: @line-height-computed / 4;
padding: 0;
vertical-align: inherit;
white-space: normal;
text-align: left;
}
.tag-label {
@ -373,8 +377,7 @@ ul.project-list {
}
.v1-badge {
margin-right: 9px;
margin-left: 7px;
margin-left: -4px;
}
}
i.tablesort {