From 6c265747183669fb092501dbc93812c128641ee6 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Thu, 10 May 2018 12:29:55 -0400 Subject: [PATCH 1/6] add new row items to token list --- .../client/features/users/tokens/tokens.strings.js | 5 ++++- .../users/tokens/users-tokens-list.partial.html | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/features/users/tokens/tokens.strings.js b/awx/ui/client/features/users/tokens/tokens.strings.js index ac0af8e15f..27b9450992 100644 --- a/awx/ui/client/features/users/tokens/tokens.strings.js +++ b/awx/ui/client/features/users/tokens/tokens.strings.js @@ -34,7 +34,10 @@ function TokensStrings (BaseString) { ns.list = { ROW_ITEM_LABEL_DESCRIPTION: t.s('DESCRIPTION'), ROW_ITEM_LABEL_EXPIRED: t.s('EXPIRATION'), - ROW_ITEM_LABEL_USED: t.s('LAST USED') + ROW_ITEM_LABEL_USED: t.s('LAST USED'), + ROW_ITEM_LABEL_SCOPE: t.s('SCOPE'), + ROW_ITEM_LABEL_APPLICATION: t.s('APPLICATION'), + HEADER: appName => t.s('{{ appName }} Token', { appName }), }; } diff --git a/awx/ui/client/features/users/tokens/users-tokens-list.partial.html b/awx/ui/client/features/users/tokens/users-tokens-list.partial.html index e460e5ecf4..9a25c09c23 100644 --- a/awx/ui/client/features/users/tokens/users-tokens-list.partial.html +++ b/awx/ui/client/features/users/tokens/users-tokens-list.partial.html @@ -25,15 +25,24 @@
+ header-value="{{ vm.strings.get('list.HEADER', token.summary_fields.application.name) }}"> + + + + + value="{{ token.expires | longDate }}"> Date: Thu, 10 May 2018 12:38:56 -0400 Subject: [PATCH 2/6] use translated string for scope in tokens list --- .../features/users/tokens/users-tokens-list.controller.js | 8 ++++++++ .../features/users/tokens/users-tokens-list.partial.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/awx/ui/client/features/users/tokens/users-tokens-list.controller.js b/awx/ui/client/features/users/tokens/users-tokens-list.controller.js index c2fe647928..ecd3d68c39 100644 --- a/awx/ui/client/features/users/tokens/users-tokens-list.controller.js +++ b/awx/ui/client/features/users/tokens/users-tokens-list.controller.js @@ -37,6 +37,14 @@ function ListTokensController ( $scope[name] = dataset.results; vm.tokensCount = dataset.count; }); + + vm.getScopeString = str => { + if (str === 'Read') { + return vm.strings.get('add.SCOPE_READ_LABEL'); + } else if (str === 'Write') { + return vm.strings.get('add.SCOPE_WRITE_LABEL'); + } + } vm.getLastUsed = token => { const lastUsed = _.get(token, 'last_used'); diff --git a/awx/ui/client/features/users/tokens/users-tokens-list.partial.html b/awx/ui/client/features/users/tokens/users-tokens-list.partial.html index 9a25c09c23..b92d24811a 100644 --- a/awx/ui/client/features/users/tokens/users-tokens-list.partial.html +++ b/awx/ui/client/features/users/tokens/users-tokens-list.partial.html @@ -33,7 +33,7 @@ + value="{{ vm.getScopeString(token.scope) }}"> Date: Thu, 10 May 2018 13:38:56 -0400 Subject: [PATCH 3/6] use app name as part of delete token confirmation modal header --- .../features/users/tokens/users-tokens-list.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/features/users/tokens/users-tokens-list.controller.js b/awx/ui/client/features/users/tokens/users-tokens-list.controller.js index ecd3d68c39..fdeb821dcf 100644 --- a/awx/ui/client/features/users/tokens/users-tokens-list.controller.js +++ b/awx/ui/client/features/users/tokens/users-tokens-list.controller.js @@ -103,7 +103,7 @@ function ListTokensController ( Prompt({ hdr: strings.get('deleteResource.HEADER'), - resourceName: 'token', + resourceName: strings.get('list.HEADER', tok.summary_fields.application.name), body: deleteModalBody, action, actionText: strings.get('add.DELETE_ACTION_LABEL') From 924cb51d51e1e8ba079b4c9ca7e9193fa9bb4175 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Thu, 10 May 2018 13:45:46 -0400 Subject: [PATCH 4/6] make delete of app work when you are on app's tokens route --- .../features/applications/list-applications.controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/features/applications/list-applications.controller.js b/awx/ui/client/features/applications/list-applications.controller.js index 8a6ad5a8bf..b9353f8d88 100644 --- a/awx/ui/client/features/applications/list-applications.controller.js +++ b/awx/ui/client/features/applications/list-applications.controller.js @@ -78,7 +78,7 @@ function ListApplicationsController ( } if (parseInt($state.params.application_id, 10) === app.id) { - $state.go('^', reloadListStateParams, { reload: true }); + $state.go('applications', reloadListStateParams, { reload: true }); } else { $state.go('.', reloadListStateParams, { reload: true }); } From 8a2c3ce7165758b4e892b18f84c860e82f75377b Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Thu, 10 May 2018 14:13:13 -0400 Subject: [PATCH 5/6] add tokens to activity stream --- .../client/features/users/tokens/users-tokens-add.route.js | 5 +++++ .../client/features/users/tokens/users-tokens-list.route.js | 5 +++++ .../client/src/activity-stream/get-target-title.factory.js | 3 +++ .../streamDropdownNav/stream-dropdown-nav.directive.js | 1 + awx/ui/client/src/bread-crumb/bread-crumb.directive.js | 4 ++-- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/features/users/tokens/users-tokens-add.route.js b/awx/ui/client/features/users/tokens/users-tokens-add.route.js index 350e9bd2dd..56effe1991 100644 --- a/awx/ui/client/features/users/tokens/users-tokens-add.route.js +++ b/awx/ui/client/features/users/tokens/users-tokens-add.route.js @@ -21,6 +21,11 @@ export default { name: 'users.edit.tokens.add', params: { }, + data: { + activityStream: true, + activityStreamTarget: 'o_auth2_access_token', + noActivityStreamID: true + }, ncyBreadcrumb: { label: N_('CREATE TOKEN') }, diff --git a/awx/ui/client/features/users/tokens/users-tokens-list.route.js b/awx/ui/client/features/users/tokens/users-tokens-list.route.js index c8a780e473..d262bbe944 100644 --- a/awx/ui/client/features/users/tokens/users-tokens-list.route.js +++ b/awx/ui/client/features/users/tokens/users-tokens-list.route.js @@ -17,6 +17,11 @@ export default { controllerAs: 'vm' } }, + data: { + activityStream: true, + activityStreamTarget: 'o_auth2_access_token', + noActivityStreamID: true + }, searchPrefix: 'token', params: { token_search: { diff --git a/awx/ui/client/src/activity-stream/get-target-title.factory.js b/awx/ui/client/src/activity-stream/get-target-title.factory.js index 88d274f58f..d895daa988 100644 --- a/awx/ui/client/src/activity-stream/get-target-title.factory.js +++ b/awx/ui/client/src/activity-stream/get-target-title.factory.js @@ -46,6 +46,9 @@ export default function GetTargetTitle(i18n) { case 'o_auth2_application': rtnTitle = i18n._('APPLICATIONS'); break; + case 'o_auth2_access_token': + rtnTitle = i18n._('TOKENS'); + break; } return rtnTitle; diff --git a/awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js b/awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js index e60170c310..e6b0ff87be 100644 --- a/awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js +++ b/awx/ui/client/src/activity-stream/streamDropdownNav/stream-dropdown-nav.directive.js @@ -22,6 +22,7 @@ export default ['templateUrl', 'i18n', function(templateUrl, i18n) { $scope.options = [ {label: i18n._('All Activity'), value: 'dashboard'}, {label: i18n._('Applications'), value: 'o_auth2_application'}, + {label: i18n._('Tokens'), value: 'o_auth2_access_token'}, {label: i18n._('Credentials'), value: 'credential'}, {label: i18n._('Hosts'), value: 'host'}, {label: i18n._('Inventories'), value: 'inventory'}, diff --git a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js index 41b7bc26ca..eeecf9e4c0 100644 --- a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js +++ b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js @@ -97,7 +97,7 @@ export default order_by: '-timestamp', page_size: '20', }; - if (streamConfig.activityStreamTarget && streamConfig.activityStreamId) { + if (streamConfig.activityStreamTarget && streamConfig.activityStreamId && !streamConfig.noActivityStreamID) { stateGoParams.activity_search[streamConfig.activityStreamTarget] = $state.params[streamConfig.activityStreamId]; } } @@ -107,7 +107,7 @@ export default page_size: '20', }; } - if(streamConfig.activityStreamId) { + if(streamConfig.activityStreamId && !streamConfig.noActivityStreamID) { stateGoParams.id = $state.params[streamConfig.activityStreamId]; } if(stateGoParams.target === "custom_inventory_script"){ From 97614892c613c25b9235057fb7bdba9b5dd0a595 Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Thu, 10 May 2018 14:17:38 -0400 Subject: [PATCH 6/6] fix syntax error in tokens list controller --- .../features/users/tokens/users-tokens-list.controller.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/features/users/tokens/users-tokens-list.controller.js b/awx/ui/client/features/users/tokens/users-tokens-list.controller.js index fdeb821dcf..056a77792a 100644 --- a/awx/ui/client/features/users/tokens/users-tokens-list.controller.js +++ b/awx/ui/client/features/users/tokens/users-tokens-list.controller.js @@ -37,14 +37,16 @@ function ListTokensController ( $scope[name] = dataset.results; vm.tokensCount = dataset.count; }); - + vm.getScopeString = str => { if (str === 'Read') { return vm.strings.get('add.SCOPE_READ_LABEL'); } else if (str === 'Write') { return vm.strings.get('add.SCOPE_WRITE_LABEL'); } - } + + return undefined; + }; vm.getLastUsed = token => { const lastUsed = _.get(token, 'last_used');