From 464eeb49ec58e93bb88bbad1228e4d526931fd9b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 10 Sep 2020 13:55:57 -0500 Subject: [PATCH] Issue 70: Can Create invalid Remote Project Managers, breaking system. This expands upon PR #73 further removing the basic authentication for VersionOne as well. With these changes, it makes sense to remove the settings and simplify the model design. This better allows for validation using the existing weaver validation functionality. The most notable downside of this particular implementation is the database changes. The URL is now a validated and required part of the ManagementService. The token is now a validated part of the ManagementService, but is not explicitly required via the DB. Both Github and VersionOne require token, so the default behavior is to require the token. see: #70 see: #73 --- .../remoteProjectManagerFormDirective.js | 91 --------------- app/index.html | 1 - app/repo/remoteProjectManagerRepo.js | 4 +- .../directives/remoteProjectManagerForm.html | 13 --- .../management/remoteProjectManager.html | 11 +- .../modals/addRemoteProjectManagerModal.html | 4 +- .../modals/editRemoteProjectManagerModal.html | 4 +- tests/mock/model/mockProduct.js | 27 ++--- tests/mock/model/mockRemoteProjectManager.js | 21 +--- .../mock/repo/mockRemoteProjectManagerRepo.js | 4 +- .../remoteProjectManagerFormDirectiveTest.js | 106 ------------------ 11 files changed, 29 insertions(+), 257 deletions(-) delete mode 100644 app/directives/remoteProjectManagerFormDirective.js delete mode 100644 app/views/directives/remoteProjectManagerForm.html delete mode 100644 tests/unit/directives/remoteProjectManagerFormDirectiveTest.js diff --git a/app/directives/remoteProjectManagerFormDirective.js b/app/directives/remoteProjectManagerFormDirective.js deleted file mode 100644 index 3ba818b..0000000 --- a/app/directives/remoteProjectManagerFormDirective.js +++ /dev/null @@ -1,91 +0,0 @@ -app.directive('remoteProjectManagerForm', function () { - return { - templateUrl: 'views/directives/remoteProjectManagerForm.html', - restrict: 'E', - replace: false, - scope: { - 'managementType': '<', - 'managementSettings': '=', - 'model': '=' - }, - link: function ($scope) { - - $scope.auth = { - useToken: false, - required: false - }; - - var originalType; - - var isAuthRequired = function () { - $scope.auth.useToken = false; - $scope.auth.required = false; - - for (var i in $scope.managementSettings) { - var key = $scope.managementSettings[i].key; - if (key === 'password') { - $scope.auth.required = true; - } - - if (key === 'token') { - $scope.auth.useToken = true; - } - } - }; - - var refreshAuth = function () { - if (originalType === undefined || originalType == $scope.managementType) { - if (originalType === undefined) { - isAuthRequired(); - - originalType = $scope.managementType; - } - - if ($scope.auth.required) { - $scope.auth.useToken = false; - - for (var key in $scope.model.settings) { - var value = $scope.model.settings[key]; - - if (key === 'token' && value != undefined && value.length > 0) { - $scope.auth.useToken = true; - } - } - } - } else { - isAuthRequired(); - - originalType = $scope.managementType; - } - }; - - $scope.inputSetting = function (setting) { - var display = true; - if ($scope.auth.useToken) { - if (setting.key === 'username' || setting.key === 'password') { - display = false; - } - } else { - if (setting.key === 'token') { - display = false; - } - } - return display; - }; - - $scope.clearAuthSettings = function () { - for (var key in $scope.model.settings) { - if (key === 'token' || key === 'username' || key === 'password') { - $scope.model.settings[key] = ''; - } - } - }; - - refreshAuth(); - - $scope.$watch('managementType', function() { - refreshAuth(); - }); - } - }; -}); diff --git a/app/index.html b/app/index.html index d3155db..d151a9b 100644 --- a/app/index.html +++ b/app/index.html @@ -193,7 +193,6 @@ - diff --git a/app/repo/remoteProjectManagerRepo.js b/app/repo/remoteProjectManagerRepo.js index 7a9e6ee..4a0e5f1 100644 --- a/app/repo/remoteProjectManagerRepo.js +++ b/app/repo/remoteProjectManagerRepo.js @@ -2,7 +2,9 @@ app.repo("RemoteProjectManagerRepo", function RemoteProjectManagerRepo($q, WsApi this.scaffold = { name: '', - type: '' + type: '', + url: '', + token: '' }; this.getTypes = function () { diff --git a/app/views/directives/remoteProjectManagerForm.html b/app/views/directives/remoteProjectManagerForm.html deleted file mode 100644 index 93d85db..0000000 --- a/app/views/directives/remoteProjectManagerForm.html +++ /dev/null @@ -1,13 +0,0 @@ -
- - -
-
- -
- -
-
diff --git a/app/views/management/remoteProjectManager.html b/app/views/management/remoteProjectManager.html index ed5c6e5..d6d3202 100644 --- a/app/views/management/remoteProjectManager.html +++ b/app/views/management/remoteProjectManager.html @@ -6,19 +6,12 @@ - + - +
Remote Project ManagerSettingsURL Actions
{{remoteProjectManager.name}} -
    -
  • - -  {{remoteProjectManager.settings[setting.key]}} -
  • -
-
{{remoteProjectManager.url}} diff --git a/app/views/modals/addRemoteProjectManagerModal.html b/app/views/modals/addRemoteProjectManagerModal.html index b2efdb0..2557d17 100644 --- a/app/views/modals/addRemoteProjectManagerModal.html +++ b/app/views/modals/addRemoteProjectManagerModal.html @@ -14,7 +14,9 @@ - + + +