diff --git a/services/web/app/views/project/list/modals.pug b/services/web/app/views/project/list/modals.pug deleted file mode 100644 index e9d122b0da..0000000000 --- a/services/web/app/views/project/list/modals.pug +++ /dev/null @@ -1,257 +0,0 @@ -script(type='text/ng-template', id='newTagModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="cancel()" - aria-label="Close" - ) - span(aria-hidden="true") × - h3 #{translate("create_new_folder")} - .modal-body - form(name="newTagForm", novalidate) - input.form-control( - type="text", - placeholder="New Folder Name", - required, - ng-model="inputs.newTagName", - on-enter="create()", - focus-on="open", - stop-propagation="click" - ) - .modal-footer - .modal-footer-left - span.text-danger.error(ng-show="state.error") #{translate("generic_something_went_wrong")} - //- We stop propagation to stop the clicks from closing the - //- 'move to folder' menu. - button.btn.btn-secondary( - ng-click="cancel()" - stop-propagation="click" - ) #{translate("cancel")} - button.btn.btn-primary( - ng-disabled="newTagForm.$invalid || state.inflight" - ng-click="create()" - stop-propagation="click" - ) - span(ng-show="!state.inflight") #{translate("create")} - span(ng-show="state.inflight") #{translate("creating")}… - -script(type='text/ng-template', id='deleteTagModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="cancel()" - aria-label="Close" - ) - span(aria-hidden="true") × - h3 #{translate("delete_folder")} - .modal-body - p #{translate("about_to_delete_folder")} - ul - li - strong {{tag.name}} - .modal-footer - .modal-footer-left - span.text-danger.error(ng-show="state.error") #{translate("generic_something_went_wrong")} - button.btn.btn-secondary( - ng-click="cancel()" - ) #{translate("cancel")} - button.btn.btn-danger( - ng-click="delete()", - ng-disabled="state.inflight" - ) - span(ng-show="state.inflight") #{translate("deleting")}… - span(ng-show="!state.inflight") #{translate("delete")} - -script(type='text/ng-template', id='renameTagModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="cancel()" - aria-label="Close" - ) - span(aria-hidden="true") × - h3 #{translate("rename_folder")} - .modal-body - form(name="renameTagForm", novalidate) - input.form-control( - type="text", - placeholder="Tag Name", - ng-model="inputs.tagName", - required, - on-enter="rename()", - focus-on="open" - ) - .modal-footer - .modal-footer-left - span.text-danger.error(ng-show="state.error") #{translate("generic_something_went_wrong")} - button.btn.btn-secondary(ng-click="cancel()") #{translate("cancel")} - button.btn.btn-primary( - ng-click="rename()", - ng-disabled="renameTagForm.$invalid || state.inflight" - ) - span(ng-show="!state.inflight") #{translate("rename")} - span(ng-show="state.inflight") #{translate("renaming")}… - -script(type='text/ng-template', id='renameProjectModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="cancel()" - aria-label="Close" - ) - span(aria-hidden="true") × - h3 #{translate("rename_project")} - .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(name="renameProjectForm", novalidate) - input.form-control( - type="text", - placeholder="Project Name", - ng-model="inputs.projectName", - required, - on-enter="rename()", - focus-on="open" - ) - .modal-footer - button.btn.btn-secondary(ng-click="cancel()") #{translate("cancel")} - button.btn.btn-primary( - ng-click="rename()", - ng-disabled="renameProjectForm.$invalid || state.inflight" - ) - span(ng-show="!state.inflight") #{translate("rename")} - span(ng-show="state.inflight") #{translate("renaming")}… - -script(type='text/ng-template', id='cloneProjectModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="cancel()" - aria-label="Close" - ) - span(aria-hidden="true") × - h3 #{translate("copy_project")} - .modal-body - .alert.alert-danger(ng-show="state.error.message") {{state.error.message === "invalid element name" ? "#{translate("invalid_element_name")}" : state.error.message}} - .alert.alert-danger(ng-show="state.error && !state.error.message") #{translate("generic_something_went_wrong")} - form(name="cloneProjectForm", novalidate) - .form-group - label #{translate("new_name")} - input.form-control( - type="text", - placeholder="New Project Name", - required, - ng-model="inputs.projectName", - on-enter="clone()", - focus-on="open" - ) - .modal-footer - button.btn.btn-secondary( - ng-disabled="state.inflight" - ng-click="cancel()" - ) #{translate("cancel")} - button.btn.btn-primary( - ng-disabled="cloneProjectForm.$invalid || state.inflight" - ng-click="clone()" - ) - span(ng-hide="state.inflight") #{translate("copy")} - span(ng-show="state.inflight") #{translate("copying")} … - -script(type='text/ng-template', id='newProjectModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="cancel()" - aria-label="Close" - ) - span(aria-hidden="true") × - h3 #{translate("new_project")} - .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(novalidate, name="newProjectForm") - input.form-control( - type="text", - placeholder="Project Name", - required, - ng-model="inputs.projectName", - on-enter="create()", - focus-on="open" - ) - .modal-footer - button.btn.btn-secondary( - ng-disabled="state.inflight" - ng-click="cancel()" - ) #{translate("cancel")} - button.btn.btn-primary( - ng-disabled="newProjectForm.$invalid || state.inflight" - ng-click="create()" - ) - span(ng-hide="state.inflight") #{translate("create")} - span(ng-show="state.inflight") #{translate("creating")}… - -script(type='text/ng-template', id='archiveTrashLeaveOrDeleteProjectsModalTemplate') - .modal-header - button.close( - type="button" - data-dismiss="modal" - ng-click="cancel()" - aria-label="Close" - ) - span(aria-hidden="true") × - h3(ng-if="action === 'archive'") #{translate("archive_projects")} - h3(ng-if="action === 'trash'") #{translate("trash_projects")} - h3(ng-if="action === 'leave'") #{translate("leave_projects")} - h3(ng-if="action === 'delete'") #{translate("delete_projects")} - h3(ng-if="action === 'leaveOrDelete'") #{translate("delete_and_leave_projects")} - .modal-body - div(ng-if="action !== 'leaveOrDelete'") - p(ng-if="action === 'archive'") #{translate("about_to_archive_projects")} - p(ng-if="action === 'trash'") #{translate("about_to_trash_projects")} - p(ng-if="action === 'leave'") #{translate("about_to_leave_projects")} - p(ng-if="action === 'delete'") #{translate("about_to_delete_projects")} - ul - li(ng-repeat="project in projects | orderBy:'name'") - strong {{project.name}} - div(ng-if="action === 'archive'") - p #{translate("archiving_projects_wont_affect_collaborators")} - |   - a( - href="https://www.overleaf.com/blog/new-feature-using-archive-and-trash-to-keep-your-projects-organized" - target="_blank" - ) #{translate("find_out_more_nt")} - div(ng-if="action === 'trash'") - p #{translate("trashing_projects_wont_affect_collaborators")} - |   - a( - href="https://www.overleaf.com/blog/new-feature-using-archive-and-trash-to-keep-your-projects-organized" - target="_blank" - ) #{translate("find_out_more_nt")} - .project-action-alert.alert.alert-warning(ng-if="action === 'leave' || action === 'delete'") - i.fa.fa-fw.fa-exclamation-triangle - .project-action-alert-msg #{translate("this_action_cannot_be_undone")} - div(ng-if="action === 'leaveOrDelete'") - p #{translate("about_to_delete_projects")} - ul - li(ng-repeat="project in projects | filter:{accessLevel: 'owner'} | orderBy:'name'") - strong {{project.name}} - p #{translate("about_to_leave_projects")} - ul - li(ng-repeat="project in projects | filter:{accessLevel: '!owner'} | orderBy:'name'") - strong {{project.name}} - .project-action-alert.alert.alert-warning - i.fa.fa-fw.fa-exclamation-triangle - .project-action-alert-msg #{translate("this_action_cannot_be_undone")} - .modal-footer - button.btn.btn-secondary( - ng-click="cancel()" - ) #{translate("cancel")} - button.btn.btn-danger( - ng-click="confirm()" - ) #{translate("confirm")} diff --git a/services/web/frontend/js/main.js b/services/web/frontend/js/main.js index cbf22343ec..644651c1f0 100644 --- a/services/web/frontend/js/main.js +++ b/services/web/frontend/js/main.js @@ -9,7 +9,6 @@ * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import './main/token-access' -import './main/project-list/index' import './main/clear-sessions' import './main/account-upgrade-angular' import './main/plans' diff --git a/services/web/frontend/js/main/project-list/index.js b/services/web/frontend/js/main/project-list/index.js deleted file mode 100644 index 6b1205ad52..0000000000 --- a/services/web/frontend/js/main/project-list/index.js +++ /dev/null @@ -1,5 +0,0 @@ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -import './modal-controllers' -import './tag-controllers' -import '../../services/queued-http' diff --git a/services/web/frontend/js/main/project-list/modal-controllers.js b/services/web/frontend/js/main/project-list/modal-controllers.js deleted file mode 100644 index e553c0d90b..0000000000 --- a/services/web/frontend/js/main/project-list/modal-controllers.js +++ /dev/null @@ -1,63 +0,0 @@ -/* eslint-disable - n/handle-callback-err, - 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' -App.controller( - 'CloneProjectModalController', - function ($scope, $modalInstance, $timeout, project) { - $scope.inputs = { projectName: project.name + ' (Copy)' } - $scope.state = { - inflight: false, - error: false, - } - - $modalInstance.opened.then(() => - $timeout(() => $scope.$broadcast('open'), 200) - ) - - $scope.clone = function () { - $scope.state.inflight = true - return $scope - .cloneProject(project, $scope.inputs.projectName) - .then(function () { - $scope.state.inflight = false - $scope.state.error = 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) - } - }) - } - - return ($scope.cancel = () => $modalInstance.dismiss('cancel')) - } -) - -App.controller( - 'ArchiveTrashLeaveOrDeleteProjectsModalController', - function ($scope, $modalInstance, $timeout, projects, action) { - $scope.projects = projects - - $scope.action = action - - $scope.confirm = () => $modalInstance.close({ projects, action }) - - $scope.cancel = () => $modalInstance.dismiss('cancel') - } -) diff --git a/services/web/frontend/js/main/project-list/tag-controllers.js b/services/web/frontend/js/main/project-list/tag-controllers.js deleted file mode 100644 index a2a825fcc1..0000000000 --- a/services/web/frontend/js/main/project-list/tag-controllers.js +++ /dev/null @@ -1,226 +0,0 @@ -import App from '../../base' -import ColorManager from '../../ide/colors/ColorManager' -App.controller('TagListController', function ($scope, $modal) { - $scope.filterProjects = function (filter = 'all') { - $scope._clearTags() - $scope.setFilter(filter) - } - - $scope._clearTags = () => - $scope.tags.forEach(tag => { - tag.selected = false - }) - - $scope.selectTag = function (tag) { - $scope._clearTags() - tag.selected = true - $scope.setFilter('tag') - } - - $scope.selectUntagged = function () { - $scope._clearTags() - $scope.setFilter('untagged') - } - - $scope.countProjectsForTag = function (tag) { - return tag.project_ids.reduce((acc, projectId) => { - const project = $scope.getProjectById(projectId) - - // There is a bug where the tag is not cleaned up when you leave a - // project, so tag.project_ids can contain a project that the user can - // no longer access. If the project cannot be found, ignore it - if (!project) return acc - - // Ignore archived projects as they are not shown in the filter - if (!(project.archived || project.trashed)) { - return acc + 1 - } else { - return acc - } - }, 0) - } - - $scope.getHueForTagId = tagId => ColorManager.getHueForTagId(tagId) - - $scope.deleteTag = function (tag) { - const modalInstance = $modal.open({ - templateUrl: 'deleteTagModalTemplate', - controller: 'DeleteTagModalController', - resolve: { - tag() { - return tag - }, - }, - }) - modalInstance.result.then(function () { - // Remove tag from projects - for (const project of $scope.projects) { - if (!project.tags) { - project.tags = [] - } - const index = project.tags.indexOf(tag) - if (index > -1) { - project.tags.splice(index, 1) - } - } - - // Remove tag in place to update the state everywhere - $scope.tags.splice($scope.tags.indexOf(tag), 1) - }) - } - - $scope.renameTag = function (tag) { - const modalInstance = $modal.open({ - templateUrl: 'renameTagModalTemplate', - controller: 'RenameTagModalController', - resolve: { - tag() { - return tag - }, - }, - }) - modalInstance.result.then(newName => (tag.name = newName)) - } -}) - -App.controller('TagDropdownItemController', function ($scope) { - $scope.recalculateProjectsInTag = function () { - let partialSelection - $scope.areSelectedProjectsInTag = false - for (const projectId of $scope.getSelectedProjectIds()) { - if ($scope.tag.project_ids.includes(projectId)) { - $scope.areSelectedProjectsInTag = true - } else { - partialSelection = true - } - } - - if ($scope.areSelectedProjectsInTag && partialSelection) { - $scope.areSelectedProjectsInTag = 'partial' - } - } - - $scope.addOrRemoveProjectsFromTag = function () { - if ($scope.areSelectedProjectsInTag === true) { - $scope.removeSelectedProjectsFromTag($scope.tag) - $scope.areSelectedProjectsInTag = false - } else if ( - $scope.areSelectedProjectsInTag === false || - $scope.areSelectedProjectsInTag === 'partial' - ) { - $scope.addSelectedProjectsToTag($scope.tag) - $scope.areSelectedProjectsInTag = true - } - } - - $scope.$watch('selectedProjects', () => $scope.recalculateProjectsInTag()) - $scope.recalculateProjectsInTag() -}) - -App.controller( - 'NewTagModalController', - function ($scope, $modalInstance, $timeout, $http) { - $scope.inputs = { newTagName: '' } - - $scope.state = { - inflight: false, - error: false, - } - - $modalInstance.opened.then(() => - $timeout(() => $scope.$broadcast('open'), 200) - ) - - $scope.create = function () { - const name = $scope.inputs.newTagName - $scope.state.inflight = true - $scope.state.error = false - $http - .post('/tag', { - _csrf: window.csrfToken, - name, - }) - .then(function (response) { - const { data } = response - $scope.state.inflight = false - $modalInstance.close(data) - }) - .catch(function () { - $scope.state.inflight = false - $scope.state.error = true - }) - } - - $scope.cancel = () => $modalInstance.dismiss('cancel') - } -) - -App.controller( - 'RenameTagModalController', - function ($scope, $modalInstance, $timeout, $http, tag) { - $scope.inputs = { tagName: tag.name } - - $scope.state = { - inflight: false, - error: false, - } - - $modalInstance.opened.then(() => - $timeout(() => $scope.$broadcast('open'), 200) - ) - - $scope.rename = function () { - const name = $scope.inputs.tagName - $scope.state.inflight = true - $scope.state.error = false - return $http - .post(`/tag/${tag._id}/rename`, { - _csrf: window.csrfToken, - name, - }) - .then(function () { - $scope.state.inflight = false - $modalInstance.close(name) - }) - .catch(function () { - $scope.state.inflight = false - $scope.state.error = true - }) - } - - $scope.cancel = () => $modalInstance.dismiss('cancel') - } -) - -export default App.controller( - 'DeleteTagModalController', - function ($scope, $modalInstance, $http, tag) { - $scope.tag = tag - $scope.state = { - inflight: false, - error: false, - } - - $scope.delete = function () { - $scope.state.inflight = true - $scope.state.error = false - return $http({ - method: 'DELETE', - url: `/tag/${tag._id}`, - headers: { - 'X-CSRF-Token': window.csrfToken, - }, - }) - .then(function () { - $scope.state.inflight = false - $modalInstance.close() - }) - .catch(function () { - $scope.state.inflight = false - $scope.state.error = true - }) - } - - $scope.cancel = () => $modalInstance.dismiss('cancel') - } -) diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 927ce0de0d..97947d72be 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -18,7 +18,6 @@ "a_more_comprehensive_list_of_keyboard_shortcuts": "A more comprehensive list of keyboard shortcuts can be found in <0>this __appName__ project template", "about": "About", "about_to_archive_projects": "You are about to archive the following projects:", - "about_to_delete_folder": "You are about to delete the following folders (any projects in them will not be deleted):", "about_to_delete_projects": "You are about to delete the following projects:", "about_to_delete_tag": "You are about to delete the following tag (any projects in them will not be deleted):", "about_to_delete_the_following_project": "You are about to delete the following project", @@ -339,7 +338,6 @@ "create_first_admin_account": "Create the first Admin account", "create_first_project": "Create First Project", "create_new_account": "Create new account", - "create_new_folder": "Create New Folder", "create_new_subscription": "Create New Subscription", "create_new_tag": "Create new tag", "create_project_in_github": "Create a GitHub repository", @@ -382,7 +380,6 @@ "delete_authentication_token": "Delete Authentication token", "delete_authentication_token_info": "You’re about to delete a Git authentication token. If you do, it can no longer be used to authenticate your identity when performing Git operations.", "delete_figure": "Delete figure", - "delete_folder": "Delete Folder", "delete_projects": "Delete Projects", "delete_row_or_column": "Delete row or column", "delete_table": "Delete table", @@ -846,7 +843,6 @@ "integrations": "Integrations", "interested_in": "Interested in", "interested_in_cheaper_personal_plan": "Would you be interested in the cheaper <0>__price__ Personal plan?", - "invalid_element_name": "Could not copy your project because of filenames containing invalid characters\r\n(such as asterisks, slashes or control characters). Please rename the files and\r\ntry again.", "invalid_email": "An email address is invalid", "invalid_file_name": "Invalid File Name", "invalid_filename": "Upload failed: check that the file name doesn’t contain special characters, trailing/leading whitespace or more than __nameLimit__ characters", @@ -1435,7 +1431,6 @@ "removed": "removed", "removing": "Removing", "rename": "Rename", - "rename_folder": "Rename Folder", "rename_project": "Rename Project", "renaming": "Renaming", "reopen": "Re-open",