diff --git a/awx/ui_next/SEARCH.md b/awx/ui_next/SEARCH.md
index 0035213446..0e223b0fe8 100644
--- a/awx/ui_next/SEARCH.md
+++ b/awx/ui_next/SEARCH.md
@@ -108,8 +108,6 @@ Similar to the way the list grabs data based on changes to the react-router para
Currently the filter tags do not display the key, though that data is available and they could very easily do so.
-Some small changes were made to our custom ChipGroup component to make this possible--a new displayAll bool prop which bypasses all chip hiding based on number of chips.
-
## QS Updates (and supporting duplicate keys)
The logic that was updated to handle search tags can be found in the qs.js util file.
diff --git a/awx/ui_next/src/api/mixins/Notifications.mixin.js b/awx/ui_next/src/api/mixins/Notifications.mixin.js
index e40b7983a3..9625c29e04 100644
--- a/awx/ui_next/src/api/mixins/Notifications.mixin.js
+++ b/awx/ui_next/src/api/mixins/Notifications.mixin.js
@@ -14,14 +14,14 @@ const NotificationsMixin = parent =>
readNotificationTemplatesSuccess(id, params) {
return this.http.get(
`${this.baseUrl}${id}/notification_templates_success/`,
- params
+ { params }
);
}
readNotificationTemplatesError(id, params) {
return this.http.get(
`${this.baseUrl}${id}/notification_templates_error/`,
- params
+ { params }
);
}
@@ -54,43 +54,58 @@ const NotificationsMixin = parent =>
}
/**
- * This is a helper method meant to simplify setting the "on" or "off" status of
+ * This is a helper method meant to simplify setting the "on" status of
* a related notification.
*
* @param[resourceId] - id of the base resource
* @param[notificationId] - id of the notification
* @param[notificationType] - the type of notification, options are "success" and "error"
- * @param[associationState] - Boolean for associating or disassociating, options are true or false
*/
- // eslint-disable-next-line max-len
- updateNotificationTemplateAssociation(
+ associateNotificationTemplate(
resourceId,
notificationId,
- notificationType,
- associationState
+ notificationType
) {
- if (notificationType === 'success' && associationState === true) {
+ if (notificationType === 'success') {
return this.associateNotificationTemplatesSuccess(
resourceId,
notificationId
);
}
- if (notificationType === 'success' && associationState === false) {
- return this.disassociateNotificationTemplatesSuccess(
- resourceId,
- notificationId
- );
- }
-
- if (notificationType === 'error' && associationState === true) {
+ if (notificationType === 'error') {
return this.associateNotificationTemplatesError(
resourceId,
notificationId
);
}
- if (notificationType === 'error' && associationState === false) {
+ throw new Error(
+ `Unsupported notificationType for association: ${notificationType}`
+ );
+ }
+
+ /**
+ * This is a helper method meant to simplify setting the "off" status of
+ * a related notification.
+ *
+ * @param[resourceId] - id of the base resource
+ * @param[notificationId] - id of the notification
+ * @param[notificationType] - the type of notification, options are "success" and "error"
+ */
+ disassociateNotificationTemplate(
+ resourceId,
+ notificationId,
+ notificationType
+ ) {
+ if (notificationType === 'success') {
+ return this.disassociateNotificationTemplatesSuccess(
+ resourceId,
+ notificationId
+ );
+ }
+
+ if (notificationType === 'error') {
return this.disassociateNotificationTemplatesError(
resourceId,
notificationId
@@ -98,7 +113,7 @@ const NotificationsMixin = parent =>
}
throw new Error(
- `Unsupported notificationType, associationState combination: ${notificationType}, ${associationState}`
+ `Unsupported notificationType for disassociation: ${notificationType}`
);
}
};
diff --git a/awx/ui_next/src/components/Chip/ChipGroup.jsx b/awx/ui_next/src/components/Chip/ChipGroup.jsx
index 8d6d6f0593..58ba8ac7e5 100644
--- a/awx/ui_next/src/components/Chip/ChipGroup.jsx
+++ b/awx/ui_next/src/components/Chip/ChipGroup.jsx
@@ -1,15 +1,9 @@
import React, { useState } from 'react';
-import { number, bool } from 'prop-types';
+import { number } from 'prop-types';
import styled from 'styled-components';
import Chip from './Chip';
-const ChipGroup = ({
- children,
- className,
- showOverflowAfter,
- displayAll,
- ...props
-}) => {
+const ChipGroup = ({ children, className, showOverflowAfter, ...props }) => {
const [isExpanded, setIsExpanded] = useState(!showOverflowAfter);
const toggleIsOpen = () => setIsExpanded(!isExpanded);
@@ -26,8 +20,8 @@ const ChipGroup = ({
return (
- {displayAll ? mappedChildren : mappedChildren.slice(0, numToShow)}
- {!displayAll && showOverflowToggle && (
+ {!showOverflowAfter ? mappedChildren : mappedChildren.slice(0, numToShow)}
+ {showOverflowAfter && showOverflowToggle && (
{isExpanded ? expandedText : collapsedText}
@@ -37,11 +31,9 @@ const ChipGroup = ({
};
ChipGroup.propTypes = {
showOverflowAfter: number,
- displayAll: bool,
};
ChipGroup.defaultProps = {
showOverflowAfter: null,
- displayAll: false,
};
export default styled(ChipGroup)`
diff --git a/awx/ui_next/src/components/FilterTags/FilterTags.jsx b/awx/ui_next/src/components/FilterTags/FilterTags.jsx
index ac66d97969..c9bc1cb4a7 100644
--- a/awx/ui_next/src/components/FilterTags/FilterTags.jsx
+++ b/awx/ui_next/src/components/FilterTags/FilterTags.jsx
@@ -40,7 +40,6 @@ const FilterTags = ({
}) => {
const queryParams = parseQueryString(qsConfig, location.search);
const queryParamsArr = [];
- const displayAll = true;
const nonDefaultParams = filterDefaultParams(
Object.keys(queryParams),
qsConfig
@@ -59,7 +58,7 @@ const FilterTags = ({
{`${itemCount} results`}
{i18n._(t`Active Filters:`)}
-
+
{queryParamsArr.map(({ key, value }) => (
initially renders succesfully 1`] = `
>
', () => {
.find('Switch')
.at(0)
.prop('onChange')();
- expect(
- OrganizationsAPI.updateNotificationTemplateAssociation
- ).toHaveBeenCalledWith(1, 2, 'success', true);
+ expect(OrganizationsAPI.associateNotificationTemplate).toHaveBeenCalledWith(
+ 1,
+ 2,
+ 'success'
+ );
await sleep(0);
wrapper.update();
expect(
@@ -122,9 +124,11 @@ describe('', () => {
.find('Switch')
.at(1)
.prop('onChange')();
- expect(
- OrganizationsAPI.updateNotificationTemplateAssociation
- ).toHaveBeenCalledWith(1, 1, 'error', true);
+ expect(OrganizationsAPI.associateNotificationTemplate).toHaveBeenCalledWith(
+ 1,
+ 1,
+ 'error'
+ );
await sleep(0);
wrapper.update();
expect(
@@ -149,8 +153,8 @@ describe('', () => {
.at(0)
.prop('onChange')();
expect(
- OrganizationsAPI.updateNotificationTemplateAssociation
- ).toHaveBeenCalledWith(1, 1, 'success', false);
+ OrganizationsAPI.disassociateNotificationTemplate
+ ).toHaveBeenCalledWith(1, 1, 'success');
await sleep(0);
wrapper.update();
expect(
@@ -175,8 +179,8 @@ describe('', () => {
.at(1)
.prop('onChange')();
expect(
- OrganizationsAPI.updateNotificationTemplateAssociation
- ).toHaveBeenCalledWith(1, 2, 'error', false);
+ OrganizationsAPI.disassociateNotificationTemplate
+ ).toHaveBeenCalledWith(1, 2, 'error');
await sleep(0);
wrapper.update();
expect(
diff --git a/awx/ui_next/src/util/qs.js b/awx/ui_next/src/util/qs.js
index 05e8e4b695..b14f1bc27e 100644
--- a/awx/ui_next/src/util/qs.js
+++ b/awx/ui_next/src/util/qs.js
@@ -320,10 +320,7 @@ const getRemainingNewParams = (mergedParams, newParams) =>
* @return {object} query param object
*/
export function addParams(config, oldParams, paramsToAdd) {
- const namespacedOldParams = namespaceParams(
- config.namespace,
- oldParams
- );
+ const namespacedOldParams = namespaceParams(config.namespace, oldParams);
const namespacedParamsToAdd = namespaceParams(config.namespace, paramsToAdd);
const namespacedDefaultParams = namespaceParams(
config.namespace,
diff --git a/awx/ui_next/src/util/qs.test.js b/awx/ui_next/src/util/qs.test.js
index 636b97ce84..9a9bb76515 100644
--- a/awx/ui_next/src/util/qs.test.js
+++ b/awx/ui_next/src/util/qs.test.js
@@ -403,7 +403,11 @@ describe('qs (qs.js)', () => {
defaultParams: { page: 1, page_size: 15 },
integerFields: ['page', 'page_size'],
};
- const oldParams = { baz: ['bar', 'bang', 'bust'], page: 3, page_size: 15 };
+ const oldParams = {
+ baz: ['bar', 'bang', 'bust'],
+ page: 3,
+ page_size: 15,
+ };
const newParams = { baz: 'bar' };
expect(removeParams(config, oldParams, newParams)).toEqual({
baz: ['bang', 'bust'],
@@ -433,7 +437,12 @@ describe('qs (qs.js)', () => {
defaultParams: { page: 1, page_size: 15 },
integerFields: ['page', 'page_size'],
};
- const oldParams = { baz: ['bar', 'bang', 'bust'], pat: 'pal', page: 3, page_size: 15 };
+ const oldParams = {
+ baz: ['bar', 'bang', 'bust'],
+ pat: 'pal',
+ page: 3,
+ page_size: 15,
+ };
const newParams = { baz: 'bust', pat: 'pal' };
expect(removeParams(config, oldParams, newParams)).toEqual({
baz: ['bar', 'bang'],
@@ -491,7 +500,11 @@ describe('qs (qs.js)', () => {
defaultParams: { page: 1, page_size: 15 },
integerFields: ['page', 'page_size'],
};
- const oldParams = { baz: ['bar', 'bang', 'bust'], page: 3, page_size: 15 };
+ const oldParams = {
+ baz: ['bar', 'bang', 'bust'],
+ page: 3,
+ page_size: 15,
+ };
const newParams = { baz: 'bar' };
expect(removeParams(config, oldParams, newParams)).toEqual({
baz: ['bang', 'bust'],
@@ -521,7 +534,12 @@ describe('qs (qs.js)', () => {
defaultParams: { page: 1, page_size: 15 },
integerFields: ['page', 'page_size'],
};
- const oldParams = { baz: ['bar', 'bang', 'bust'], pat: 'pal', page: 3, page_size: 15 };
+ const oldParams = {
+ baz: ['bar', 'bang', 'bust'],
+ pat: 'pal',
+ page: 3,
+ page_size: 15,
+ };
const newParams = { baz: 'bust', pat: 'pal' };
expect(removeParams(config, oldParams, newParams)).toEqual({
baz: ['bar', 'bang'],
diff --git a/awx/ui_next/testUtils/apiReusable.jsx b/awx/ui_next/testUtils/apiReusable.jsx
index 11f9fca7c7..aa66015afd 100644
--- a/awx/ui_next/testUtils/apiReusable.jsx
+++ b/awx/ui_next/testUtils/apiReusable.jsx
@@ -8,23 +8,36 @@ export function describeNotificationMixin (Model, name) {
jest.clearAllMocks();
});
- const parameters = [
- ['success', true],
- ['success', false],
- ['error', true],
- ['error', false],
- ];
- parameters.forEach(([type, state]) => {
- const label = `[notificationType=${type}, associationState=${state}]`;
- const testName = `updateNotificationTemplateAssociation ${label} makes expected http calls`;
+ const parameters = ['success', 'error'];
+
+ parameters.forEach((type) => {
+ const label = `[notificationType=${type}, associationState=true`;
+ const testName = `associateNotificationTemplate ${label} makes expected http calls`;
test(testName, async (done) => {
- await ModelAPI.updateNotificationTemplateAssociation(1, 21, type, state);
+ await ModelAPI.associateNotificationTemplate(1, 21, type);
const expectedPath = `${ModelAPI.baseUrl}1/notification_templates_${type}/`;
expect(mockHttp.post).toHaveBeenCalledTimes(1);
- const expectedParams = state ? { id: 21 } : { id: 21, disassociate: true };
+ const expectedParams = { id: 21 };
+ expect(mockHttp.post.mock.calls.pop()).toEqual([expectedPath, expectedParams]);
+
+ done();
+ });
+ });
+
+ parameters.forEach((type) => {
+ const label = `[notificationType=${type}, associationState=false`;
+ const testName = `disassociateNotificationTemplate ${label} makes expected http calls`;
+
+ test(testName, async (done) => {
+ await ModelAPI.disassociateNotificationTemplate(1, 21, type);
+
+ const expectedPath = `${ModelAPI.baseUrl}1/notification_templates_${type}/`;
+ expect(mockHttp.post).toHaveBeenCalledTimes(1);
+
+ const expectedParams = { id: 21, disassociate: true };
expect(mockHttp.post.mock.calls.pop()).toEqual([expectedPath, expectedParams]);
done();