diff --git a/services/web/public/coffee/ide/settings/controllers/ProjectNameController.coffee b/services/web/public/coffee/ide/settings/controllers/ProjectNameController.coffee index 01f441b603..0741fbc862 100644 --- a/services/web/public/coffee/ide/settings/controllers/ProjectNameController.coffee +++ b/services/web/public/coffee/ide/settings/controllers/ProjectNameController.coffee @@ -1,6 +1,7 @@ define [ "base" ], (App) -> + MAX_PROJECT_NAME_LENGTH = 150 App.controller "ProjectNameController", ["$scope", "settings", "ide", ($scope, settings, ide) -> $scope.state = renaming: false @@ -12,11 +13,12 @@ define [ $scope.$emit "project:rename:start" $scope.finishRenaming = () -> - newName = $scope.inputs.name - if newName.length < 150 - $scope.project.name = newName - settings.saveProjectSettings({name: $scope.project.name}) $scope.state.renaming = false + newName = $scope.inputs.name + if !newName? or newName.length == 0 or newName.length > MAX_PROJECT_NAME_LENGTH + return + $scope.project.name = newName + settings.saveProjectSettings({name: $scope.project.name}) ide.socket.on "projectNameUpdated", (name) -> $scope.$apply () -> diff --git a/services/web/public/coffee/main/project-list/project-list.coffee b/services/web/public/coffee/main/project-list/project-list.coffee index 4c4c1daf03..a528c0b96f 100644 --- a/services/web/public/coffee/main/project-list/project-list.coffee +++ b/services/web/public/coffee/main/project-list/project-list.coffee @@ -257,9 +257,11 @@ define [ modalInstance.result.then (project_id) -> window.location = "/project/#{project_id}" + MAX_PROJECT_NAME_LENGTH = 150 $scope.renameProject = (project, newName) -> - if newName.length < 150 - project.name = newName + if !newName? or newName.length == 0 or newName.length > MAX_PROJECT_NAME_LENGTH + return + project.name = newName queuedHttp.post "/project/#{project.id}/rename", { newProjectName: project.name _csrf: window.csrfToken