Repository: syncthing/syncthing
File: gui/default/untrusted/syncthing/core/syncthingController.js (JavaScript)

Code before:
                    $scope.emitHTTPError(err);
                });

            $scope.editFolderModal();
        };

        $scope.selectAllSharedDevices = function (state) {
            var devices = $scope.currentSharing.shared;
            for (var i = 0; i < devices.length; i++) {
                $scope.currentSharing.selected[devices[i].deviceID] = !!state;
            }
        };

        $scope.selectAllUnrelatedDevices = function (state) {
            var devices = $scope.currentSharing.unrelated;
            for (var i = 0; i < devices.length; i++) {
                $scope.currentSharing.selected[devices[i].deviceID] = !!state;
            }
        };

        function addFolderInit(recvEnc) {
            $scope.editingExisting = false;
            $scope.currentFolder = angular.copy($scope.folderDefaults);
            if (recvEnc) {
                $scope.currentFolder.type = "receiveencrypted";
                $scope.currentFolder.ignorePerms = true;
                delete $scope.currentFolder.versioning;
            }
            initShareEditing('folder');
            $scope.ignores.text = '';
            $scope.ignores.error = null;
            $scope.ignores.disabled = false;
        }

        $scope.addFolder = function () {
            $http.get(urlbase + '/svc/random/string?length=10').success(function (data) {
                addFolderInit(false);
                $scope.currentFolder.id = (data.random.substr(0, 5) + '-' + data.random.substr(5, 5)).toLowerCase();
                $scope.currentSharing.unrelated = $scope.otherDevices();
                $scope.editFolderModal();
            });
        };

        $scope.addFolderAndShare = function (folder, folderLabel, device) {
            var pendingFolder = $scope.pendingFolders[folder];
            var recvEnc = false;
            for (var k in pendingFolder.offeredBy) {
                if (pendingFolder.offeredBy[k].receiveEncrypted) {
                    recvEnc = "receiveencrypted";
                    break;
                }

Review comment (security):
Isn't this something the backend should enforce if permission synchronization is not useful for encrypted folders?  Also applies to versioning settings.

I think such things should not be the GUI's responsibility.

Code after:
            if ($scope.editingDefaults) {
                return $translate.instant("Edit Folder Defaults");
            }
            var title = '';
            if ($scope.editingExisting) {
                title += $translate.instant("Edit Folder");
            } else {
                title += $translate.instant("Add Folder");
            }
            if ($scope.currentFolder.id !== '') {
                title += ' (' + $scope.folderLabel($scope.currentFolder.id) + ')';
            }
            return title;
        };

        $scope.editFolderModalIcon = function() {
            if ($scope.editingDefaults || $scope.editingExisting) {
                return 'fas fa-pencil-alt';
            }
            return 'fas fa-folder';
        };

        function editFolder() {
            if ($scope.currentFolder.path.length > 1 && $scope.currentFolder.path.slice(-1) === $scope.system.pathSeparator) {
                $scope.currentFolder.path = $scope.currentFolder.path.slice(0, -1);
            } else if (!$scope.currentFolder.path) {
                // undefined path leads to invalid input field
                $scope.currentFolder.path = '';
            }
            initShareEditing('folder');
            editFolderModal();
        }

        function initVersioningEditing() {
            $scope.currentFolder._guiVersioning = angular.copy($scope.versioningDefaults);

            if (!$scope.currentFolder.versioning) {
                return;
            }

            var currentVersioning = $scope.currentFolder.versioning;

            $scope.currentFolder._guiVersioning.cleanupIntervalS = +currentVersioning.cleanupIntervalS;

            // Apply parameters currently in use
            switch (currentVersioning.type) {
            case "trashcan":
                $scope.currentFolder._guiVersioning.selector = "trashcan";
                $scope.currentFolder._guiVersioning.trashcanClean = +currentVersioning.params.cleanoutDays;
                break;
            case "simple":