From 3a80c3407891c828c227fecdfcee6aa6678dbcd4 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 26 Jul 2018 16:49:04 +0100 Subject: [PATCH 01/13] Basic label support (showing labels in the entries list; creating labels via a modal). --- .../project/editor/history/entriesListV2.pug | 6 +++ .../project/editor/history/toolbarV2.pug | 47 +++++++++++++++++-- .../ide/history/HistoryV2Manager.coffee | 39 +++++++++++---- .../HistoryV2AddLabelModalController.coffee | 28 +++++++++++ .../HistoryV2ToolbarController.coffee | 10 ++++ services/web/public/robots.txt | 21 ++++++++- .../stylesheets/app/editor/history-v2.less | 10 ++++ .../stylesheets/core/_common-variables.less | 1 + .../public/stylesheets/core/ol-variables.less | 1 + 9 files changed, 149 insertions(+), 14 deletions(-) create mode 100644 services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee create mode 100644 services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index fa7a90b20e..155ad6a3fd 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -129,6 +129,12 @@ 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 }} .history-entry-details(ng-click="$ctrl.onSelect({ selectedEntry: $ctrl.entry })") + .history-entry-label( + ng-if="$ctrl.entry.labels.length > 0" + ng-repeat="label in ::$ctrl.entry.labels" + ) + i.fa.fa-tag + |  {{ label.comment }} ol.history-entry-changes li.history-entry-change( ng-repeat="pathname in ::$ctrl.entry.pathnames" diff --git a/services/web/app/views/project/editor/history/toolbarV2.pug b/services/web/app/views/project/editor/history/toolbarV2.pug index 799a7136f3..b53e54f95c 100644 --- a/services/web/app/views/project/editor/history/toolbarV2.pug +++ b/services/web/app/views/project/editor/history/toolbarV2.pug @@ -1,4 +1,5 @@ .history-toolbar( + ng-controller="HistoryV2ToolbarController" ng-if="ui.view == 'history' && history.isV2 && history.viewMode === HistoryViewModes.POINT_IN_TIME" ) span(ng-show="history.loadingFileTree") @@ -6,8 +7,46 @@ |    #{translate("loading")}... span(ng-show="!history.loadingFileTree") #{translate("browsing_project_as_of")}  time.history-toolbar-time {{ history.selection.updates[0].meta.end_ts | formatDate:'Do MMM YYYY, h:mm a' }} - .history-toolbar-btn( - ng-click="toggleHistoryViewMode();" + button.history-toolbar-btn( + ng-click="showAddLabelDialog();" + ng-disabled="history.loadingFileTree" ) - i.fa - | #{translate("compare_to_another_version")} \ No newline at end of file + i.fa.fa-tag + |  Label this version + button.history-toolbar-btn( + ng-click="toggleHistoryViewMode();" + ng-disabled="history.loadingFileTree" + ) + i.fa.fa-exchange + |  #{translate("compare_to_another_version")} + +script(type="text/ng-template", id="historyV2AddLabelModalTemplate") + form( + name="addLabelModalForm" + ng-submit="addLabelModalFormSubmit();" + novalidate + ) + .modal-header + h3 Label this version + .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")} + .form-group + input.form-control( + type="text" + placeholder="New label name" + ng-model="inputs.labelName" + focus-on="open" + required + ) + .modal-footer + button.btn.btn-default( + type="button" + ng-disabled="state.inflight" + ng-click="$dismiss()" + ) #{translate("cancel")} + input.btn.btn-primary( + ng-disabled="addLabelModalForm.$invalid || state.inflight" + ng-value="state.inflight ? 'Adding label' : 'Add label'" + type="submit" + ) \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee index 7c8f476e39..e3623bb1fa 100644 --- a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee +++ b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee @@ -6,6 +6,8 @@ define [ "ide/history/controllers/HistoryV2ListController" "ide/history/controllers/HistoryV2DiffController" "ide/history/controllers/HistoryV2FileTreeController" + "ide/history/controllers/HistoryV2ToolbarController" + "ide/history/controllers/HistoryV2AddLabelModalController" "ide/history/directives/infiniteScroll" "ide/history/components/historyEntriesList" "ide/history/components/historyEntry" @@ -68,6 +70,7 @@ define [ toV: null } } + labels: null files: [] diff: null # When history.viewMode == HistoryViewModes.COMPARE selectedFile: null # When history.viewMode == HistoryViewModes.POINT_IN_TIME @@ -126,18 +129,25 @@ define [ BATCH_SIZE: 10 fetchNextBatchOfUpdates: () -> - url = "/project/#{@ide.project_id}/updates?min_count=#{@BATCH_SIZE}" + updatesURL = "/project/#{@ide.project_id}/updates?min_count=#{@BATCH_SIZE}" if @$scope.history.nextBeforeTimestamp? - url += "&before=#{@$scope.history.nextBeforeTimestamp}" + updatesURL += "&before=#{@$scope.history.nextBeforeTimestamp}" + @$scope.history.loading = true @$scope.history.loadingFileTree = true - @ide.$http - .get(url) - .then (response) => - { data } = response - @_loadUpdates(data.updates) - @$scope.history.nextBeforeTimestamp = data.nextBeforeTimestamp - if !data.nextBeforeTimestamp? + + requests = + updates: @ide.$http.get updatesURL + + if !@$scope.history.labels? + requests.labels = @ide.$http.get "/project/#{@ide.project_id}/labels" + + @ide.$q.all requests + .then (responses) => + updatesData = responses.updates.data + @_loadUpdates(updatesData.updates) + @$scope.history.nextBeforeTimestamp = updatesData.nextBeforeTimestamp + if !updatesData.nextBeforeTimestamp? @$scope.history.atEnd = true @$scope.history.loading = false @@ -199,6 +209,9 @@ define [ diff.loading = false diff.error = true + labelCurrentVersion: (labelComment) => + @_labelVersion labelComment, @$scope.history.selection.updates[0].toV + _parseDiff: (diff) -> if diff.binary return { binary: true } @@ -278,6 +291,14 @@ define [ else @autoSelectLastUpdate() + _labelVersion: (comment, version) -> + url = "/project/#{@$scope.project_id}/labels" + @ide.$http.post url, { + comment, + version, + _csrf: window.csrfToken + } + _perDocSummaryOfUpdates: (updates) -> # Track current_pathname -> original_pathname # create bare object for use as Map diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee new file mode 100644 index 0000000000..39b83d8998 --- /dev/null +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee @@ -0,0 +1,28 @@ +define [ + "base", +], (App) -> + App.controller "HistoryV2AddLabelModalController", ["$scope", "$modalInstance", "ide", ($scope, $modalInstance, ide) -> + $scope.inputs = + labelName: null + $scope.state = + inflight: false + error: false + + $modalInstance.opened.then () -> + $scope.$applyAsync () -> + $scope.$broadcast "open" + + $scope.addLabelModalFormSubmit = () -> + $scope.state.inflight = true + ide.historyManager.labelCurrentVersion $scope.inputs.labelName + .then (response) -> + $scope.state.inflight = false + $modalInstance.close() + .catch (response) -> + { data, status } = response + $scope.state.inflight = false + if status == 400 + $scope.state.error = { message: data } + else + $scope.state.error = true + ] \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee new file mode 100644 index 0000000000..ed8dee63ec --- /dev/null +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee @@ -0,0 +1,10 @@ +define [ + "base", +], (App) -> + App.controller "HistoryV2ToolbarController", ["$scope", "$modal", "ide", ($scope, $modal, ide) -> + $scope.showAddLabelDialog = () -> + $modal.open( + templateUrl: "historyV2AddLabelModalTemplate" + controller: "HistoryV2AddLabelModalController" + ) + ] \ No newline at end of file diff --git a/services/web/public/robots.txt b/services/web/public/robots.txt index 77470cb39f..e241feebcc 100644 --- a/services/web/public/robots.txt +++ b/services/web/public/robots.txt @@ -1,2 +1,21 @@ +# robots.txt for https://www.sharelatex.com/ + User-agent: * -Disallow: / \ No newline at end of file +Disallow: /project/* +Disallow: /github/repos/* +Disallow: /recurly.com +Disallow: /user/password/set +Disallow: /learn-scripts/* +Allow: / + +User-Agent: AhrefsBot +Disallow: / + +User-Agent: XoviBot +Disallow: / + +User-Agent: RankSonicBot +Disallow: / + +User-Agent: SMTBot +Disallow: / diff --git a/services/web/public/stylesheets/app/editor/history-v2.less b/services/web/public/stylesheets/app/editor/history-v2.less index 9089ed1ae9..3e0d5f7ebc 100644 --- a/services/web/public/stylesheets/app/editor/history-v2.less +++ b/services/web/public/stylesheets/app/editor/history-v2.less @@ -53,6 +53,16 @@ color: #FFF; } } + + .history-entry-label { + color: @history-entry-label-color; + font-weight: bold; + margin-bottom: 3px; + .history-entry-selected & { + color: #FFF; + } + } + .history-entry-changes { .list-unstyled; margin-bottom: 3px; diff --git a/services/web/public/stylesheets/core/_common-variables.less b/services/web/public/stylesheets/core/_common-variables.less index fefe12da73..ac2afdca45 100644 --- a/services/web/public/stylesheets/core/_common-variables.less +++ b/services/web/public/stylesheets/core/_common-variables.less @@ -988,6 +988,7 @@ // v2 History @history-base-font-size : @font-size-small; @history-base-bg : @gray-lightest; +@history-entry-label-color : @red; @history-entry-day-bg : @gray; @history-entry-selected-bg : @red; @history-base-color : @gray-light; diff --git a/services/web/public/stylesheets/core/ol-variables.less b/services/web/public/stylesheets/core/ol-variables.less index 0e05ccdd68..40e53a0c71 100644 --- a/services/web/public/stylesheets/core/ol-variables.less +++ b/services/web/public/stylesheets/core/ol-variables.less @@ -277,6 +277,7 @@ // v2 History @history-base-font-size : @font-size-small; @history-base-bg : @ol-blue-gray-1; +@history-entry-label-color : @ol-blue; @history-entry-day-bg : @ol-blue-gray-2; @history-entry-selected-bg : @ol-green; @history-base-color : @ol-blue-gray-2; From 5a64313e245606315ab9c5c09625fcf6d81079fd Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 1 Aug 2018 12:17:29 +0100 Subject: [PATCH 02/13] Add label delete functionality; styles. --- .../project/editor/history/entriesListV2.pug | 12 +++++-- .../project/editor/history/toolbarV2.pug | 29 +++++++++++++++-- .../ide/history/HistoryV2Manager.coffee | 31 +++++++++++++------ .../components/historyEntriesList.coffee | 1 + .../history/components/historyEntry.coffee | 1 + .../HistoryV2AddLabelModalController.coffee | 3 +- ...HistoryV2DeleteLabelModalController.coffee | 23 ++++++++++++++ .../HistoryV2ListController.coffee | 11 +++++-- .../HistoryV2ToolbarController.coffee | 2 ++ .../stylesheets/app/editor/history-v2.less | 30 ++++++++++++++++-- .../stylesheets/core/_common-variables.less | 21 +++++++------ .../public/stylesheets/core/ol-variables.less | 21 +++++++------ 12 files changed, 149 insertions(+), 36 deletions(-) create mode 100644 services/web/public/coffee/ide/history/controllers/HistoryV2DeleteLabelModalController.coffee diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index 155ad6a3fd..ba7492663c 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -10,6 +10,7 @@ aside.change-list( load-initialize="ui.view == 'history'" is-loading="history.loading" on-entry-select="handleEntrySelect(selectedEntry)" + on-label-delete="handleLabelDelete(label)" ) aside.change-list( @@ -107,6 +108,7 @@ script(type="text/ng-template", id="historyEntriesListTpl") entry="entry" current-user="$ctrl.currentUser" on-select="$ctrl.onEntrySelect({ selectedEntry: selectedEntry })" + on-label-delete="$ctrl.onLabelDelete({ label: label })" ng-show="!$ctrl.isLoading" ) .loading(ng-show="$ctrl.isLoading") @@ -133,8 +135,14 @@ script(type="text/ng-template", id="historyEntryTpl") ng-if="$ctrl.entry.labels.length > 0" ng-repeat="label in ::$ctrl.entry.labels" ) - i.fa.fa-tag - |  {{ label.comment }} + 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 li.history-entry-change( ng-repeat="pathname in ::$ctrl.entry.pathnames" diff --git a/services/web/app/views/project/editor/history/toolbarV2.pug b/services/web/app/views/project/editor/history/toolbarV2.pug index b53e54f95c..1b8b733154 100644 --- a/services/web/app/views/project/editor/history/toolbarV2.pug +++ b/services/web/app/views/project/editor/history/toolbarV2.pug @@ -27,7 +27,7 @@ script(type="text/ng-template", id="historyV2AddLabelModalTemplate") novalidate ) .modal-header - h3 Label this version + h3 Add 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")} @@ -39,6 +39,9 @@ script(type="text/ng-template", id="historyV2AddLabelModalTemplate") focus-on="open" required ) + p.help-block(ng-if="update") + | A new label will be added as of + strong {{ update.meta.end_ts | formatDate:'ddd Do MMM YYYY, h:mm a' }} .modal-footer button.btn.btn-default( type="button" @@ -49,4 +52,26 @@ script(type="text/ng-template", id="historyV2AddLabelModalTemplate") ng-disabled="addLabelModalForm.$invalid || state.inflight" ng-value="state.inflight ? 'Adding label' : 'Add label'" type="submit" - ) \ No newline at end of file + ) + +script(type="text/ng-template", id="historyV2DeleteLabelModalTemplate") + .modal-header + h3 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") + | Are you sure you want to delete the following 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 ? 'Deleting label' : 'Delete label' }} \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee index e3623bb1fa..3a8640ac9a 100644 --- a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee +++ b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee @@ -8,6 +8,7 @@ define [ "ide/history/controllers/HistoryV2FileTreeController" "ide/history/controllers/HistoryV2ToolbarController" "ide/history/controllers/HistoryV2AddLabelModalController" + "ide/history/controllers/HistoryV2DeleteLabelModalController" "ide/history/directives/infiniteScroll" "ide/history/components/historyEntriesList" "ide/history/components/historyEntry" @@ -136,15 +137,9 @@ define [ @$scope.history.loading = true @$scope.history.loadingFileTree = true - requests = - updates: @ide.$http.get updatesURL - - if !@$scope.history.labels? - requests.labels = @ide.$http.get "/project/#{@ide.project_id}/labels" - - @ide.$q.all requests - .then (responses) => - updatesData = responses.updates.data + @ide.$http.get updatesURL + .then (response) => + updatesData = response.data @_loadUpdates(updatesData.updates) @$scope.history.nextBeforeTimestamp = updatesData.nextBeforeTimestamp if !updatesData.nextBeforeTimestamp? @@ -212,6 +207,24 @@ define [ labelCurrentVersion: (labelComment) => @_labelVersion labelComment, @$scope.history.selection.updates[0].toV + deleteLabel: (labelId) => + url = "/project/#{@$scope.project_id}/labels/#{labelId}" + + @ide.$http({ + url, + method: "DELETE" + headers: + "X-CSRF-Token": window.csrfToken + }).then (response) => + @_deleteLabelFromLocalCollection @$scope.history.updates, labelId + @_deleteLabelFromLocalCollection @$scope.history.selection, labelId + + + _deleteLabelFromLocalCollection: (collection, labelId) -> + for update in collection + update.labels = _.filter update.labels, (label) -> + label.id != labelId + _parseDiff: (diff) -> if diff.binary return { binary: true } diff --git a/services/web/public/coffee/ide/history/components/historyEntriesList.coffee b/services/web/public/coffee/ide/history/components/historyEntriesList.coffee index 5022724714..82331258ec 100644 --- a/services/web/public/coffee/ide/history/components/historyEntriesList.coffee +++ b/services/web/public/coffee/ide/history/components/historyEntriesList.coffee @@ -14,6 +14,7 @@ define [ isLoading: "<" currentUser: "<" onEntrySelect: "&" + onLabelDelete: "&" controller: historyEntriesListController templateUrl: "historyEntriesListTpl" } diff --git a/services/web/public/coffee/ide/history/components/historyEntry.coffee b/services/web/public/coffee/ide/history/components/historyEntry.coffee index e2692b7dee..46018d3a32 100644 --- a/services/web/public/coffee/ide/history/components/historyEntry.coffee +++ b/services/web/public/coffee/ide/history/components/historyEntry.coffee @@ -22,6 +22,7 @@ define [ entry: "<" currentUser: "<" onSelect: "&" + onLabelDelete: "&" controller: historyEntryController templateUrl: "historyEntryTpl" } \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee index 39b83d8998..cbe72b0dce 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2AddLabelModalController.coffee @@ -1,7 +1,8 @@ define [ "base", ], (App) -> - App.controller "HistoryV2AddLabelModalController", ["$scope", "$modalInstance", "ide", ($scope, $modalInstance, ide) -> + App.controller "HistoryV2AddLabelModalController", ["$scope", "$modalInstance", "ide", "update", ($scope, $modalInstance, ide, update) -> + $scope.update = update $scope.inputs = labelName: null $scope.state = diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2DeleteLabelModalController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2DeleteLabelModalController.coffee new file mode 100644 index 0000000000..d03786c2c6 --- /dev/null +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2DeleteLabelModalController.coffee @@ -0,0 +1,23 @@ +define [ + "base", +], (App) -> + App.controller "HistoryV2DeleteLabelModalController", ["$scope", "$modalInstance", "ide", "labelDetails", ($scope, $modalInstance, ide, labelDetails) -> + $scope.labelDetails = labelDetails + $scope.state = + inflight: false + error: false + + $scope.deleteLabel = () -> + $scope.state.inflight = true + ide.historyManager.deleteLabel labelDetails.id + .then (response) -> + $scope.state.inflight = false + $modalInstance.close() + .catch (response) -> + { data, status } = response + $scope.state.inflight = false + if status == 400 + $scope.state.error = { message: data } + else + $scope.state.error = true + ] \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee index eaf7fbc884..d63f9329ae 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee @@ -3,17 +3,24 @@ define [ "ide/history/util/displayNameForUser" ], (App, displayNameForUser) -> - App.controller "HistoryV2ListController", ["$scope", "ide", ($scope, ide) -> + App.controller "HistoryV2ListController", ["$scope", "$modal", "ide", ($scope, $modal, ide) -> $scope.hoveringOverListSelectors = false $scope.loadMore = () => ide.historyManager.fetchNextBatchOfUpdates() $scope.handleEntrySelect = (entry) -> - # $scope.$applyAsync () -> ide.historyManager.selectUpdate(entry) $scope.recalculateSelectedUpdates() + $scope.handleLabelDelete = (labelDetails) -> + $modal.open( + templateUrl: "historyV2DeleteLabelModalTemplate" + controller: "HistoryV2DeleteLabelModalController" + resolve: + labelDetails: () -> labelDetails + ) + $scope.recalculateSelectedUpdates = () -> beforeSelection = true afterSelection = false diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee index ed8dee63ec..3feb9f8a7d 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2ToolbarController.coffee @@ -6,5 +6,7 @@ define [ $modal.open( templateUrl: "historyV2AddLabelModalTemplate" controller: "HistoryV2AddLabelModalController" + resolve: + update: () -> $scope.history.selection.updates[0] ) ] \ No newline at end of file diff --git a/services/web/public/stylesheets/app/editor/history-v2.less b/services/web/public/stylesheets/app/editor/history-v2.less index 3e0d5f7ebc..9e099422c5 100644 --- a/services/web/public/stylesheets/app/editor/history-v2.less +++ b/services/web/public/stylesheets/app/editor/history-v2.less @@ -56,12 +56,38 @@ .history-entry-label { color: @history-entry-label-color; - font-weight: bold; + font-size: @font-size-small; margin-bottom: 3px; + margin-right: 10px; + &:last-of-type { + margin-right: 0; + } .history-entry-selected & { - color: #FFF; + color: @history-entry-selected-label-color; } } + .history-entry-label-comment, + .history-entry-label-delete-btn { + display: inline-block; + padding: 0 (@padding-xs-horizontal / 2) 1px @padding-xs-horizontal; + border: 0; + background-color: @history-entry-label-bg-color; + border-radius: 9999px 0 0 9999px; + .history-entry-selected & { + background-color: @history-entry-selected-label-bg-color; + } + } + .history-entry-label-delete-btn { + padding-left: (@padding-xs-horizontal / 2); + padding-right: @padding-xs-horizontal; + border-radius: 0 9999px 9999px 0; + &:hover { + background-color: darken(@history-entry-label-bg-color, 8%); + .history-entry-selected & { + background-color: darken(@history-entry-selected-label-bg-color, 8%); + } + } + } .history-entry-changes { .list-unstyled; diff --git a/services/web/public/stylesheets/core/_common-variables.less b/services/web/public/stylesheets/core/_common-variables.less index ac2afdca45..aef1f2b5a2 100644 --- a/services/web/public/stylesheets/core/_common-variables.less +++ b/services/web/public/stylesheets/core/_common-variables.less @@ -986,15 +986,18 @@ @sys-msg-border : 1px solid @common-border-color; // v2 History -@history-base-font-size : @font-size-small; -@history-base-bg : @gray-lightest; -@history-entry-label-color : @red; -@history-entry-day-bg : @gray; -@history-entry-selected-bg : @red; -@history-base-color : @gray-light; -@history-highlight-color : @gray; -@history-toolbar-bg-color : @toolbar-alt-bg-color; -@history-toolbar-color : @text-color; +@history-base-font-size : @font-size-small; +@history-base-bg : @gray-lightest; +@history-entry-label-bg-color : @red; +@history-entry-label-color : #FFF; +@history-entry-selected-label-bg-color : #FFF; +@history-entry-selected-label-color : @red; +@history-entry-day-bg : @gray; +@history-entry-selected-bg : @red; +@history-base-color : @gray-light; +@history-highlight-color : @gray; +@history-toolbar-bg-color : @toolbar-alt-bg-color; +@history-toolbar-color : @text-color; // Input suggestions @input-suggestion-v-offset : 6px; diff --git a/services/web/public/stylesheets/core/ol-variables.less b/services/web/public/stylesheets/core/ol-variables.less index 40e53a0c71..b75de6086d 100644 --- a/services/web/public/stylesheets/core/ol-variables.less +++ b/services/web/public/stylesheets/core/ol-variables.less @@ -275,15 +275,18 @@ // v2 History -@history-base-font-size : @font-size-small; -@history-base-bg : @ol-blue-gray-1; -@history-entry-label-color : @ol-blue; -@history-entry-day-bg : @ol-blue-gray-2; -@history-entry-selected-bg : @ol-green; -@history-base-color : @ol-blue-gray-2; -@history-highlight-color : @ol-type-color; -@history-toolbar-bg-color : @editor-toolbar-bg; -@history-toolbar-color : #FFF; +@history-base-font-size : @font-size-small; +@history-base-bg : @ol-blue-gray-1; +@history-entry-label-bg-color : @ol-blue; +@history-entry-label-color : #FFF; +@history-entry-selected-label-bg-color: #FFF; +@history-entry-selected-label-color : @ol-blue; +@history-entry-day-bg : @ol-blue-gray-2; +@history-entry-selected-bg : @ol-green; +@history-base-color : @ol-blue-gray-2; +@history-highlight-color : @ol-type-color; +@history-toolbar-bg-color : @editor-toolbar-bg; +@history-toolbar-color : #FFF; // System messages @sys-msg-background : @ol-blue; From d21f6ef62452ce560758834d4818774c091d129d Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 1 Aug 2018 16:03:45 +0100 Subject: [PATCH 03/13] Label handling in compare mode. --- .../project/editor/history/entriesListV2.pug | 15 ++++++++++++++- .../coffee/ide/history/HistoryV2Manager.coffee | 18 +++++++++++++----- .../controllers/HistoryListController.coffee | 10 +++++++++- .../stylesheets/app/editor/history-v2.less | 1 + 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index ba7492663c..4cbed71fda 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -66,6 +66,18 @@ aside.change-list( ) div.description(ng-click="select()") + div + .history-entry-label( + ng-if="update.labels.length > 0" + ng-repeat="label in update.labels" + ) + span.history-entry-label-comment + i.fa.fa-tag + |  {{ label.comment }} + button.history-entry-label-delete-btn( + stop-propagation="click" + ng-click="deleteLabel(label)" + ) × div.time {{ update.meta.end_ts | formatDate:'h:mm a' }} div.action.action-edited(ng-if="history.isV2 && update.pathnames.length > 0") | #{translate("file_action_edited")} @@ -133,7 +145,7 @@ script(type="text/ng-template", id="historyEntryTpl") .history-entry-details(ng-click="$ctrl.onSelect({ selectedEntry: $ctrl.entry })") .history-entry-label( ng-if="$ctrl.entry.labels.length > 0" - ng-repeat="label in ::$ctrl.entry.labels" + ng-repeat="label in $ctrl.entry.labels" ) span.history-entry-label-comment i.fa.fa-tag @@ -162,6 +174,7 @@ script(type="text/ng-template", id="historyEntryTpl") ng-if="::project_op.remove" ) #{translate("file_action_deleted")} span.history-entry-change-doc {{ ::$ctrl.getProjectOpDoc(project_op) }} + .history-entry-metadata time.history-entry-metadata-time {{ ::$ctrl.entry.meta.end_ts | formatDate:'h:mm a' }} span diff --git a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee index 3a8640ac9a..a921cacb08 100644 --- a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee +++ b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee @@ -306,11 +306,19 @@ define [ _labelVersion: (comment, version) -> url = "/project/#{@$scope.project_id}/labels" - @ide.$http.post url, { - comment, - version, - _csrf: window.csrfToken - } + @ide.$http + .post url, { + comment, + version, + _csrf: window.csrfToken + } + .then (response) => + @_addLabelToLocalUpdate response.data + + _addLabelToLocalUpdate: (label) -> + localUpdate = _.find @$scope.history.updates, (update) -> update.toV == label.version + if localUpdate? + localUpdate.labels.push label _perDocSummaryOfUpdates: (updates) -> # Track current_pathname -> original_pathname diff --git a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee index 4b0786d259..e4bc2b541d 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee @@ -3,9 +3,17 @@ define [ "ide/history/util/displayNameForUser" ], (App, displayNameForUser) -> - App.controller "HistoryListController", ["$scope", "ide", ($scope, ide) -> + App.controller "HistoryListController", ["$scope", "$modal", "ide", ($scope, $modal, ide) -> $scope.hoveringOverListSelectors = false + $scope.deleteLabel = (labelDetails) -> + $modal.open( + templateUrl: "historyV2DeleteLabelModalTemplate" + controller: "HistoryV2DeleteLabelModalController" + resolve: + labelDetails: () -> labelDetails + ) + $scope.loadMore = () => ide.historyManager.fetchNextBatchOfUpdates() diff --git a/services/web/public/stylesheets/app/editor/history-v2.less b/services/web/public/stylesheets/app/editor/history-v2.less index 9e099422c5..7ed37d49b1 100644 --- a/services/web/public/stylesheets/app/editor/history-v2.less +++ b/services/web/public/stylesheets/app/editor/history-v2.less @@ -55,6 +55,7 @@ } .history-entry-label { + display: inline-block; color: @history-entry-label-color; font-size: @font-size-small; margin-bottom: 3px; From 8c50e4e9aec4fbe76d145cd14d4ecfe95d8047f7 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 2 Aug 2018 15:28:59 +0100 Subject: [PATCH 04/13] Add history label component. --- .../ide/history/components/historyLabel.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 services/web/public/coffee/ide/history/components/historyLabel.coffee diff --git a/services/web/public/coffee/ide/history/components/historyLabel.coffee b/services/web/public/coffee/ide/history/components/historyLabel.coffee new file mode 100644 index 0000000000..2394b76f8b --- /dev/null +++ b/services/web/public/coffee/ide/history/components/historyLabel.coffee @@ -0,0 +1,17 @@ +define [ + "base" +], (App) -> + historyLabelController = ($scope, $element, $attrs, $filter, _) -> + ctrl = @ + return + + App.component "historyLabel", { + bindings: + labelText: "<" + labelOwnerName: "<" + labelCreationDateTime: "<" + isOwnedByCurrentUser: "<" + onLabelDelete: "&" + controller: historyLabelController + templateUrl: "historyLabelTpl" + } \ No newline at end of file From a8ee87974653e9f679f8034573f9d0288c290b5e Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 2 Aug 2018 15:29:12 +0100 Subject: [PATCH 05/13] Use history label component; restrict label deletion to label owners. --- .../project/editor/history/entriesListV2.pug | 46 ++++++++++++++----- .../ide/history/HistoryV2Manager.coffee | 1 + .../components/historyEntriesList.coffee | 4 ++ .../history/components/historyEntry.coffee | 9 +++- .../HistoryV2ListController.coffee | 3 ++ .../stylesheets/app/editor/history-v2.less | 37 ++++++++++++--- 6 files changed, 82 insertions(+), 18 deletions(-) diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index 4cbed71fda..b96c74947d 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -5,10 +5,12 @@ aside.change-list( history-entries-list( entries="history.updates" current-user="user" + users="projectUsers" load-entries="loadMore()" load-disabled="history.loading || history.atEnd" load-initialize="ui.view == 'history'" is-loading="history.loading" + show-only-labelled="listConfig.showOnlyLabelled" on-entry-select="handleEntrySelect(selectedEntry)" on-label-delete="handleLabelDelete(label)" ) @@ -116,9 +118,10 @@ script(type="text/ng-template", id="historyEntriesListTpl") ) .infinite-scroll-inner history-entry( - ng-repeat="entry in $ctrl.entries" + ng-repeat="entry in $ctrl.entries | filter:$ctrl.shouldShowEntry" entry="entry" current-user="$ctrl.currentUser" + users="$ctrl.users" on-select="$ctrl.onEntrySelect({ selectedEntry: selectedEntry })" on-label-delete="$ctrl.onLabelDelete({ label: label })" 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 }} .history-entry-details(ng-click="$ctrl.onSelect({ selectedEntry: $ctrl.entry })") - .history-entry-label( - ng-if="$ctrl.entry.labels.length > 0" + history-label( 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 li.history-entry-change( @@ -198,4 +198,28 @@ 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")} \ No newline at end of file + ) #{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 }} \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee index a921cacb08..7ff41985f4 100644 --- a/services/web/public/coffee/ide/history/HistoryV2Manager.coffee +++ b/services/web/public/coffee/ide/history/HistoryV2Manager.coffee @@ -12,6 +12,7 @@ define [ "ide/history/directives/infiniteScroll" "ide/history/components/historyEntriesList" "ide/history/components/historyEntry" + "ide/history/components/historyLabel" "ide/history/components/historyFileTree" "ide/history/components/historyFileEntity" ], (moment, ColorManager, displayNameForUser, HistoryViewModes) -> diff --git a/services/web/public/coffee/ide/history/components/historyEntriesList.coffee b/services/web/public/coffee/ide/history/components/historyEntriesList.coffee index 82331258ec..f872b5d72a 100644 --- a/services/web/public/coffee/ide/history/components/historyEntriesList.coffee +++ b/services/web/public/coffee/ide/history/components/historyEntriesList.coffee @@ -3,11 +3,14 @@ define [ ], (App) -> historyEntriesListController = ($scope, $element, $attrs) -> ctrl = @ + ctrl.shouldShowEntry = (entry) -> + !(ctrl.showOnlyLabelled and entry.labels.length == 0) return App.component "historyEntriesList", { bindings: entries: "<" + users: "<" loadEntries: "&" loadDisabled: "<" loadInitialize: "<" @@ -15,6 +18,7 @@ define [ currentUser: "<" onEntrySelect: "&" onLabelDelete: "&" + showOnlyLabelled: "<" controller: historyEntriesListController templateUrl: "historyEntriesListTpl" } diff --git a/services/web/public/coffee/ide/history/components/historyEntry.coffee b/services/web/public/coffee/ide/history/components/historyEntry.coffee index 46018d3a32..2995c5f481 100644 --- a/services/web/public/coffee/ide/history/components/historyEntry.coffee +++ b/services/web/public/coffee/ide/history/components/historyEntry.coffee @@ -2,9 +2,15 @@ define [ "base" "ide/history/util/displayNameForUser" ], (App, displayNameForUser) -> - historyEntryController = ($scope, $element, $attrs) -> + historyEntryController = ($scope, $element, $attrs, $filter, _) -> ctrl = @ + _getUserById = (id) -> + _.find ctrl.users, (user) -> + curUserId = user?._id or user?.id + curUserId == id ctrl.displayName = displayNameForUser + ctrl.displayNameById = (id) -> + displayNameForUser(_getUserById(id)) ctrl.getProjectOpDoc = (projectOp) -> if projectOp.rename? then "#{ projectOp.rename.pathname} → #{ projectOp.rename.newPathname }" else if projectOp.add? then "#{ projectOp.add.pathname}" @@ -21,6 +27,7 @@ define [ bindings: entry: "<" currentUser: "<" + users: "<" onSelect: "&" onLabelDelete: "&" controller: historyEntryController diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee index d63f9329ae..f7c602733f 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2ListController.coffee @@ -5,6 +5,9 @@ define [ App.controller "HistoryV2ListController", ["$scope", "$modal", "ide", ($scope, $modal, ide) -> $scope.hoveringOverListSelectors = false + $scope.listConfig = + showOnlyLabelled: false + $scope.projectUsers = $scope.project.members.concat $scope.project.owner $scope.loadMore = () => ide.historyManager.fetchNextBatchOfUpdates() diff --git a/services/web/public/stylesheets/app/editor/history-v2.less b/services/web/public/stylesheets/app/editor/history-v2.less index 7ed37d49b1..404609917a 100644 --- a/services/web/public/stylesheets/app/editor/history-v2.less +++ b/services/web/public/stylesheets/app/editor/history-v2.less @@ -60,24 +60,32 @@ font-size: @font-size-small; margin-bottom: 3px; margin-right: 10px; - &:last-of-type { - margin-right: 0; - } + white-space: nowrap; .history-entry-selected & { color: @history-entry-selected-label-color; } } .history-entry-label-comment, .history-entry-label-delete-btn { - display: inline-block; - padding: 0 (@padding-xs-horizontal / 2) 1px @padding-xs-horizontal; + padding: 0 @padding-xs-horizontal 1px @padding-xs-horizontal; border: 0; background-color: @history-entry-label-bg-color; - border-radius: 9999px 0 0 9999px; .history-entry-selected & { 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 { padding-left: (@padding-xs-horizontal / 2); 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 { .list-unstyled; margin-bottom: 3px; From dc235b91d98ed23eb90c72c116e15b85a10169aa Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 2 Aug 2018 15:46:42 +0100 Subject: [PATCH 06/13] Fix some issues with the label tooltip in compare mode. --- .../web/app/views/project/editor/history.pug | 26 ++++++++++ .../project/editor/history/entriesListV2.pug | 52 +++++++------------ .../controllers/HistoryListController.coffee | 12 ++++- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/services/web/app/views/project/editor/history.pug b/services/web/app/views/project/editor/history.pug index a7a52d2927..f0d22136b5 100644 --- a/services/web/app/views/project/editor/history.pug +++ b/services/web/app/views/project/editor/history.pug @@ -67,3 +67,29 @@ script(type="text/ng-template", id="historyRestoreDiffModalTemplate") ) span(ng-show="!state.inflight") #{translate("restore")} span(ng-show="state.inflight") #{translate("restoring")} ... + + +script(type="text/ng-template", id="historyLabelTpl") + .history-entry-label( + ng-class="{ 'history-entry-label-own' : $ctrl.isOwnedByCurrentUser }" + ) + span.history-entry-label-comment( + tooltip-append-to-body="true" + 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 }} diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index b96c74947d..52da25c3b5 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -69,17 +69,25 @@ aside.change-list( div.description(ng-click="select()") div - .history-entry-label( - ng-if="update.labels.length > 0" + history-label( ng-repeat="label in update.labels" + 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" + on-label-delete="deleteLabel(label)" ) - span.history-entry-label-comment - i.fa.fa-tag - |  {{ label.comment }} - button.history-entry-label-delete-btn( - stop-propagation="click" - ng-click="deleteLabel(label)" - ) × + //- .history-entry-label( + //- ng-if="update.labels.length > 0" + //- ng-repeat="label in update.labels" + //- ) + //- span.history-entry-label-comment + //- i.fa.fa-tag + //- |  {{ label.comment }} + //- button.history-entry-label-delete-btn( + //- stop-propagation="click" + //- ng-click="deleteLabel(label)" + //- ) × div.time {{ update.meta.end_ts | formatDate:'h:mm a' }} div.action.action-edited(ng-if="history.isV2 && update.pathnames.length > 0") | #{translate("file_action_edited")} @@ -198,28 +206,4 @@ 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")} - -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 }} \ No newline at end of file + ) #{translate("anonymous")} \ No newline at end of file diff --git a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee index e4bc2b541d..8257eebd8c 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee @@ -5,7 +5,17 @@ define [ App.controller "HistoryListController", ["$scope", "$modal", "ide", ($scope, $modal, ide) -> $scope.hoveringOverListSelectors = false - + + projectUsers = $scope.project.members.concat $scope.project.owner + console.log projectUsers + _getUserById = (id) -> + _.find projectUsers, (user) -> + curUserId = user?._id or user?.id + curUserId == id + + $scope.getDisplayNameById = (id) -> + displayNameForUser(_getUserById(id)) + $scope.deleteLabel = (labelDetails) -> $modal.open( templateUrl: "historyV2DeleteLabelModalTemplate" From 2c2bb4c130da809fdfe84833c941ae8d1386248d Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 2 Aug 2018 16:20:01 +0100 Subject: [PATCH 07/13] Add i18n; avoid injecting unneeded dependencies. --- .../web/app/views/project/editor/history.pug | 2 +- .../project/editor/history/entriesListV2.pug | 11 ----------- .../views/project/editor/history/toolbarV2.pug | 16 ++++++++-------- .../ide/history/components/historyEntry.coffee | 2 +- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/services/web/app/views/project/editor/history.pug b/services/web/app/views/project/editor/history.pug index f0d22136b5..6281bbee49 100644 --- a/services/web/app/views/project/editor/history.pug +++ b/services/web/app/views/project/editor/history.pug @@ -91,5 +91,5 @@ script(type="text/ng-template", id="historyLabelTooltipTpl") p.history-label-tooltip-title i.fa.fa-tag |  {{ $ctrl.labelText }} - p.history-label-tooltip-owner Created by {{ $ctrl.labelOwnerName }} + p.history-label-tooltip-owner #{translate("history_label_created_by")} {{ $ctrl.labelOwnerName }} time.history-label-tooltip-datetime {{ labelCreationDateTime | formatDate }} diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index 52da25c3b5..e4ad48caba 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -77,17 +77,6 @@ aside.change-list( is-owned-by-current-user="label.user_id === $ctrl.currentUser.id" on-label-delete="deleteLabel(label)" ) - //- .history-entry-label( - //- ng-if="update.labels.length > 0" - //- ng-repeat="label in update.labels" - //- ) - //- span.history-entry-label-comment - //- i.fa.fa-tag - //- |  {{ label.comment }} - //- button.history-entry-label-delete-btn( - //- stop-propagation="click" - //- ng-click="deleteLabel(label)" - //- ) × div.time {{ update.meta.end_ts | formatDate:'h:mm a' }} div.action.action-edited(ng-if="history.isV2 && update.pathnames.length > 0") | #{translate("file_action_edited")} diff --git a/services/web/app/views/project/editor/history/toolbarV2.pug b/services/web/app/views/project/editor/history/toolbarV2.pug index 1b8b733154..76d4ed1494 100644 --- a/services/web/app/views/project/editor/history/toolbarV2.pug +++ b/services/web/app/views/project/editor/history/toolbarV2.pug @@ -12,7 +12,7 @@ ng-disabled="history.loadingFileTree" ) i.fa.fa-tag - |  Label this version + |  #{translate("history_label_this_version")} button.history-toolbar-btn( ng-click="toggleHistoryViewMode();" ng-disabled="history.loadingFileTree" @@ -27,20 +27,20 @@ script(type="text/ng-template", id="historyV2AddLabelModalTemplate") novalidate ) .modal-header - h3 Add label + h3 #{translate("history_add_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")} .form-group input.form-control( type="text" - placeholder="New label name" + placeholder=translate("history_new_label_name") ng-model="inputs.labelName" focus-on="open" required ) p.help-block(ng-if="update") - | A new label will be added as of + | #{translate("history_new_label_added_at")} strong {{ update.meta.end_ts | formatDate:'ddd Do MMM YYYY, h:mm a' }} .modal-footer button.btn.btn-default( @@ -50,18 +50,18 @@ script(type="text/ng-template", id="historyV2AddLabelModalTemplate") ) #{translate("cancel")} input.btn.btn-primary( ng-disabled="addLabelModalForm.$invalid || state.inflight" - ng-value="state.inflight ? 'Adding label' : 'Add label'" + ng-value="state.inflight ? '" + translate("history_adding_label") + "' : '" + translate("history_add_label") + "'" type="submit" ) script(type="text/ng-template", id="historyV2DeleteLabelModalTemplate") .modal-header - h3 Delete label + 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") - | Are you sure you want to delete the following label: + | #{translate("history_are_you_sure_delete_label")} strong "{{ labelDetails.comment }}" | ? .modal-footer @@ -74,4 +74,4 @@ script(type="text/ng-template", id="historyV2DeleteLabelModalTemplate") type="button" ng-click="deleteLabel()" ng-disabled="state.inflight" - ) {{ state.inflight ? 'Deleting label' : 'Delete label' }} \ No newline at end of file + ) {{ state.inflight ? '#{translate("history_deleting_label")}' : '#{translate("history_delete_label")}' }} diff --git a/services/web/public/coffee/ide/history/components/historyEntry.coffee b/services/web/public/coffee/ide/history/components/historyEntry.coffee index 2995c5f481..eb7f1e7266 100644 --- a/services/web/public/coffee/ide/history/components/historyEntry.coffee +++ b/services/web/public/coffee/ide/history/components/historyEntry.coffee @@ -2,7 +2,7 @@ define [ "base" "ide/history/util/displayNameForUser" ], (App, displayNameForUser) -> - historyEntryController = ($scope, $element, $attrs, $filter, _) -> + historyEntryController = ($scope, $element, $attrs, _) -> ctrl = @ _getUserById = (id) -> _.find ctrl.users, (user) -> From f418929dcfe58c034e3a7d8436cb3b117d2182c9 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 2 Aug 2018 16:23:47 +0100 Subject: [PATCH 08/13] Adjust i18n. --- services/web/app/views/project/editor/history/toolbarV2.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/app/views/project/editor/history/toolbarV2.pug b/services/web/app/views/project/editor/history/toolbarV2.pug index 76d4ed1494..b4afe439b3 100644 --- a/services/web/app/views/project/editor/history/toolbarV2.pug +++ b/services/web/app/views/project/editor/history/toolbarV2.pug @@ -61,7 +61,7 @@ script(type="text/ng-template", id="historyV2DeleteLabelModalTemplate") .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")} + | #{translate("history_are_you_sure_delete_label")}: strong "{{ labelDetails.comment }}" | ? .modal-footer From f605e79fa5ff0b9a2bfc3f21890bc85b5134330b Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 2 Aug 2018 16:33:45 +0100 Subject: [PATCH 09/13] Remove changes to robots.txt. --- services/web/public/robots.txt | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/services/web/public/robots.txt b/services/web/public/robots.txt index e241feebcc..77470cb39f 100644 --- a/services/web/public/robots.txt +++ b/services/web/public/robots.txt @@ -1,21 +1,2 @@ -# robots.txt for https://www.sharelatex.com/ - User-agent: * -Disallow: /project/* -Disallow: /github/repos/* -Disallow: /recurly.com -Disallow: /user/password/set -Disallow: /learn-scripts/* -Allow: / - -User-Agent: AhrefsBot -Disallow: / - -User-Agent: XoviBot -Disallow: / - -User-Agent: RankSonicBot -Disallow: / - -User-Agent: SMTBot -Disallow: / +Disallow: / \ No newline at end of file From 80eeaaaaea9e5b5b44a83b0501087f037741dbb0 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Thu, 2 Aug 2018 17:19:16 +0100 Subject: [PATCH 10/13] Update web acceptance tests. --- .../coffee/ide/history/HistoryV2ManagerTests.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/services/web/test/unit_frontend/coffee/ide/history/HistoryV2ManagerTests.coffee b/services/web/test/unit_frontend/coffee/ide/history/HistoryV2ManagerTests.coffee index 5d5ba13609..725befb721 100644 --- a/services/web/test/unit_frontend/coffee/ide/history/HistoryV2ManagerTests.coffee +++ b/services/web/test/unit_frontend/coffee/ide/history/HistoryV2ManagerTests.coffee @@ -23,6 +23,7 @@ define ['ide/history/HistoryV2Manager'], (HistoryV2Manager) -> toV: null } } + labels: null diff: null files: [] selectedFile: null From bd6dcc007b7c416ab68db08848f0d42ab1fcff28 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 6 Aug 2018 11:00:45 +0100 Subject: [PATCH 11/13] Remove prototype code. --- .../web/app/views/project/editor/history/entriesListV2.pug | 3 +-- .../coffee/ide/history/components/historyEntriesList.coffee | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index e4ad48caba..55d86c434f 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -10,7 +10,6 @@ aside.change-list( load-disabled="history.loading || history.atEnd" load-initialize="ui.view == 'history'" is-loading="history.loading" - show-only-labelled="listConfig.showOnlyLabelled" on-entry-select="handleEntrySelect(selectedEntry)" on-label-delete="handleLabelDelete(label)" ) @@ -115,7 +114,7 @@ script(type="text/ng-template", id="historyEntriesListTpl") ) .infinite-scroll-inner history-entry( - ng-repeat="entry in $ctrl.entries | filter:$ctrl.shouldShowEntry" + ng-repeat="entry in $ctrl.entries" entry="entry" current-user="$ctrl.currentUser" users="$ctrl.users" diff --git a/services/web/public/coffee/ide/history/components/historyEntriesList.coffee b/services/web/public/coffee/ide/history/components/historyEntriesList.coffee index f872b5d72a..934ca304fe 100644 --- a/services/web/public/coffee/ide/history/components/historyEntriesList.coffee +++ b/services/web/public/coffee/ide/history/components/historyEntriesList.coffee @@ -3,8 +3,6 @@ define [ ], (App) -> historyEntriesListController = ($scope, $element, $attrs) -> ctrl = @ - ctrl.shouldShowEntry = (entry) -> - !(ctrl.showOnlyLabelled and entry.labels.length == 0) return App.component "historyEntriesList", { @@ -18,7 +16,6 @@ define [ currentUser: "<" onEntrySelect: "&" onLabelDelete: "&" - showOnlyLabelled: "<" controller: historyEntriesListController templateUrl: "historyEntriesListTpl" } From e0707253a773146df8738b3fde56acd811bdfd81 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 6 Aug 2018 11:03:15 +0100 Subject: [PATCH 12/13] Remove debug lines and unneeded HTML. --- .../project/editor/history/entriesListV2.pug | 17 ++++++++--------- .../controllers/HistoryListController.coffee | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/services/web/app/views/project/editor/history/entriesListV2.pug b/services/web/app/views/project/editor/history/entriesListV2.pug index 55d86c434f..337b5e33ce 100644 --- a/services/web/app/views/project/editor/history/entriesListV2.pug +++ b/services/web/app/views/project/editor/history/entriesListV2.pug @@ -67,15 +67,14 @@ aside.change-list( ) div.description(ng-click="select()") - div - history-label( - ng-repeat="label in update.labels" - 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" - on-label-delete="deleteLabel(label)" - ) + history-label( + ng-repeat="label in update.labels" + 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" + on-label-delete="deleteLabel(label)" + ) div.time {{ update.meta.end_ts | formatDate:'h:mm a' }} div.action.action-edited(ng-if="history.isV2 && update.pathnames.length > 0") | #{translate("file_action_edited")} diff --git a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee index 8257eebd8c..90c8142c6c 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryListController.coffee @@ -7,7 +7,7 @@ define [ $scope.hoveringOverListSelectors = false projectUsers = $scope.project.members.concat $scope.project.owner - console.log projectUsers + _getUserById = (id) -> _.find projectUsers, (user) -> curUserId = user?._id or user?.id From b0261970fc3d88abe9314d4bf1dcd6cc68806712 Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Mon, 6 Aug 2018 11:26:22 +0100 Subject: [PATCH 13/13] 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