mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Basic label support (showing labels in the entries list; creating labels via a modal).
This commit is contained in:
parent
22b664da1a
commit
3a80c34078
9 changed files with 149 additions and 14 deletions
|
@ -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"
|
||||
|
|
|
@ -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")}
|
||||
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"
|
||||
)
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
]
|
|
@ -0,0 +1,10 @@
|
|||
define [
|
||||
"base",
|
||||
], (App) ->
|
||||
App.controller "HistoryV2ToolbarController", ["$scope", "$modal", "ide", ($scope, $modal, ide) ->
|
||||
$scope.showAddLabelDialog = () ->
|
||||
$modal.open(
|
||||
templateUrl: "historyV2AddLabelModalTemplate"
|
||||
controller: "HistoryV2AddLabelModalController"
|
||||
)
|
||||
]
|
|
@ -1,2 +1,21 @@
|
|||
# robots.txt for https://www.sharelatex.com/
|
||||
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
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: /
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue