Remove history-related Angular code (#15932)

GitOrigin-RevId: e4fafddd67909a0e709439ddbe560c66e2629bdb
This commit is contained in:
Alf Eaton 2023-11-28 11:24:23 +00:00 committed by Copybot
parent d40de2018c
commit 19a17060ab
22 changed files with 5 additions and 2096 deletions

View file

@ -26,6 +26,7 @@ export type IdeEvents = {
'scroll:editor:update': [] 'scroll:editor:update': []
'comment:start_adding': [] 'comment:start_adding': []
'references:should-reindex': [] 'references:should-reindex': []
'history:toggle': []
'entity:deleted': [entity: FileTreeFindResult] 'entity:deleted': [entity: FileTreeFindResult]
} }

View file

@ -5,10 +5,6 @@ const reviewPanelStorageKey = `ui.reviewPanelOpen.${getMeta('ol-project_id')}`
export default function populateLayoutScope(store: ReactScopeValueStore) { export default function populateLayoutScope(store: ReactScopeValueStore) {
store.set('ui.view', 'editor') store.set('ui.view', 'editor')
// TODO: Find out what this needs to do and make it do it
store.set('toggleHistory', () => {})
store.set('openFile', null) store.set('openFile', null)
store.persisted('ui.chatOpen', false, 'ui.chatOpen') store.persisted('ui.chatOpen', false, 'ui.chatOpen')
store.persisted('ui.reviewPanelOpen', false, reviewPanelStorageKey) store.persisted('ui.reviewPanelOpen', false, reviewPanelStorageKey)

View file

@ -22,7 +22,6 @@ import LoadingManager from './ide/LoadingManager'
import ConnectionManager from './ide/connection/ConnectionManager' import ConnectionManager from './ide/connection/ConnectionManager'
import EditorManager from './ide/editor/EditorManager' import EditorManager from './ide/editor/EditorManager'
import OnlineUsersManager from './ide/online-users/OnlineUsersManager' import OnlineUsersManager from './ide/online-users/OnlineUsersManager'
import HistoryV2Manager from './ide/history/HistoryV2Manager'
import PermissionsManager from './ide/permissions/PermissionsManager' import PermissionsManager from './ide/permissions/PermissionsManager'
import BinaryFilesManager from './ide/binary-files/BinaryFilesManager' import BinaryFilesManager from './ide/binary-files/BinaryFilesManager'
import ReferencesManager from './ide/references/ReferencesManager' import ReferencesManager from './ide/references/ReferencesManager'
@ -205,7 +204,6 @@ App.controller('IdeController', [
eventTracking eventTracking
) )
ide.onlineUsersManager = new OnlineUsersManager(ide, $scope) ide.onlineUsersManager = new OnlineUsersManager(ide, $scope)
ide.historyManager = new HistoryV2Manager(ide, $scope, localStorage)
ide.permissionsManager = new PermissionsManager(ide, $scope) ide.permissionsManager = new PermissionsManager(ide, $scope)
ide.binaryFilesManager = new BinaryFilesManager(ide, $scope) ide.binaryFilesManager = new BinaryFilesManager(ide, $scope)
ide.metadataManager = new MetadataManager(ide, $scope, metadata) ide.metadataManager = new MetadataManager(ide, $scope, metadata)

File diff suppressed because it is too large Load diff

View file

@ -1,138 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
const historyEntriesListController = function ($scope, $element) {
const ctrl = this
ctrl.$entryListViewportEl = null
ctrl.isDragging = false
const _isEntryElVisible = function ($entryEl) {
const entryElTop = $entryEl.offset().top
const entryElBottom = entryElTop + $entryEl.outerHeight()
const entryListViewportElTop = ctrl.$entryListViewportEl.offset().top
const entryListViewportElBottom =
entryListViewportElTop + ctrl.$entryListViewportEl.height()
return (
entryElTop >= entryListViewportElTop &&
entryElBottom <= entryListViewportElBottom
)
}
const _getScrollTopPosForEntry = function ($entryEl) {
const halfViewportElHeight = ctrl.$entryListViewportEl.height() / 2
return $entryEl.offset().top - halfViewportElHeight
}
ctrl.onEntryLinked = function (entry, $entryEl) {
if (
!ctrl.rangeSelectionEnabled &&
entry.toV === ctrl.selectedHistoryVersion
) {
$scope.$applyAsync(() => {
if (!_isEntryElVisible($entryEl)) {
ctrl.$entryListViewportEl.scrollTop(
_getScrollTopPosForEntry($entryEl)
)
}
})
}
}
ctrl.handleEntrySelect = entry => {
if (ctrl.rangeSelectionEnabled) {
ctrl.onRangeSelect({
selectedToV: entry.toV,
selectedFromV: entry.fromV,
})
} else {
ctrl.onVersionSelect({ version: entry.toV })
}
}
ctrl.setRangeToV = toV => {
if (toV > ctrl.selectedHistoryRange.fromV) {
ctrl.onRangeSelect({
selectedToV: toV,
selectedFromV: ctrl.selectedHistoryRange.fromV,
})
}
}
ctrl.setRangeFromV = fromV => {
if (fromV < ctrl.selectedHistoryRange.toV) {
ctrl.onRangeSelect({
selectedToV: ctrl.selectedHistoryRange.toV,
selectedFromV: fromV,
})
}
}
ctrl.initHoveredRange = () => {
ctrl.hoveredHistoryRange = {
toV: ctrl.selectedHistoryRange.toV,
fromV: ctrl.selectedHistoryRange.fromV,
}
}
ctrl.resetHoveredRange = () => {
ctrl.hoveredHistoryRange = { toV: null, fromV: null }
}
ctrl.setHoveredRangeToV = toV => {
if (toV > ctrl.hoveredHistoryRange.fromV) {
$scope.$applyAsync(() => (ctrl.hoveredHistoryRange.toV = toV))
}
}
ctrl.setHoveredRangeFromV = fromV => {
if (fromV < ctrl.hoveredHistoryRange.toV) {
$scope.$applyAsync(() => (ctrl.hoveredHistoryRange.fromV = fromV))
}
}
ctrl.onDraggingStart = () => {
$scope.$applyAsync(() => {
ctrl.isDragging = true
ctrl.initHoveredRange()
})
}
ctrl.onDraggingStop = (isValidDrop, boundary) => {
$scope.$applyAsync(() => {
ctrl.isDragging = false
if (!isValidDrop) {
if (boundary === 'toV') {
ctrl.setRangeToV(ctrl.hoveredHistoryRange.toV)
} else if (boundary === 'fromV') {
ctrl.setRangeFromV(ctrl.hoveredHistoryRange.fromV)
}
}
ctrl.resetHoveredRange()
})
}
ctrl.$onInit = () => {
ctrl.$entryListViewportEl = $element.find('> .history-entries')
ctrl.resetHoveredRange()
}
}
export default App.component('historyEntriesList', {
bindings: {
entries: '<',
users: '<',
loadEntries: '&',
loadDisabled: '<',
loadInitialize: '<',
isLoading: '<',
currentUser: '<',
freeHistoryLimitHit: '<',
currentUserIsOwner: '<',
rangeSelectionEnabled: '<',
selectedHistoryVersion: '<?',
selectedHistoryRange: '<?',
onVersionSelect: '&',
onRangeSelect: '&',
onLabelDelete: '&',
},
controller: ['$scope', '$element', historyEntriesListController],
templateUrl: 'historyEntriesListTpl',
})

View file

@ -1,125 +0,0 @@
import _ from 'lodash'
/* eslint-disable
max-len,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
import ColorManager from '../../colors/ColorManager'
import displayNameForUser from '../util/displayNameForUser'
const historyEntryController = function ($scope, $element) {
const ctrl = this
// 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.
const _getUserById = id =>
_.find(ctrl.users, function (user) {
const curUserId =
(user != null ? user._id : undefined) ||
(user != null ? user.id : undefined)
return curUserId === id
})
ctrl.displayName = displayNameForUser
ctrl.displayNameById = id => displayNameForUser(_getUserById(id))
ctrl.getProjectOpDoc = function (projectOp) {
if (projectOp.rename != null) {
return `${projectOp.rename.pathname}${projectOp.rename.newPathname}`
} else if (projectOp.add != null) {
return `${projectOp.add.pathname}`
} else if (projectOp.remove != null) {
return `${projectOp.remove.pathname}`
}
}
ctrl.getUserCSSStyle = function (user) {
const curUserId =
(user != null ? user._id : undefined) ||
(user != null ? user.id : undefined)
const hue = ColorManager.getHueForUserId(curUserId) || 100
if (ctrl.isEntrySelected() || ctrl.isEntryHoverSelected()) {
return { color: '#FFF' }
} else {
return { color: `hsl(${hue}, 70%, 50%)` }
}
}
ctrl.isEntrySelected = function () {
if (ctrl.rangeSelectionEnabled) {
return (
ctrl.entry.toV <= ctrl.selectedHistoryRange.toV &&
ctrl.entry.fromV >= ctrl.selectedHistoryRange.fromV
)
} else {
return ctrl.entry.toV === ctrl.selectedHistoryVersion
}
}
ctrl.isEntryHoverSelected = function () {
return (
ctrl.rangeSelectionEnabled &&
ctrl.entry.toV <= ctrl.hoveredHistoryRange.toV &&
ctrl.entry.fromV >= ctrl.hoveredHistoryRange.fromV
)
}
ctrl.onDraggingStart = () => {
ctrl.historyEntriesList.onDraggingStart()
}
ctrl.onDraggingStop = (isValidDrop, boundary) =>
ctrl.historyEntriesList.onDraggingStop(isValidDrop, boundary)
ctrl.onDrop = boundary => {
if (boundary === 'toV') {
$scope.$applyAsync(() =>
ctrl.historyEntriesList.setRangeToV(ctrl.entry.toV)
)
} else if (boundary === 'fromV') {
$scope.$applyAsync(() =>
ctrl.historyEntriesList.setRangeFromV(ctrl.entry.fromV)
)
}
}
ctrl.onOver = boundary => {
if (boundary === 'toV') {
$scope.$applyAsync(() =>
ctrl.historyEntriesList.setHoveredRangeToV(ctrl.entry.toV)
)
} else if (boundary === 'fromV') {
$scope.$applyAsync(() =>
ctrl.historyEntriesList.setHoveredRangeFromV(ctrl.entry.fromV)
)
}
}
ctrl.$onInit = () => {
ctrl.$entryEl = $element.find('> .history-entry')
ctrl.$entryDetailsEl = $element.find('.history-entry-details')
ctrl.$toVHandleEl = $element.find('.history-entry-toV-handle')
ctrl.$fromVHandleEl = $element.find('.history-entry-fromV-handle')
ctrl.historyEntriesList.onEntryLinked(ctrl.entry, ctrl.$entryEl)
}
}
export default App.component('historyEntry', {
bindings: {
entry: '<',
currentUser: '<',
users: '<',
rangeSelectionEnabled: '<',
isDragging: '<',
selectedHistoryVersion: '<?',
selectedHistoryRange: '<?',
hoveredHistoryRange: '<?',
onSelect: '&',
onLabelDelete: '&',
},
require: {
historyEntriesList: '^historyEntriesList',
},
controller: ['$scope', '$element', historyEntryController],
templateUrl: 'historyEntryTpl',
})

View file

@ -1,104 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
import iconTypeFromName from '../../file-tree/util/iconTypeFromName'
import fileOperationI18nNames from '../../file-tree/util/fileOperationI18nNames'
const historyFileEntityController = function ($scope) {
const ctrl = this
ctrl.hasOperation = false
ctrl.getRenameTooltip = i18nRenamedStr => {
const [simplifiedOldPathname, simplifiedPathname] = _getSimplifiedPaths(
ctrl.fileEntity.oldPathname,
ctrl.fileEntity.pathname
)
return `${fileOperationI18nNames.renamed} <strong>${simplifiedOldPathname}</strong> &rarr; <strong>${simplifiedPathname}</strong>`
}
ctrl.getFileOperationName = () => {
if (ctrl.fileEntity.operation === 'edited') {
return fileOperationI18nNames.edited
} else if (ctrl.fileEntity.operation === 'renamed') {
return fileOperationI18nNames.renamed
} else if (ctrl.fileEntity.operation === 'added') {
return fileOperationI18nNames.created
} else if (ctrl.fileEntity.operation === 'removed') {
return fileOperationI18nNames.deleted
} else {
return ''
}
}
const _getSimplifiedPaths = (path1, path2) => {
const path1Parts = path1.split('/')
const path2Parts = path2.split('/')
const maxIterations = Math.min(path1Parts.length, path2Parts.length) - 1
let commonPartIndex
for (
commonPartIndex = 0;
commonPartIndex < maxIterations;
commonPartIndex++
) {
if (path1Parts[commonPartIndex] !== path2Parts[commonPartIndex]) {
break
}
}
path1Parts.splice(0, commonPartIndex)
path2Parts.splice(0, commonPartIndex)
return [path1Parts.join('/'), path2Parts.join('/')]
}
const _handleFolderClick = function () {
ctrl.isOpen = !ctrl.isOpen
ctrl.entityTypeIconClass = _getFolderIcon()
}
const _handleFileClick = () =>
ctrl.historyFileTreeController.handleEntityClick(ctrl.fileEntity)
function _getFolderIcon() {
if (ctrl.isOpen) {
return 'fa-folder-open'
} else {
return 'fa-folder'
}
}
ctrl.$onInit = function () {
if (ctrl.fileEntity.type === 'folder') {
ctrl.isOpen = true
ctrl.entityTypeIconClass = _getFolderIcon()
ctrl.handleClick = _handleFolderClick
} else {
if (ctrl.fileEntity.operation) {
ctrl.hasOperation = true
}
ctrl.entityTypeIconClass = `fa-${iconTypeFromName(ctrl.fileEntity.name)}`
ctrl.entityOpTextClass = ctrl.fileEntity.operation
? `history-file-entity-name-${ctrl.fileEntity.operation}`
: null
ctrl.handleClick = _handleFileClick
$scope.$watch(
() => ctrl.historyFileTreeController.selectedPathname,
selectedPathname =>
(ctrl.isSelected = ctrl.fileEntity.pathname === selectedPathname)
)
}
}
}
export default App.component('historyFileEntity', {
require: {
historyFileTreeController: '^historyFileTree',
},
bindings: {
fileEntity: '<',
},
controller: ['$scope', historyFileEntityController],
templateUrl: 'historyFileEntityTpl',
})

View file

@ -1,63 +0,0 @@
import _ from 'lodash'
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
const historyFileTreeController = function ($scope) {
const ctrl = this
ctrl.handleEntityClick = file => ctrl.onSelectedFileChange({ file })
ctrl._fileTree = []
$scope.$watch('$ctrl.files', function (files) {
if (files != null && files.length > 0) {
ctrl._fileTree = _.reduce(files, _reducePathsToTree, [])
}
})
function _reducePathsToTree(currentFileTree, fileObject) {
const filePathParts = fileObject.pathname.split('/')
let currentFileTreeLocation = currentFileTree
for (let index = 0; index < filePathParts.length; index++) {
let fileTreeEntity
const pathPart = filePathParts[index]
const isFile = index === filePathParts.length - 1
if (isFile) {
fileTreeEntity = _.clone(fileObject)
fileTreeEntity.name = pathPart
fileTreeEntity.type = 'file'
currentFileTreeLocation.push(fileTreeEntity)
} else {
fileTreeEntity = _.find(
currentFileTreeLocation,
entity => entity.name === pathPart
)
if (fileTreeEntity == null) {
fileTreeEntity = {
name: pathPart,
type: 'folder',
children: [],
}
currentFileTreeLocation.push(fileTreeEntity)
}
currentFileTreeLocation = fileTreeEntity.children
}
}
return currentFileTree
}
}
export default App.component('historyFileTree', {
bindings: {
files: '<',
selectedPathname: '<',
onSelectedFileChange: '&',
isLoading: '<',
},
controller: ['$scope', historyFileTreeController],
templateUrl: 'historyFileTreeTpl',
})

View file

@ -1,37 +0,0 @@
/* eslint-disable
max-len,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
const historyLabelController = function () {
const ctrl = this
ctrl.$onInit = () => {
if (ctrl.showTooltip == null) {
ctrl.showTooltip = true
}
if (ctrl.isPseudoCurrentStateLabel == null) {
ctrl.isPseudoCurrentStateLabel = false
}
}
}
export default App.component('historyLabel', {
bindings: {
labelText: '<',
labelOwnerName: '<?',
labelCreationDateTime: '<?',
isOwnedByCurrentUser: '<',
isPseudoCurrentStateLabel: '<',
onLabelDelete: '&',
showTooltip: '<?',
},
controller: historyLabelController,
templateUrl: 'historyLabelTpl',
})

View file

@ -1,175 +0,0 @@
import _ from 'lodash'
/* eslint-disable
max-len,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
import ColorManager from '../../colors/ColorManager'
import displayNameForUser from '../util/displayNameForUser'
const historyLabelsListController = function ($scope) {
const ctrl = this
ctrl.isDragging = false
ctrl.versionsWithLabels = []
$scope.$watchCollection('$ctrl.labels', function (labels) {
if (labels) {
const groupedLabelsHash = _.groupBy(labels, 'version')
ctrl.versionsWithLabels = _.map(groupedLabelsHash, (labels, version) => {
return {
version: parseInt(version, 10),
labels,
}
})
}
})
ctrl.initHoveredRange = () => {
ctrl.hoveredHistoryRange = {
toV: ctrl.selectedHistoryRange.toV,
fromV: ctrl.selectedHistoryRange.fromV,
}
}
ctrl.resetHoveredRange = () => {
ctrl.hoveredHistoryRange = { toV: null, fromV: null }
}
ctrl.setHoveredRangeToV = toV => {
if (toV >= ctrl.hoveredHistoryRange.fromV) {
ctrl.hoveredHistoryRange.toV = toV
}
}
ctrl.setHoveredRangeFromV = fromV => {
if (fromV <= ctrl.hoveredHistoryRange.toV) {
ctrl.hoveredHistoryRange.fromV = fromV
}
}
ctrl.isVersionSelected = function (version) {
if (ctrl.rangeSelectionEnabled) {
return (
version <= ctrl.selectedHistoryRange.toV &&
version >= ctrl.selectedHistoryRange.fromV
)
} else {
return version === ctrl.selectedHistoryVersion
}
}
ctrl.isVersionHoverSelected = function (version) {
return (
ctrl.rangeSelectionEnabled &&
version <= ctrl.hoveredHistoryRange.toV &&
version >= ctrl.hoveredHistoryRange.fromV
)
}
ctrl.onDraggingStart = () => {
$scope.$applyAsync(() => {
ctrl.isDragging = true
ctrl.initHoveredRange()
})
}
ctrl.onDraggingStop = (isValidDrop, boundary) => {
$scope.$applyAsync(() => {
if (!isValidDrop) {
if (boundary === 'toV') {
ctrl.setRangeToV(ctrl.hoveredHistoryRange.toV)
} else if (boundary === 'fromV') {
ctrl.setRangeFromV(ctrl.hoveredHistoryRange.fromV)
}
}
ctrl.isDragging = false
ctrl.resetHoveredRange()
})
}
ctrl.onDrop = (boundary, versionWithLabel) => {
if (boundary === 'toV') {
$scope.$applyAsync(() => ctrl.setRangeToV(versionWithLabel.version))
} else if (boundary === 'fromV') {
$scope.$applyAsync(() => ctrl.setRangeFromV(versionWithLabel.version))
}
}
ctrl.onOver = (boundary, versionWithLabel) => {
if (boundary === 'toV') {
$scope.$applyAsync(() =>
ctrl.setHoveredRangeToV(versionWithLabel.version)
)
} else if (boundary === 'fromV') {
$scope.$applyAsync(() =>
ctrl.setHoveredRangeFromV(versionWithLabel.version)
)
}
}
ctrl.handleVersionSelect = versionWithLabel => {
if (ctrl.rangeSelectionEnabled) {
// TODO
ctrl.onRangeSelect({
selectedToV: versionWithLabel.version,
selectedFromV: versionWithLabel.version,
})
} else {
ctrl.onVersionSelect({ version: versionWithLabel.version })
}
}
ctrl.setRangeToV = version => {
if (version >= ctrl.selectedHistoryRange.fromV) {
ctrl.onRangeSelect({
selectedToV: version,
selectedFromV: ctrl.selectedHistoryRange.fromV,
})
}
}
ctrl.setRangeFromV = version => {
if (version <= ctrl.selectedHistoryRange.toV) {
ctrl.onRangeSelect({
selectedToV: ctrl.selectedHistoryRange.toV,
selectedFromV: version,
})
}
}
ctrl.buildUserView = label => {
const user = {
_id: label.user_id,
displayName: label.user_display_name,
}
return user
}
ctrl.displayName = displayNameForUser
ctrl.getUserCSSStyle = function (user, versionWithLabel) {
const curUserId =
(user != null ? user._id : undefined) ||
(user != null ? user.id : undefined)
const hue = ColorManager.getHueForUserId(curUserId) || 100
if (
ctrl.isVersionSelected(versionWithLabel.version) ||
ctrl.isVersionHoverSelected(versionWithLabel.version)
) {
return { color: '#FFF' }
} else {
return { color: `hsl(${hue}, 70%, 50%)` }
}
}
ctrl.$onInit = () => {
ctrl.resetHoveredRange()
}
}
export default App.component('historyLabelsList', {
bindings: {
labels: '<',
rangeSelectionEnabled: '<',
users: '<',
currentUser: '<',
isLoading: '<',
selectedHistoryVersion: '<?',
selectedHistoryRange: '<?',
onVersionSelect: '&',
onRangeSelect: '&',
onLabelDelete: '&',
},
controller: ['$scope', historyLabelsListController],
templateUrl: 'historyLabelsListTpl',
})

View file

@ -1,50 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
export default App.controller('HistoryV2AddLabelModalController', [
'$scope',
'$modalInstance',
'ide',
'update',
function ($scope, $modalInstance, ide, update) {
$scope.update = update
$scope.inputs = { labelName: null }
$scope.state = {
inflight: false,
error: false,
}
$modalInstance.opened.then(() =>
$scope.$applyAsync(() => $scope.$broadcast('open'))
)
return ($scope.addLabelModalFormSubmit = function () {
$scope.state.inflight = true
return ide.historyManager
.labelCurrentVersion($scope.inputs.labelName)
.then(function (response) {
$scope.state.inflight = false
return $modalInstance.close()
})
.catch(function (response) {
const { data, status } = response
$scope.state.inflight = false
if (status === 400) {
return ($scope.state.error = { message: data })
} else {
return ($scope.state.error = true)
}
})
})
},
])

View file

@ -1,45 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
export default App.controller('HistoryV2DeleteLabelModalController', [
'$scope',
'$modalInstance',
'ide',
'labelDetails',
function ($scope, $modalInstance, ide, labelDetails) {
$scope.labelDetails = labelDetails
$scope.state = {
inflight: false,
error: false,
}
return ($scope.deleteLabel = function () {
$scope.state.inflight = true
return ide.historyManager
.deleteLabel(labelDetails)
.then(function (response) {
$scope.state.inflight = false
return $modalInstance.close()
})
.catch(function (response) {
const { data, status } = response
$scope.state.inflight = false
if (status === 400) {
return ($scope.state.error = { message: data })
} else {
return ($scope.state.error = true)
}
})
})
},
])

View file

@ -1,23 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
export default App.controller('HistoryV2FileTreeController', [
'$scope',
'ide',
function ($scope, ide) {
$scope.handleFileSelection = file => {
ide.historyManager.selectFile(file)
}
},
])

View file

@ -1,56 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
export default App.controller('HistoryV2ListController', [
'$scope',
'$modal',
'ide',
function ($scope, $modal, ide) {
$scope.hoveringOverListSelectors = false
$scope.listConfig = { showOnlyLabelled: false }
$scope.projectUsers = []
$scope.$watch('project.members', function (newVal) {
if (newVal != null) {
return ($scope.projectUsers = newVal.concat($scope.project.owner))
}
})
$scope.loadMore = () => {
return ide.historyManager.fetchNextBatchOfUpdates()
}
$scope.handleVersionSelect = version =>
$scope.$applyAsync(() =>
ide.historyManager.selectVersionForPointInTime(version)
)
$scope.handleRangeSelect = (selectedToV, selectedFromV) =>
$scope.$applyAsync(() =>
ide.historyManager.selectVersionsForCompare(selectedToV, selectedFromV)
)
return ($scope.handleLabelDelete = labelDetails =>
$modal.open({
templateUrl: 'historyV2DeleteLabelModalTemplate',
controller: 'HistoryV2DeleteLabelModalController',
resolve: {
labelDetails() {
return labelDetails
},
},
}))
},
])

View file

@ -1,128 +0,0 @@
/* eslint-disable
max-len,
no-return-assign,
camelcase,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
import { debugConsole } from '@/utils/debugging'
export default App.controller('HistoryV2ToolbarController', [
'$scope',
'$modal',
'ide',
'eventTracking',
'waitFor',
function ($scope, $modal, ide, eventTracking, waitFor) {
$scope.currentUpdate = null
$scope.currentLabel = null
$scope.restoreState = {
inflight: false,
error: false,
}
$scope.toolbarUIConfig = {
showOnlyLabels: false,
}
const _deregistershowOnlyLabelsWatcher = $scope.$watch(
'history.showOnlyLabels',
showOnlyLabels => {
if (showOnlyLabels != null) {
$scope.toolbarUIConfig.showOnlyLabels = showOnlyLabels
_deregistershowOnlyLabelsWatcher()
}
}
)
$scope.$watch('toolbarUIConfig.showOnlyLabels', (newVal, oldVal) => {
if (newVal != null && newVal !== oldVal) {
if (newVal) {
ide.historyManager.showOnlyLabels()
} else {
ide.historyManager.showAllUpdates()
}
}
})
$scope.$watch('history.viewMode', (newVal, oldVal) => {
if (newVal != null && newVal !== oldVal) {
$scope.currentUpdate = ide.historyManager.getUpdateForVersion(newVal)
}
})
$scope.$watch('history.selection.range.toV', (newVal, oldVal) => {
if (
newVal != null &&
newVal !== oldVal &&
$scope.history.viewMode === $scope.HistoryViewModes.POINT_IN_TIME
) {
$scope.currentUpdate = ide.historyManager.getUpdateForVersion(newVal)
}
})
$scope.toggleHistoryViewMode = () => {
ide.historyManager.toggleHistoryViewMode()
}
$scope.restoreDeletedFile = function () {
const { pathname, deletedAtV } = $scope.history.selection.file
if (pathname == null || deletedAtV == null) {
return
}
eventTracking.sendMB('history-v2-restore-deleted')
$scope.restoreState.inflight = true
return ide.historyManager
.restoreFile(deletedAtV, pathname)
.then(function (response) {
const { data } = response
return openEntity(data)
})
.catch(() =>
ide.showGenericMessageModal(
'Sorry, something went wrong with the restore'
)
)
.finally(() => ($scope.restoreState.inflight = false))
}
$scope.showAddLabelDialog = () => {
$modal.open({
templateUrl: 'historyV2AddLabelModalTemplate',
controller: 'HistoryV2AddLabelModalController',
resolve: {
update() {
return $scope.history.selection.update
},
},
})
}
function openEntity(data) {
const { id, type } = data
return waitFor(() => ide.fileTreeManager.findEntityById(id), 3000)
.then(function (entity) {
if (type === 'doc') {
ide.editorManager.openDoc(entity)
ide.$timeout(() => {
$scope.$broadcast('history:toggle')
}, 0)
} else if (type === 'file') {
ide.binaryFilesManager.openFile(entity)
ide.$timeout(() => {
$scope.$broadcast('history:toggle')
}, 0)
}
})
.catch(debugConsole.error)
}
},
])

View file

@ -1,35 +0,0 @@
import App from '../../../base'
export default App.directive('historyDraggableBoundary', function () {
return {
scope: {
historyDraggableBoundary: '@',
historyDraggableBoundaryOnDragStart: '&',
historyDraggableBoundaryOnDragStop: '&',
},
restrict: 'A',
link(scope, element, attrs) {
element.data('selectionBoundary', {
boundary: scope.historyDraggableBoundary,
})
element.draggable({
axis: 'y',
opacity: false,
helper: 'clone',
revert: true,
scroll: true,
cursor: 'row-resize',
start(e, ui) {
ui.helper.data('wasProperlyDropped', false)
scope.historyDraggableBoundaryOnDragStart()
},
stop(e, ui) {
scope.historyDraggableBoundaryOnDragStop({
isValidDrop: ui.helper.data('wasProperlyDropped'),
boundary: scope.historyDraggableBoundary,
})
},
})
},
}
})

View file

@ -1,28 +0,0 @@
import App from '../../../base'
export default App.directive('historyDroppableArea', function () {
return {
scope: {
historyDroppableAreaOnDrop: '&',
historyDroppableAreaOnOver: '&',
historyDroppableAreaOnOut: '&',
},
restrict: 'A',
link(scope, element, attrs) {
element.droppable({
accept: e => '.history-entry-toV-handle, .history-entry-fromV-handle',
drop: (e, ui) => {
const draggedBoundary =
ui.draggable.data('selectionBoundary').boundary
ui.helper.data('wasProperlyDropped', true)
scope.historyDroppableAreaOnDrop({ boundary: draggedBoundary })
},
over: (e, ui) => {
const draggedBoundary =
ui.draggable.data('selectionBoundary').boundary
scope.historyDroppableAreaOnOver({ boundary: draggedBoundary })
},
})
},
}
})

View file

@ -1,55 +0,0 @@
/* eslint-disable
max-len,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import App from '../../../base'
export default App.directive('infiniteScroll', function () {
return {
link(scope, element, attrs, ctrl) {
const innerElement = element.find('.infinite-scroll-inner')
element.css({ 'overflow-y': 'auto' })
const atEndOfListView = function () {
if (attrs.infiniteScrollUpwards != null) {
return atTopOfListView()
} else {
return atBottomOfListView()
}
}
const atTopOfListView = () => element.scrollTop() < 30
const atBottomOfListView = () =>
element.scrollTop() + element.height() >= innerElement.height() - 30
const listShorterThanContainer = () =>
element.height() > innerElement.height()
function loadUntilFull() {
if (
(listShorterThanContainer() || atEndOfListView()) &&
!scope.$eval(attrs.infiniteScrollDisabled)
) {
const promise = scope.$eval(attrs.infiniteScroll)
return promise.then(() => setTimeout(() => loadUntilFull(), 0))
}
}
element.on('scroll', event => loadUntilFull())
return scope.$watch(attrs.infiniteScrollInitialize, function (value) {
if (value) {
return loadUntilFull()
}
})
},
}
})

View file

@ -1,17 +0,0 @@
/* eslint-disable
no-return-assign,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
let HistoryViewModes
export default HistoryViewModes = {
POINT_IN_TIME: 'point_in_time',
COMPARE: 'compare',
}

View file

@ -14,6 +14,7 @@ import localStorage from '../../infrastructure/local-storage'
import getMeta from '../../utils/meta' import getMeta from '../../utils/meta'
import { debugConsole } from '@/utils/debugging' import { debugConsole } from '@/utils/debugging'
import { BinaryFile } from '@/features/file-view/types/binary-file' import { BinaryFile } from '@/features/file-view/types/binary-file'
import useScopeEventEmitter from '@/shared/hooks/use-scope-event-emitter'
export type IdeLayout = 'sideBySide' | 'flat' export type IdeLayout = 'sideBySide' | 'flat'
export type IdeView = 'editor' | 'file' | 'pdf' | 'history' export type IdeView = 'editor' | 'file' | 'pdf' | 'history'
@ -60,15 +61,15 @@ function setLayoutInLocalStorage(pdfLayout: IdeLayout) {
export const LayoutProvider: FC = ({ children }) => { export const LayoutProvider: FC = ({ children }) => {
// what to show in the "flat" view (editor or pdf) // what to show in the "flat" view (editor or pdf)
const [view, _setView] = useScopeValue<IdeView>('ui.view') const [view, _setView] = useScopeValue<IdeView>('ui.view')
const [toggleHistory] = useScopeValue<() => void>('toggleHistory')
const [openFile] = useScopeValue<BinaryFile | null>('openFile') const [openFile] = useScopeValue<BinaryFile | null>('openFile')
const historyToggleEmitter = useScopeEventEmitter('history:toggle', true)
const setView = useCallback( const setView = useCallback(
(value: IdeView) => { (value: IdeView) => {
_setView(oldValue => { _setView(oldValue => {
// ensure that the "history:toggle" event is broadcast when switching in or out of history view // ensure that the "history:toggle" event is broadcast when switching in or out of history view
if (value === 'history' || oldValue === 'history') { if (value === 'history' || oldValue === 'history') {
toggleHistory() historyToggleEmitter()
} }
if (value === 'editor' && openFile) { if (value === 'editor' && openFile) {
@ -82,7 +83,7 @@ export const LayoutProvider: FC = ({ children }) => {
return value return value
}) })
}, },
[_setView, openFile, toggleHistory] [_setView, openFile, historyToggleEmitter]
) )
// whether the chat pane is open // whether the chat pane is open

View file

@ -89,7 +89,6 @@ const initialize = () => {
pdfViewer: 'js', pdfViewer: 'js',
syntaxValidation: true, syntaxValidation: true,
}, },
toggleHistory: () => {},
editor: { editor: {
richText: false, richText: false,
sharejs_doc: { sharejs_doc: {

View file

@ -116,7 +116,6 @@ export function EditorProviders({
}, },
$on: sinon.stub(), $on: sinon.stub(),
$applyAsync: sinon.stub(), $applyAsync: sinon.stub(),
toggleHistory: sinon.stub(),
permissionsLevel, permissionsLevel,
}, },
scope scope