From 90a86f53ba25c819f9cb36d0c68cf3b67c8e343c Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 2 May 2019 17:13:17 -0400 Subject: [PATCH 1/6] Fix display bug on host groups list --- .../hosts/related/groups/hosts-related-groups.list.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.list.js b/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.list.js index ee79c9680a..f54c700063 100644 --- a/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.list.js +++ b/awx/ui/client/src/inventories-hosts/hosts/related/groups/hosts-related-groups.list.js @@ -15,7 +15,7 @@ export default ['i18n', function(i18n) { hover: true, trackBy: 'group.id', basePath: 'api/v2/hosts/{{$stateParams.host_id}}/groups/', - layoutClass: 'List-staticColumnLayout--groups', + layoutClass: 'List-staticColumnLayout--statusOrCheckbox', staticColumns: [ { field: 'failed_hosts', From d2e67aea199e1c5e203b0939be901c54b9154b06 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Fri, 3 May 2019 10:20:31 -0400 Subject: [PATCH 2/6] Fix server error for in-flight migration --- awx/main/middleware.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/awx/main/middleware.py b/awx/main/middleware.py index e2dcd9c1da..90f63fc1e2 100644 --- a/awx/main/middleware.py +++ b/awx/main/middleware.py @@ -127,6 +127,9 @@ class SessionTimeoutMiddleware(object): def process_response(self, request, response): should_skip = 'HTTP_X_WS_SESSION_QUIET' in request.META + # Something went wrong, such as upgrade-in-progress page + if not hasattr(request, 'session'): + return response # Only update the session if it hasn't been flushed by being forced to log out. if request.session and not request.session.is_empty() and not should_skip: expiry = int(settings.SESSION_COOKIE_AGE) From 70e513a3cf5535375821492162d8bac0a230f29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ely=C3=A9zer=20Rezende?= Date: Fri, 3 May 2019 16:20:01 -0400 Subject: [PATCH 3/6] Fix job list sorting options grouping Ensure that the sorting options are grouped just like every other sorting options list. --- awx/ui/client/features/jobs/jobsList.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/features/jobs/jobsList.controller.js b/awx/ui/client/features/jobs/jobsList.controller.js index 3881a4071c..922212965e 100644 --- a/awx/ui/client/features/jobs/jobsList.controller.js +++ b/awx/ui/client/features/jobs/jobsList.controller.js @@ -64,13 +64,13 @@ function ListJobsController ( { label: `${strings.get('sort.NAME_ASCENDING')}`, value: 'name' }, { label: `${strings.get('sort.NAME_DESCENDING')}`, value: '-name' }, { label: `${strings.get('sort.FINISH_TIME_ASCENDING')}`, value: 'finished' }, + toolbarSortDefault, { label: `${strings.get('sort.START_TIME_ASCENDING')}`, value: 'started' }, { label: `${strings.get('sort.START_TIME_DESCENDING')}`, value: '-started' }, { label: `${strings.get('sort.LAUNCHED_BY_ASCENDING')}`, value: 'created_by__id' }, { label: `${strings.get('sort.LAUNCHED_BY_DESCENDING')}`, value: '-created_by__id' }, { label: `${strings.get('sort.PROJECT_ASCENDING')}`, value: 'unified_job_template__project__id' }, - { label: `${strings.get('sort.PROJECT_DESCENDING')}`, value: '-unified_job_template__project__id' }, - toolbarSortDefault + { label: `${strings.get('sort.PROJECT_DESCENDING')}`, value: '-unified_job_template__project__id' } ]; vm.toolbarSortValue = toolbarSortDefault; From f524c94bad1a710d152c8539dc1471aa767017bd Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 7 May 2019 14:43:53 -0400 Subject: [PATCH 4/6] Fixes basic host filter searches --- .../client/src/shared/smart-search/queryset.service.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index 2db940b94c..df143f0580 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -1,7 +1,5 @@ function searchWithoutKey (term, singleSearchParam = null) { - if (singleSearchParam === 'host_filter') { - return { [singleSearchParam]: `${encodeURIComponent(term)}` }; - } else if (singleSearchParam) { + if (singleSearchParam) { return { [singleSearchParam]: `search=${encodeURIComponent(term)}` }; } return { search: encodeURIComponent(term) }; @@ -418,7 +416,11 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc let termParams; if (termParts.length === 1) { - termParams = searchWithoutKey(term, singleSearchParam); + if (singleSearchParam && termParts[0].toLowerCase() === "or") { + termParams = { [singleSearchParam]: "or" } + } else { + termParams = searchWithoutKey(term, singleSearchParam); + } } else if ((isAnsibleFactField && isAnsibleFactField(termParts)) || (isFilterableBaseField && isFilterableBaseField(termParts))) { termParams = this.encodeParam({ term, singleSearchParam, searchTerm: true }); } else if (isRelatedField && isRelatedField(termParts)) { From 11244f85a4eedfaaaec98fd19e68c6fcdcb5ab43 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 8 May 2019 10:05:02 -0400 Subject: [PATCH 5/6] Adds missing semicolon --- awx/ui/client/src/shared/smart-search/queryset.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/shared/smart-search/queryset.service.js b/awx/ui/client/src/shared/smart-search/queryset.service.js index df143f0580..216045eee3 100644 --- a/awx/ui/client/src/shared/smart-search/queryset.service.js +++ b/awx/ui/client/src/shared/smart-search/queryset.service.js @@ -417,7 +417,7 @@ function QuerysetService ($q, Rest, ProcessErrors, $rootScope, Wait, DjangoSearc if (termParts.length === 1) { if (singleSearchParam && termParts[0].toLowerCase() === "or") { - termParams = { [singleSearchParam]: "or" } + termParams = { [singleSearchParam]: "or" }; } else { termParams = searchWithoutKey(term, singleSearchParam); } From e1de0a528df5ef723d5f20a17ad3bdb1a8cb3bd9 Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 8 May 2019 14:59:04 -0400 Subject: [PATCH 6/6] Adds some test coverage for host_filter queries --- .../test/spec/smart-search/queryset.service-test.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/awx/ui/test/spec/smart-search/queryset.service-test.js b/awx/ui/test/spec/smart-search/queryset.service-test.js index eb8563c37d..a2771f9344 100644 --- a/awx/ui/test/spec/smart-search/queryset.service-test.js +++ b/awx/ui/test/spec/smart-search/queryset.service-test.js @@ -63,11 +63,22 @@ describe('Service: QuerySet', () => { spyOn(QuerySet, 'encodeParam').and.callThrough(); const term = 'name:foo'; - const isFilterableBaseField = () => true; + const isFilterableBaseField = (termParts) => termParts[0] === 'name'; const isRelatedField = () => false; expect(QuerySet.getSearchInputQueryset(term, isFilterableBaseField, isRelatedField)).toEqual({ name__icontains_DEFAULT: 'foo' }); expect(QuerySet.encodeParam).toHaveBeenCalledWith({ term: "name:foo", searchTerm: true, singleSearchParam: null }); + expect(QuerySet.getSearchInputQueryset('foo', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'search=foo' }); + expect(QuerySet.getSearchInputQueryset('foo bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'search=foo%20and%20search=bar' }); + expect(QuerySet.getSearchInputQueryset('foo or bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'search=foo%20or%20search=bar' }); + expect(QuerySet.getSearchInputQueryset('name:foo or bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'name__icontains=foo%20or%20search=bar' }); + expect(QuerySet.getSearchInputQueryset('name:foo bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'name__icontains=foo%20and%20search=bar' }); + expect(QuerySet.getSearchInputQueryset('foo or name:bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'search=foo%20or%20name__icontains=bar' }); + expect(QuerySet.getSearchInputQueryset('foo name:bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'search=foo%20and%20name__icontains=bar' }); + expect(QuerySet.getSearchInputQueryset('name:foo or name:bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'name__icontains=foo%20or%20name__icontains=bar' }); + expect(QuerySet.getSearchInputQueryset('name:foo name:bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'name__icontains=foo%20and%20name__icontains=bar' }); + expect(QuerySet.getSearchInputQueryset('name:foo name:bar or baz', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'name__icontains=foo%20and%20name__icontains=bar%20or%20search=baz' }); + expect(QuerySet.getSearchInputQueryset('baz or name:foo name:bar', isFilterableBaseField, null, null, 'host_filter')).toEqual({ host_filter: 'search=baz%20or%20name__icontains=foo%20and%20name__icontains=bar' }); }); });