From b0261970fc3d88abe9314d4bf1dcd6cc68806712 Mon Sep 17 00:00:00 2001 From: Paulo Reis <paulojreis@gmail.com> Date: Mon, 6 Aug 2018 11:26:22 +0100 Subject: [PATCH] Make label removal also work in compare mode. --- .../web/app/views/project/editor/history.pug | 23 ++++++++++++++++++ .../project/editor/history/entriesListV2.pug | 2 +- .../project/editor/history/toolbarV2.pug | 24 +------------------ .../history/components/historyEntry.coffee | 3 +++ .../controllers/HistoryListController.coffee | 3 +++ 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/services/web/app/views/project/editor/history.pug b/services/web/app/views/project/editor/history.pug index 6281bbee49..2f3f317561 100644 --- a/services/web/app/views/project/editor/history.pug +++ b/services/web/app/views/project/editor/history.pug @@ -93,3 +93,26 @@ script(type="text/ng-template", id="historyLabelTooltipTpl") | {{ $ctrl.labelText }} p.history-label-tooltip-owner #{translate("history_label_created_by")} {{ $ctrl.labelOwnerName }} time.history-label-tooltip-datetime {{ labelCreationDateTime | formatDate }} + + +script(type="text/ng-template", id="historyV2DeleteLabelModalTemplate") + .modal-header + h3 #{translate("history_delete_label")} + .modal-body + .alert.alert-danger(ng-show="state.error.message") {{ state.error.message}} + .alert.alert-danger(ng-show="state.error && !state.error.message") #{translate("generic_something_went_wrong")} + p.help-block(ng-if="labelDetails") + | #{translate("history_are_you_sure_delete_label")} + strong "{{ labelDetails.comment }}" + | ? + .modal-footer + button.btn.btn-default( + type="button" + ng-disabled="state.inflight" + ng-click="$dismiss()" + ) #{translate("cancel")} + button.btn.btn-primary( + type="button" + ng-click="deleteLabel()" + ng-disabled="state.inflight" + ) {{ state.inflight ? '#{translate("history_deleting_label")}' : '#{translate("history_delete_label")}' }} diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index 337b5e33ce..e08de0effd 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -72,7 +72,7 @@ aside.change-list( label-text="label.comment" label-owner-name="getDisplayNameById(label.user_id)" label-creation-date-time="label.created_at" - is-owned-by-current-user="label.user_id === $ctrl.currentUser.id" + is-owned-by-current-user="label.user_id === user.id" on-label-delete="deleteLabel(label)" ) div.time {{ update.meta.end_ts | formatDate:'h:mm a' }} diff --git a/services/web/app/views/project/editor/history/toolbarV2.pug b/services/web/app/views/project/editor/history/toolbarV2.pug index b4afe439b3..2a4c222bad 100644 --- a/services/web/app/views/project/editor/history/toolbarV2.pug +++ b/services/web/app/views/project/editor/history/toolbarV2.pug @@ -52,26 +52,4 @@ script(type="text/ng-template", id="historyV2AddLabelModalTemplate") ng-disabled="addLabelModalForm.$invalid || state.inflight" ng-value="state.inflight ? '" + translate("history_adding_label") + "' : '" + translate("history_add_label") + "'" type="submit" - ) - -script(type="text/ng-template", id="historyV2DeleteLabelModalTemplate") - .modal-header - h3 #{translate("history_delete_label")} - .modal-body - .alert.alert-danger(ng-show="state.error.message") {{ state.error.message}} - .alert.alert-danger(ng-show="state.error && !state.error.message") #{translate("generic_something_went_wrong")} - p.help-block(ng-if="labelDetails") - | #{translate("history_are_you_sure_delete_label")}: - strong "{{ labelDetails.comment }}" - | ? - .modal-footer - button.btn.btn-default( - type="button" - ng-disabled="state.inflight" - ng-click="$dismiss()" - ) #{translate("cancel")} - button.btn.btn-primary( - type="button" - ng-click="deleteLabel()" - ng-disabled="state.inflight" - ) {{ state.inflight ? '#{translate("history_deleting_label")}' : '#{translate("history_delete_label")}' }} + ) \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/components/historyEntry.coffee b/services/web/public/coffee/ide/history/components/historyEntry.coffee index eb7f1e7266..0942613ef2 100644 --- a/services/web/public/coffee/ide/history/components/historyEntry.coffee +++ b/services/web/public/coffee/ide/history/components/historyEntry.coffee @@ -4,6 +4,9 @@ define [ ], (App, displayNameForUser) -> historyEntryController = ($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 diff --git a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee index 90c8142c6c..cfd5bb75c5 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee @@ -8,6 +8,9 @@ define [ projectUsers = $scope.project.members.concat $scope.project.owner + # 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 projectUsers, (user) -> curUserId = user?._id or user?.id