Skip to content

Commit

Permalink
refactor(redux): merge action types, single file (#1260)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Jan 24, 2024
1 parent e85d4dc commit 5225e01
Show file tree
Hide file tree
Showing 14 changed files with 169 additions and 345 deletions.
118 changes: 45 additions & 73 deletions src/redux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,7 @@
<dt><a href="#Redux State.module_Store">Store</a></dt>
<dd><p>Redux store setup.</p>
</dd>
<dt><a href="#Types.module_AppTypes">AppTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_GraphTypes">GraphTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_InventoryTypes">InventoryTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_MessageTypes">MessageTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_PlatformTypes">PlatformTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_QueryTypes">QueryTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_RhsmTypes">RhsmTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_ToolbarTypes">ToolbarTypes</a></dt>
<dd></dd>
<dt><a href="#Types.module_UserTypes">UserTypes</a></dt>
<dt><a href="#Types.module_ReduxTypes">ReduxTypes</a></dt>
<dd></dd>
</dl>

Expand Down Expand Up @@ -1198,87 +1182,75 @@ Redux store setup.
Create a Redux store.

**Kind**: inner constant of [<code>Store</code>](#Redux State.module_Store)
<a name="Types.module_AppTypes"></a>
<a name="Types.module_ReduxTypes"></a>

## AppTypes
<a name="Types.module_AppTypes..appTypes"></a>
## ReduxTypes

### AppTypes~appTypes : <code>Object</code>
Application action, reducer types.
* [ReduxTypes](#Types.module_ReduxTypes)
* [~appTypes](#Types.module_ReduxTypes..appTypes) : <code>Object</code>
* [~graphTypes](#Types.module_ReduxTypes..graphTypes) : <code>Object</code>
* [~inventoryTypes](#Types.module_ReduxTypes..inventoryTypes) : <code>Object</code>
* [~messageTypes](#Types.module_ReduxTypes..messageTypes) : <code>Object</code>
* [~platformTypes](#Types.module_ReduxTypes..platformTypes) : <code>Object</code>
* [~queryTypes](#Types.module_ReduxTypes..queryTypes) : <code>Object</code>
* [~rhsmTypes](#Types.module_ReduxTypes..rhsmTypes) : <code>Object</code>
* [~toolbarTypes](#Types.module_ReduxTypes..toolbarTypes) : <code>Object</code>
* [~userTypes](#Types.module_ReduxTypes..userTypes) : <code>Object</code>

**Kind**: inner constant of [<code>AppTypes</code>](#Types.module_AppTypes)
<a name="Types.module_GraphTypes"></a>
<a name="Types.module_ReduxTypes..appTypes"></a>

## GraphTypes
<a name="Types.module_GraphTypes..graphTypes"></a>
### ReduxTypes~appTypes : <code>Object</code>
Application action, reducer types.

### GraphTypes~graphTypes : <code>Object</code>
Graph action, reducer types.
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..graphTypes"></a>

**Kind**: inner constant of [<code>GraphTypes</code>](#Types.module_GraphTypes)
<a name="Types.module_InventoryTypes"></a>
### ReduxTypes~graphTypes : <code>Object</code>
Graph action, reducer types.

## InventoryTypes
<a name="Types.module_InventoryTypes..inventoryTypes"></a>
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..inventoryTypes"></a>

### InventoryTypes~inventoryTypes : <code>Object</code>
### ReduxTypes~inventoryTypes : <code>Object</code>
Inventory action, reducer types.

**Kind**: inner constant of [<code>InventoryTypes</code>](#Types.module_InventoryTypes)
<a name="Types.module_MessageTypes"></a>

## MessageTypes
<a name="Types.module_MessageTypes..messageTypes"></a>

### MessageTypes~messageTypes : <code>Object</code>
User action, reducer types.
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..messageTypes"></a>

**Kind**: inner constant of [<code>MessageTypes</code>](#Types.module_MessageTypes)
<a name="Types.module_PlatformTypes"></a>
### ReduxTypes~messageTypes : <code>Object</code>
Banner message action, reducer types.

## PlatformTypes
<a name="Types.module_PlatformTypes..platformTypes"></a>
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..platformTypes"></a>

### PlatformTypes~platformTypes : <code>Object</code>
### ReduxTypes~platformTypes : <code>Object</code>
Platform action, reducer types.

**Kind**: inner constant of [<code>PlatformTypes</code>](#Types.module_PlatformTypes)
<a name="Types.module_QueryTypes"></a>
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..queryTypes"></a>

## QueryTypes
<a name="Types.module_QueryTypes..queryTypes"></a>
### ReduxTypes~queryTypes : <code>Object</code>
Query/filter action, reducer types.

### QueryTypes~queryTypes : <code>Object</code>
Query/filter reducer types.
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..rhsmTypes"></a>

**Kind**: inner constant of [<code>QueryTypes</code>](#Types.module_QueryTypes)
<a name="Types.module_RhsmTypes"></a>

## RhsmTypes
<a name="Types.module_RhsmTypes..rhsmTypes"></a>

### RhsmTypes~rhsmTypes : <code>Object</code>
### ReduxTypes~rhsmTypes : <code>Object</code>
RHSM API action, reducer types.

**Kind**: inner constant of [<code>RhsmTypes</code>](#Types.module_RhsmTypes)
<a name="Types.module_ToolbarTypes"></a>

## ToolbarTypes
<a name="Types.module_ToolbarTypes..toolbarTypes"></a>

### ToolbarTypes~toolbarTypes : <code>Object</code>
Filter, toolbar reducer types.
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..toolbarTypes"></a>

**Kind**: inner constant of [<code>ToolbarTypes</code>](#Types.module_ToolbarTypes)
<a name="Types.module_UserTypes"></a>
### ReduxTypes~toolbarTypes : <code>Object</code>
Filter, toolbar action, reducer types.

## UserTypes
<a name="Types.module_UserTypes..userTypes"></a>
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="Types.module_ReduxTypes..userTypes"></a>

### UserTypes~userTypes : <code>Object</code>
### ReduxTypes~userTypes : <code>Object</code>
User action, reducer types.

**Kind**: inner constant of [<code>UserTypes</code>](#Types.module_UserTypes)
**Kind**: inner constant of [<code>ReduxTypes</code>](#Types.module_ReduxTypes)
<a name="reduxMiddleware"></a>

## reduxMiddleware : <code>Array</code>
Expand Down
3 changes: 1 addition & 2 deletions src/redux/reducers/inventoryReducer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { rhsmTypes } from '../types/rhsmTypes';
import { inventoryTypes, rhsmTypes } from '../types';
import { reduxHelpers } from '../common/reduxHelpers';
import { inventoryTypes } from '../types';

/**
* Inventory, and tabs, related API and user state reducer.
Expand Down
4 changes: 1 addition & 3 deletions src/redux/reducers/userReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ const userReducer = (state = initialState, action) => {
return reduxHelpers.generatedPromiseActionReducer(
[
{ ref: 'locale', type: userTypes.USER_LOCALE },
{ ref: 'optin', type: userTypes.DELETE_USER_OPTIN },
{ ref: 'optin', type: userTypes.GET_USER_OPTIN },
{ ref: 'optin', type: userTypes.UPDATE_USER_OPTIN },
{ ref: 'optin', type: [userTypes.DELETE_USER_OPTIN, userTypes.GET_USER_OPTIN, userTypes.UPDATE_USER_OPTIN] },
{ ref: 'auth', type: platformTypes.PLATFORM_USER_AUTH }
],
state,
Expand Down
4 changes: 0 additions & 4 deletions src/redux/types/__tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ exports[`ReduxTypes should have specific type properties: all redux types 1`] =
"GET_USER_OPTIN": "GET_USER_OPTIN",
"UPDATE_USER_OPTIN": "UPDATE_USER_OPTIN",
"USER_LOCALE": "USER_LOCALE",
"USER_LOGOUT": "USER_LOGOUT",
},
},
"graphTypes": {
Expand Down Expand Up @@ -144,7 +143,6 @@ exports[`ReduxTypes should have specific type properties: all redux types 1`] =
"GET_USER_OPTIN": "GET_USER_OPTIN",
"UPDATE_USER_OPTIN": "UPDATE_USER_OPTIN",
"USER_LOCALE": "USER_LOCALE",
"USER_LOGOUT": "USER_LOGOUT",
},
},
"rhsmTypes": {
Expand All @@ -163,7 +161,6 @@ exports[`ReduxTypes should have specific type properties: all redux types 1`] =
"GET_USER_OPTIN": "GET_USER_OPTIN",
"UPDATE_USER_OPTIN": "UPDATE_USER_OPTIN",
"USER_LOCALE": "USER_LOCALE",
"USER_LOGOUT": "USER_LOGOUT",
},
}
`;
Expand Down Expand Up @@ -221,7 +218,6 @@ exports[`ReduxTypes should have specific type properties: specific types 1`] = `
"GET_USER_OPTIN": "GET_USER_OPTIN",
"UPDATE_USER_OPTIN": "UPDATE_USER_OPTIN",
"USER_LOCALE": "USER_LOCALE",
"USER_LOGOUT": "USER_LOGOUT",
},
}
`;
34 changes: 0 additions & 34 deletions src/redux/types/appTypes.js

This file was deleted.

17 changes: 0 additions & 17 deletions src/redux/types/graphTypes.js

This file was deleted.

131 changes: 122 additions & 9 deletions src/redux/types/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,125 @@
import { appTypes } from './appTypes';
import { graphTypes } from './graphTypes';
import { inventoryTypes } from './inventoryTypes';
import { messageTypes } from './messageTypes';
import { platformTypes } from './platformTypes';
import { queryTypes } from './queryTypes';
import { rhsmTypes } from './rhsmTypes';
import { toolbarTypes } from './toolbarTypes';
import { userTypes } from './userTypes';
import {
ADD_NOTIFICATION,
REMOVE_NOTIFICATION,
CLEAR_NOTIFICATIONS
} from '@redhat-cloud-services/frontend-components-notifications';

/**
* @memberof Types
* @module ReduxTypes
*/

/**
* Application action, reducer types.
*
* @type {{STATUS_4XX: string, SET_PRODUCT_VARIANT: string, SET_PRODUCT_VARIANT_QUERY_RESET_ALL: string,
* SET_PRODUCT: string, STATUS_5XX: string}}
*/
const appTypes = {
STATUS_4XX: '4XX',
STATUS_5XX: '5XX',
SET_PRODUCT: 'SET_PRODUCT',
SET_PRODUCT_VARIANT: 'SET_PRODUCT_VARIANT',
SET_PRODUCT_VARIANT_QUERY_RESET_ALL: 'SET_PRODUCT_VARIANT_QUERY_RESET_ALL'
};

/**
* Graph action, reducer types.
*
* @type {{SET_GRAPH_LEGEND: string}}
*/
const graphTypes = {
SET_GRAPH_LEGEND: 'SET_GRAPH_LEGEND'
};

/**
* Inventory action, reducer types.
*
* @type {{CLEAR_INVENTORY_GUESTS: string, SET_INVENTORY_TAB: string}}
*/
const inventoryTypes = {
CLEAR_INVENTORY_GUESTS: 'CLEAR_INVENTORY_GUESTS',
SET_INVENTORY_TAB: 'SET_INVENTORY_TAB'
};

/**
* Banner message action, reducer types.
*
* @type {{SET_BANNER_MESSAGES: string}}
*/
const messageTypes = {
SET_BANNER_MESSAGES: 'SET_BANNER_MESSAGES'
};

/**
* Platform action, reducer types.
*
* @type {{PLATFORM_USER_AUTH: string, PLATFORM_GLOBAL_FILTER_HIDE: string, PLATFORM_CLEAR_NOTIFICATIONS:
* string, PLATFORM_ADD_NOTIFICATION: string, PLATFORM_REMOVE_NOTIFICATION: string}}
*/
const platformTypes = {
PLATFORM_ADD_NOTIFICATION: ADD_NOTIFICATION,
PLATFORM_REMOVE_NOTIFICATION: REMOVE_NOTIFICATION,
PLATFORM_CLEAR_NOTIFICATIONS: CLEAR_NOTIFICATIONS,
PLATFORM_GLOBAL_FILTER_HIDE: 'PLATFORM_GLOBAL_FILTER_HIDE',
PLATFORM_USER_AUTH: 'PLATFORM_USER_AUTH'
};

/**
* Query/filter action, reducer types.
*
* @type {{SET_QUERY_INVENTORY_GUESTS: string, SET_QUERY_INVENTORY_INSTANCES: string, SET_QUERY_GRAPH: string,
* SET_QUERY_CLEAR: string, SET_QUERY_CLEAR_INVENTORY_LIST: string, SET_QUERY_INVENTORY_SUBSCRIPTIONS:
* string, SET_QUERY: string, SET_QUERY_RESET_INVENTORY_LIST: string, SET_QUERY_CLEAR_INVENTORY_GUESTS_LIST:
* string}}
*/
const queryTypes = {
SET_QUERY: 'SET_QUERY',
SET_QUERY_GRAPH: 'SET_QUERY_GRAPH',
SET_QUERY_INVENTORY_GUESTS: 'SET_QUERY_INVENTORY_GUESTS',
SET_QUERY_INVENTORY_INSTANCES: 'SET_QUERY_INVENTORY_INSTANCES',
SET_QUERY_INVENTORY_SUBSCRIPTIONS: 'SET_QUERY_INVENTORY_SUBSCRIPTIONS',
SET_QUERY_CLEAR: 'SET_QUERY_CLEAR',
SET_QUERY_CLEAR_INVENTORY_LIST: 'SET_QUERY_CLEAR_INVENTORY_LIST',
SET_QUERY_CLEAR_INVENTORY_GUESTS_LIST: 'SET_QUERY_CLEAR_INVENTORY_GUESTS_LIST',
SET_QUERY_RESET_INVENTORY_LIST: 'SET_QUERY_RESET_INVENTORY_LIST'
};

/**
* RHSM API action, reducer types.
*
* @type {{GET_GRAPH_CAPACITY_RHSM: string, GET_INSTANCES_INVENTORY_GUESTS_RHSM: string,
* GET_SUBSCRIPTIONS_INVENTORY_RHSM: string, GET_INSTANCES_INVENTORY_RHSM: string, GET_GRAPH_TALLY_RHSM: string}}
*/
const rhsmTypes = {
GET_GRAPH_CAPACITY_RHSM: 'GET_GRAPH_CAPACITY_RHSM',
GET_GRAPH_TALLY_RHSM: 'GET_GRAPH_TALLY_RHSM',
GET_INSTANCES_INVENTORY_RHSM: 'GET_INSTANCES_INVENTORY_RHSM',
GET_INSTANCES_INVENTORY_GUESTS_RHSM: 'GET_INSTANCES_INVENTORY_GUESTS_RHSM',
GET_SUBSCRIPTIONS_INVENTORY_RHSM: 'GET_SUBSCRIPTIONS_INVENTORY_RHSM'
};

/**
* Filter, toolbar action, reducer types.
*
* @type {{SET_FILTER_TYPE: string, SET_ACTIVE_FILTERS: string}}
*/
const toolbarTypes = {
SET_ACTIVE_FILTERS: 'SET_ACTIVE_FILTERS',
SET_FILTER_TYPE: 'SET_FILTER_TYPE'
};

/**
* User action, reducer types.
*
* @type {{USER_LOCALE: string, GET_USER_OPTIN: string, UPDATE_USER_OPTIN: string, DELETE_USER_OPTIN: string}}
*/
const userTypes = {
DELETE_USER_OPTIN: 'DELETE_USER_OPTIN',
GET_USER_OPTIN: 'GET_USER_OPTIN',
UPDATE_USER_OPTIN: 'UPDATE_USER_OPTIN',
USER_LOCALE: 'USER_LOCALE'
};

const reduxTypes = {
app: appTypes,
Expand Down
Loading

0 comments on commit 5225e01

Please sign in to comment.