mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Use history label component; restrict label deletion to label owners.
This commit is contained in:
parent
8c50e4e9ae
commit
a8ee879746
6 changed files with 82 additions and 18 deletions
|
@ -5,10 +5,12 @@ aside.change-list(
|
||||||
history-entries-list(
|
history-entries-list(
|
||||||
entries="history.updates"
|
entries="history.updates"
|
||||||
current-user="user"
|
current-user="user"
|
||||||
|
users="projectUsers"
|
||||||
load-entries="loadMore()"
|
load-entries="loadMore()"
|
||||||
load-disabled="history.loading || history.atEnd"
|
load-disabled="history.loading || history.atEnd"
|
||||||
load-initialize="ui.view == 'history'"
|
load-initialize="ui.view == 'history'"
|
||||||
is-loading="history.loading"
|
is-loading="history.loading"
|
||||||
|
show-only-labelled="listConfig.showOnlyLabelled"
|
||||||
on-entry-select="handleEntrySelect(selectedEntry)"
|
on-entry-select="handleEntrySelect(selectedEntry)"
|
||||||
on-label-delete="handleLabelDelete(label)"
|
on-label-delete="handleLabelDelete(label)"
|
||||||
)
|
)
|
||||||
|
@ -116,9 +118,10 @@ script(type="text/ng-template", id="historyEntriesListTpl")
|
||||||
)
|
)
|
||||||
.infinite-scroll-inner
|
.infinite-scroll-inner
|
||||||
history-entry(
|
history-entry(
|
||||||
ng-repeat="entry in $ctrl.entries"
|
ng-repeat="entry in $ctrl.entries | filter:$ctrl.shouldShowEntry"
|
||||||
entry="entry"
|
entry="entry"
|
||||||
current-user="$ctrl.currentUser"
|
current-user="$ctrl.currentUser"
|
||||||
|
users="$ctrl.users"
|
||||||
on-select="$ctrl.onEntrySelect({ selectedEntry: selectedEntry })"
|
on-select="$ctrl.onEntrySelect({ selectedEntry: selectedEntry })"
|
||||||
on-label-delete="$ctrl.onLabelDelete({ label: label })"
|
on-label-delete="$ctrl.onLabelDelete({ label: label })"
|
||||||
ng-show="!$ctrl.isLoading"
|
ng-show="!$ctrl.isLoading"
|
||||||
|
@ -143,17 +146,14 @@ script(type="text/ng-template", id="historyEntryTpl")
|
||||||
time.history-entry-day(ng-if="::$ctrl.entry.meta.first_in_day") {{ ::$ctrl.entry.meta.end_ts | relativeDate }}
|
time.history-entry-day(ng-if="::$ctrl.entry.meta.first_in_day") {{ ::$ctrl.entry.meta.end_ts | relativeDate }}
|
||||||
|
|
||||||
.history-entry-details(ng-click="$ctrl.onSelect({ selectedEntry: $ctrl.entry })")
|
.history-entry-details(ng-click="$ctrl.onSelect({ selectedEntry: $ctrl.entry })")
|
||||||
.history-entry-label(
|
history-label(
|
||||||
ng-if="$ctrl.entry.labels.length > 0"
|
|
||||||
ng-repeat="label in $ctrl.entry.labels"
|
ng-repeat="label in $ctrl.entry.labels"
|
||||||
|
label-text="label.comment"
|
||||||
|
label-owner-name="$ctrl.displayNameById(label.user_id)"
|
||||||
|
label-creation-date-time="label.created_at"
|
||||||
|
is-owned-by-current-user="label.user_id === $ctrl.currentUser.id"
|
||||||
|
on-label-delete="$ctrl.onLabelDelete({ label: label })"
|
||||||
)
|
)
|
||||||
span.history-entry-label-comment
|
|
||||||
i.fa.fa-tag
|
|
||||||
| {{ label.comment }}
|
|
||||||
button.history-entry-label-delete-btn(
|
|
||||||
stop-propagation="click"
|
|
||||||
ng-click="$ctrl.onLabelDelete({ label: label })"
|
|
||||||
) ×
|
|
||||||
|
|
||||||
ol.history-entry-changes
|
ol.history-entry-changes
|
||||||
li.history-entry-change(
|
li.history-entry-change(
|
||||||
|
@ -199,3 +199,27 @@ script(type="text/ng-template", id="historyEntryTpl")
|
||||||
span.name(
|
span.name(
|
||||||
ng-style="$ctrl.getUserCSSStyle();"
|
ng-style="$ctrl.getUserCSSStyle();"
|
||||||
) #{translate("anonymous")}
|
) #{translate("anonymous")}
|
||||||
|
|
||||||
|
script(type="text/ng-template", id="historyLabelTpl")
|
||||||
|
.history-entry-label(
|
||||||
|
ng-class="{ 'history-entry-label-own' : $ctrl.isOwnedByCurrentUser }"
|
||||||
|
)
|
||||||
|
span.history-entry-label-comment(
|
||||||
|
tooltip-template="'historyLabelTooltipTpl'"
|
||||||
|
tooltip-placement="left"
|
||||||
|
)
|
||||||
|
i.fa.fa-tag
|
||||||
|
| {{ $ctrl.labelText }}
|
||||||
|
button.history-entry-label-delete-btn(
|
||||||
|
ng-if="$ctrl.isOwnedByCurrentUser"
|
||||||
|
stop-propagation="click"
|
||||||
|
ng-click="$ctrl.onLabelDelete()"
|
||||||
|
) ×
|
||||||
|
|
||||||
|
script(type="text/ng-template", id="historyLabelTooltipTpl")
|
||||||
|
.history-label-tooltip
|
||||||
|
p.history-label-tooltip-title
|
||||||
|
i.fa.fa-tag
|
||||||
|
| {{ $ctrl.labelText }}
|
||||||
|
p.history-label-tooltip-owner Created by {{ $ctrl.labelOwnerName }}
|
||||||
|
time.history-label-tooltip-datetime {{ labelCreationDateTime | formatDate }}
|
|
@ -12,6 +12,7 @@ define [
|
||||||
"ide/history/directives/infiniteScroll"
|
"ide/history/directives/infiniteScroll"
|
||||||
"ide/history/components/historyEntriesList"
|
"ide/history/components/historyEntriesList"
|
||||||
"ide/history/components/historyEntry"
|
"ide/history/components/historyEntry"
|
||||||
|
"ide/history/components/historyLabel"
|
||||||
"ide/history/components/historyFileTree"
|
"ide/history/components/historyFileTree"
|
||||||
"ide/history/components/historyFileEntity"
|
"ide/history/components/historyFileEntity"
|
||||||
], (moment, ColorManager, displayNameForUser, HistoryViewModes) ->
|
], (moment, ColorManager, displayNameForUser, HistoryViewModes) ->
|
||||||
|
|
|
@ -3,11 +3,14 @@ define [
|
||||||
], (App) ->
|
], (App) ->
|
||||||
historyEntriesListController = ($scope, $element, $attrs) ->
|
historyEntriesListController = ($scope, $element, $attrs) ->
|
||||||
ctrl = @
|
ctrl = @
|
||||||
|
ctrl.shouldShowEntry = (entry) ->
|
||||||
|
!(ctrl.showOnlyLabelled and entry.labels.length == 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
App.component "historyEntriesList", {
|
App.component "historyEntriesList", {
|
||||||
bindings:
|
bindings:
|
||||||
entries: "<"
|
entries: "<"
|
||||||
|
users: "<"
|
||||||
loadEntries: "&"
|
loadEntries: "&"
|
||||||
loadDisabled: "<"
|
loadDisabled: "<"
|
||||||
loadInitialize: "<"
|
loadInitialize: "<"
|
||||||
|
@ -15,6 +18,7 @@ define [
|
||||||
currentUser: "<"
|
currentUser: "<"
|
||||||
onEntrySelect: "&"
|
onEntrySelect: "&"
|
||||||
onLabelDelete: "&"
|
onLabelDelete: "&"
|
||||||
|
showOnlyLabelled: "<"
|
||||||
controller: historyEntriesListController
|
controller: historyEntriesListController
|
||||||
templateUrl: "historyEntriesListTpl"
|
templateUrl: "historyEntriesListTpl"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,15 @@ define [
|
||||||
"base"
|
"base"
|
||||||
"ide/history/util/displayNameForUser"
|
"ide/history/util/displayNameForUser"
|
||||||
], (App, displayNameForUser) ->
|
], (App, displayNameForUser) ->
|
||||||
historyEntryController = ($scope, $element, $attrs) ->
|
historyEntryController = ($scope, $element, $attrs, $filter, _) ->
|
||||||
ctrl = @
|
ctrl = @
|
||||||
|
_getUserById = (id) ->
|
||||||
|
_.find ctrl.users, (user) ->
|
||||||
|
curUserId = user?._id or user?.id
|
||||||
|
curUserId == id
|
||||||
ctrl.displayName = displayNameForUser
|
ctrl.displayName = displayNameForUser
|
||||||
|
ctrl.displayNameById = (id) ->
|
||||||
|
displayNameForUser(_getUserById(id))
|
||||||
ctrl.getProjectOpDoc = (projectOp) ->
|
ctrl.getProjectOpDoc = (projectOp) ->
|
||||||
if projectOp.rename? then "#{ projectOp.rename.pathname} → #{ projectOp.rename.newPathname }"
|
if projectOp.rename? then "#{ projectOp.rename.pathname} → #{ projectOp.rename.newPathname }"
|
||||||
else if projectOp.add? then "#{ projectOp.add.pathname}"
|
else if projectOp.add? then "#{ projectOp.add.pathname}"
|
||||||
|
@ -21,6 +27,7 @@ define [
|
||||||
bindings:
|
bindings:
|
||||||
entry: "<"
|
entry: "<"
|
||||||
currentUser: "<"
|
currentUser: "<"
|
||||||
|
users: "<"
|
||||||
onSelect: "&"
|
onSelect: "&"
|
||||||
onLabelDelete: "&"
|
onLabelDelete: "&"
|
||||||
controller: historyEntryController
|
controller: historyEntryController
|
||||||
|
|
|
@ -5,6 +5,9 @@ define [
|
||||||
|
|
||||||
App.controller "HistoryV2ListController", ["$scope", "$modal", "ide", ($scope, $modal, ide) ->
|
App.controller "HistoryV2ListController", ["$scope", "$modal", "ide", ($scope, $modal, ide) ->
|
||||||
$scope.hoveringOverListSelectors = false
|
$scope.hoveringOverListSelectors = false
|
||||||
|
$scope.listConfig =
|
||||||
|
showOnlyLabelled: false
|
||||||
|
$scope.projectUsers = $scope.project.members.concat $scope.project.owner
|
||||||
|
|
||||||
$scope.loadMore = () =>
|
$scope.loadMore = () =>
|
||||||
ide.historyManager.fetchNextBatchOfUpdates()
|
ide.historyManager.fetchNextBatchOfUpdates()
|
||||||
|
|
|
@ -60,24 +60,32 @@
|
||||||
font-size: @font-size-small;
|
font-size: @font-size-small;
|
||||||
margin-bottom: 3px;
|
margin-bottom: 3px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
&:last-of-type {
|
white-space: nowrap;
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
.history-entry-selected & {
|
.history-entry-selected & {
|
||||||
color: @history-entry-selected-label-color;
|
color: @history-entry-selected-label-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.history-entry-label-comment,
|
.history-entry-label-comment,
|
||||||
.history-entry-label-delete-btn {
|
.history-entry-label-delete-btn {
|
||||||
display: inline-block;
|
padding: 0 @padding-xs-horizontal 1px @padding-xs-horizontal;
|
||||||
padding: 0 (@padding-xs-horizontal / 2) 1px @padding-xs-horizontal;
|
|
||||||
border: 0;
|
border: 0;
|
||||||
background-color: @history-entry-label-bg-color;
|
background-color: @history-entry-label-bg-color;
|
||||||
border-radius: 9999px 0 0 9999px;
|
|
||||||
.history-entry-selected & {
|
.history-entry-selected & {
|
||||||
background-color: @history-entry-selected-label-bg-color;
|
background-color: @history-entry-selected-label-bg-color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.history-entry-label-comment {
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
border-radius: 9999px;
|
||||||
|
max-width: 190px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
.history-entry-label-own & {
|
||||||
|
padding-right: (@padding-xs-horizontal / 2);
|
||||||
|
border-radius: 9999px 0 0 9999px;
|
||||||
|
}
|
||||||
|
}
|
||||||
.history-entry-label-delete-btn {
|
.history-entry-label-delete-btn {
|
||||||
padding-left: (@padding-xs-horizontal / 2);
|
padding-left: (@padding-xs-horizontal / 2);
|
||||||
padding-right: @padding-xs-horizontal;
|
padding-right: @padding-xs-horizontal;
|
||||||
|
@ -90,6 +98,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.history-label-tooltip {
|
||||||
|
white-space: normal;
|
||||||
|
padding: (@line-height-computed / 4);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.history-label-tooltip-title,
|
||||||
|
.history-label-tooltip-owner,
|
||||||
|
.history-label-tooltip-datetime {
|
||||||
|
margin: 0 0 (@line-height-computed / 4) 0;
|
||||||
|
}
|
||||||
|
.history-label-tooltip-title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.history-label-tooltip-datetime {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.history-entry-changes {
|
.history-entry-changes {
|
||||||
.list-unstyled;
|
.list-unstyled;
|
||||||
margin-bottom: 3px;
|
margin-bottom: 3px;
|
||||||
|
|
Loading…
Reference in a new issue