Create history labels list component.

This commit is contained in:
Paulo Reis 2018-08-08 11:01:51 +01:00
parent 9a27a39f55
commit 7e8e2a89ae
3 changed files with 54 additions and 1 deletions

View file

@ -3,6 +3,7 @@ aside.change-list(
ng-controller="HistoryV2ListController"
)
history-entries-list(
ng-if="!history.showOnlyLabels"
entries="history.updates"
current-user="user"
users="projectUsers"
@ -13,6 +14,10 @@ aside.change-list(
on-entry-select="handleEntrySelect(selectedEntry)"
on-label-delete="handleLabelDelete(label)"
)
history-labels-list(
ng-if="history.showOnlyLabels"
labels="history.labels"
)
aside.change-list(
ng-if="history.isV2 && history.viewMode === HistoryViewModes.COMPARE"
@ -193,4 +198,15 @@ script(type="text/ng-template", id="historyEntryTpl")
li.history-entry-metadata-user(ng-if="::$ctrl.entry.meta.users.length == 0")
span.name(
ng-style="$ctrl.getUserCSSStyle();"
) #{translate("anonymous")}
) #{translate("anonymous")}
script(type="text/ng-template", id="historyLabelsListTpl")
history-label(
ng-repeat="label in $ctrl.labels"
show-tooltip="false"
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 })"
)

View file

@ -0,0 +1,29 @@
define [
"base"
"ide/history/util/displayNameForUser"
], (App, displayNameForUser) ->
historyLabelsListController = ($scope, $element, $attrs) ->
ctrl = @
# This method (and maybe the one below) will be removed soon. User details data will be
# injected into the history API responses, so we won't need to fetch user data from other
# local data structures.
_getUserById = (id) ->
_.find ctrl.users, (user) ->
curUserId = user?._id or user?.id
curUserId == id
ctrl.displayName = displayNameForUser
ctrl.displayNameById = (id) ->
displayNameForUser(_getUserById(id))
return
App.component "historyLabelsList", {
bindings:
labels: "<"
users: "<"
isLoading: "<"
currentUser: "<"
onLabelSelect: "&"
onLabelDelete: "&"
controller: historyLabelsListController
templateUrl: "historyLabelsListTpl"
}

View file

@ -27,6 +27,14 @@
margin-left: (@line-height-computed / 2);
}
.history-toolbar-entries-list {
position: absolute;
right: 0;
width: @changesListWidth;
padding: 0 10px;
border-left: 1px solid @editor-border-color;
}
.history-entries {
font-size: @history-base-font-size;
color: @history-base-color;