mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Open file after restoring
This commit is contained in:
parent
0a1c543841
commit
415be6b4e0
3 changed files with 20 additions and 19 deletions
|
@ -1,9 +1,12 @@
|
|||
.diff-panel.full-size(ng-if="history.isV2", ng-controller="HistoryV2DiffController")
|
||||
.diff(
|
||||
ng-if="!!history.diff && !history.diff.loading && !history.diff.error && !history.diff.binary"
|
||||
ng-if="!!history.diff && !history.diff.loading && !history.diff.error",
|
||||
ng-class="{ 'diff-binary': history.diff.binary }"
|
||||
)
|
||||
.toolbar.toolbar-alt
|
||||
span.name
|
||||
span.name(ng-if="history.diff.binary")
|
||||
strong {{history.diff.pathname}}
|
||||
span.name(ng-if="!history.diff.binary")
|
||||
| <strong>{{history.diff.highlights.length}} </strong>
|
||||
ng-pluralize(
|
||||
count="history.diff.highlights.length",
|
||||
|
@ -27,6 +30,7 @@
|
|||
span.text-danger(ng-show="restoreState.error")
|
||||
| Error restoring, sorry
|
||||
.diff-editor.hide-ace-cursor(
|
||||
ng-if="!history.diff.binary"
|
||||
ace-editor="history",
|
||||
theme="settings.theme",
|
||||
font-size="settings.fontSize",
|
||||
|
@ -36,12 +40,8 @@
|
|||
resize-on="layout:main:resize",
|
||||
navigate-highlights="true"
|
||||
)
|
||||
|
||||
.diff.diff-binary(ng-show="history.diff.binary")
|
||||
.toolbar.toolbar-alt
|
||||
span.name
|
||||
strong {{history.diff.pathname}}
|
||||
.alert.alert-info We're still working on showing image and binary changes, sorry. Stay tuned!
|
||||
.alert.alert-info(ng-if="history.diff.binary")
|
||||
| We're still working on showing image and binary changes, sorry. Stay tuned!
|
||||
|
||||
.loading-panel(ng-show="history.diff.loading")
|
||||
i.fa.fa-spin.fa-refresh
|
||||
|
|
|
@ -8,6 +8,7 @@ define [
|
|||
@openFile(entity)
|
||||
|
||||
openFile: (file) ->
|
||||
@ide.fileTreeManager.selectEntity(file)
|
||||
@$scope.ui.view = "file"
|
||||
@$scope.openFile = null
|
||||
@$scope.$apply()
|
||||
|
|
|
@ -2,8 +2,6 @@ define [
|
|||
"base"
|
||||
], (App) ->
|
||||
App.controller "HistoryV2DiffController", ($scope, ide, event_tracking) ->
|
||||
console.log "HistoryV2DiffController!"
|
||||
|
||||
$scope.restoreState =
|
||||
inflight: false
|
||||
error: false
|
||||
|
@ -15,25 +13,27 @@ define [
|
|||
return if !version?
|
||||
event_tracking.sendMB "history-v2-restore-deleted"
|
||||
$scope.restoreState.inflight = true
|
||||
$scope.restoreState.error = false
|
||||
ide.historyManager
|
||||
.restoreFile(version, pathname)
|
||||
.then (response) ->
|
||||
{ data } = response
|
||||
$scope.restoreState.inflight = false
|
||||
if data.type == 'doc'
|
||||
openDoc(data.id)
|
||||
openEntity(data)
|
||||
.catch () ->
|
||||
$scope.restoreState.error = true
|
||||
ide.showGenericMessageModal('Sorry, something went wrong with the restore')
|
||||
.finally () ->
|
||||
$scope.restoreState.inflight = false
|
||||
|
||||
openDoc = (id) ->
|
||||
openEntity = (data) ->
|
||||
iterations = 0
|
||||
{id, type} = data
|
||||
do tryOpen = () ->
|
||||
if iterations > 5
|
||||
return
|
||||
doc = ide.fileTreeManager.findEntityById(id)
|
||||
if doc?
|
||||
ide.editorManager.openDoc(doc)
|
||||
entity = ide.fileTreeManager.findEntityById(id)
|
||||
if entity? and type == 'doc'
|
||||
ide.editorManager.openDoc(entity)
|
||||
if entity? and type == 'file'
|
||||
ide.binaryFilesManager.openFile(entity)
|
||||
else
|
||||
setTimeout(tryOpen, 500)
|
||||
|
Loading…
Reference in a new issue