Skip to content

Commit

Permalink
feat(rhelServices,rhelApiTypes): issues/77 allow passed id
Browse files Browse the repository at this point in the history
* rhelServices, allow product id to be passed
* rhelApiTypes, key/value reference for product ids
* rhelActions, open for product id
  • Loading branch information
cdcabrera committed Nov 15, 2019
1 parent e1c7799 commit 035e9e6
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ REACT_APP_INCLUDE_CONTENT_HEADER=<esi:include src="${UI_DEPLOY_PATH_PREFIX}/apps
REACT_APP_INCLUDE_CONTENT_BODY=<esi:include src="${UI_DEPLOY_PATH_PREFIX}/apps/chrome/snippets/body.html" />

REACT_APP_SERVICES_RHSM_VERSION=/api/rhsm-subscriptions/v1/version
REACT_APP_SERVICES_RHSM_REPORT_RHEL=/api/rhsm-subscriptions/v1/tally/products/RHEL
REACT_APP_SERVICES_RHSM_CAPACITY_RHEL=/api/rhsm-subscriptions/v1/capacity/products/RHEL
REACT_APP_SERVICES_RHSM_REPORT=/api/rhsm-subscriptions/v1/tally/products/
REACT_APP_SERVICES_RHSM_CAPACITY=/api/rhsm-subscriptions/v1/capacity/products/
4 changes: 2 additions & 2 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ REACT_APP_CONFIG_SERVICE_LOCALES=./locales/locales.json
REACT_APP_CONFIG_SERVICE_LOCALES_PATH=./locales/{{lng}}.json

REACT_APP_SERVICES_RHSM_VERSION=http://localhost:5000/api/rhsm-subscriptions/v1/version
REACT_APP_SERVICES_RHSM_REPORT_RHEL=http://localhost:5000/api/rhsm-subscriptions/v1/tally/products/RHEL
REACT_APP_SERVICES_RHSM_CAPACITY_RHEL=http://localhost:5000/api/rhsm-subscriptions/v1/capacity/products/RHEL
REACT_APP_SERVICES_RHSM_REPORT=http://localhost:5000/api/rhsm-subscriptions/v1/tally/products/
REACT_APP_SERVICES_RHSM_CAPACITY=http://localhost:5000/api/rhsm-subscriptions/v1/capacity/products/
4 changes: 2 additions & 2 deletions .env.proxy
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ REACT_APP_CONFIG_SERVICE_LOCALES=/locales/locales.json
REACT_APP_CONFIG_SERVICE_LOCALES_PATH=/locales/{{lng}}.json

REACT_APP_SERVICES_RHSM_VERSION=/api/rhsm-subscriptions/v1/version
REACT_APP_SERVICES_RHSM_REPORT_RHEL=/api/rhsm-subscriptions/v1/tally/products/RHEL
REACT_APP_SERVICES_RHSM_CAPACITY_RHEL=/api/rhsm-subscriptions/v1/capacity/products/RHEL
REACT_APP_SERVICES_RHSM_REPORT=/api/rhsm-subscriptions/v1/tally/products/
REACT_APP_SERVICES_RHSM_CAPACITY=/api/rhsm-subscriptions/v1/capacity/products/
12 changes: 6 additions & 6 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ exports[`I18n Component should generate a predictable pot output snapshot: pot o
msgstr \\"\\"
\\"Content-Type: text/plain; charset=UTF-8\\\\n\\"
#: src/components/rhelGraphCard/rhelGraphCard.js:107
#: src/components/rhelGraphCard/rhelGraphCard.js:109
msgid \\"curiosity-graph.rhelLegendHypervisorLabel\\"
msgstr \\"\\"
#: src/components/rhelGraphCard/rhelGraphCard.js:95
#: src/components/rhelGraphCard/rhelGraphCard.js:97
msgid \\"curiosity-graph.rhelLegendSocketsLabel\\"
msgstr \\"\\"
#: src/components/rhelGraphCard/rhelGraphCard.js:118
#: src/components/rhelGraphCard/rhelGraphCard.js:120
msgid \\"curiosity-graph.rhelLegendThresholdLabel\\"
msgstr \\"\\"
Expand All @@ -44,7 +44,7 @@ msgstr \\"\\"
msgid \\"curiosity-graph.tooltipNoData\\"
msgstr \\"\\"
#: src/components/rhelGraphCard/rhelGraphCard.js:134
#: src/components/rhelGraphCard/rhelGraphCard.js:136
msgctxt \\"CPU socket usage\\"
msgid \\"curiosity-graph.heading\\"
msgstr \\"\\"
Expand All @@ -64,8 +64,8 @@ msgctxt \\"Quarterly\\"
msgid \\"curiosity-graph.dropdownQuarterly\\"
msgstr \\"\\"
#: src/components/rhelGraphCard/rhelGraphCard.js:137
#: src/components/rhelGraphCard/rhelGraphCard.js:141
#: src/components/rhelGraphCard/rhelGraphCard.js:139
#: src/components/rhelGraphCard/rhelGraphCard.js:143
msgctxt \\"Select date range\\"
msgid \\"curiosity-graph.dropdownPlaceholder\\"
msgstr \\"\\"
Expand Down
16 changes: 10 additions & 6 deletions src/components/rhelGraphCard/rhelGraphCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ class RhelGraphCard extends React.Component {
}

onUpdateGraphData = () => {
const { getGraphCapacityRhel, getGraphReportsRhel, graphGranularity, startDate, endDate } = this.props;
const submit = {
const { getGraphCapacityRhel, getGraphReportsRhel, graphGranularity, startDate, endDate, productId } = this.props;
const query = {
[rhelApiTypes.RHSM_API_QUERY_GRANULARITY]: graphGranularity,
[rhelApiTypes.RHSM_API_QUERY_START_DATE]: startDate.toISOString(),
[rhelApiTypes.RHSM_API_QUERY_END_DATE]: endDate.toISOString()
};

getGraphCapacityRhel(submit);
getGraphReportsRhel(submit);
if (productId) {
getGraphCapacityRhel(productId, query);
getGraphReportsRhel(productId, query);
}
};

onSelect = event => {
Expand Down Expand Up @@ -193,6 +195,7 @@ RhelGraphCard.propTypes = {
GRANULARITY_TYPES.QUARTERLY
]),
pending: PropTypes.bool,
productId: PropTypes.string,
t: PropTypes.func,
startDate: PropTypes.instanceOf(Date),
endDate: PropTypes.instanceOf(Date)
Expand All @@ -208,6 +211,7 @@ RhelGraphCard.defaultProps = {
},
graphGranularity: GRANULARITY_TYPES.DAILY,
pending: false,
productId: rhelApiTypes.RHSM_API_PATH_RHEL_ID_TYPES.RHEL,
t: helpers.noopTranslate,
startDate: dateHelpers.defaultDateTime.startDate,
endDate: dateHelpers.defaultDateTime.endDate
Expand All @@ -222,8 +226,8 @@ const makeMapStateToProps = () => {
};

const mapDispatchToProps = dispatch => ({
getGraphCapacityRhel: query => dispatch(reduxActions.rhel.getGraphCapacityRhel(query)),
getGraphReportsRhel: query => dispatch(reduxActions.rhel.getGraphReportsRhel(query))
getGraphCapacityRhel: (id, query) => dispatch(reduxActions.rhel.getGraphCapacityRhel(id, query)),
getGraphReportsRhel: (id, query) => dispatch(reduxActions.rhel.getGraphReportsRhel(id, query))
});

const ConnectedRhelGraphCard = connectTranslate(makeMapStateToProps, mapDispatchToProps)(RhelGraphCard);
Expand Down
10 changes: 6 additions & 4 deletions src/redux/actions/rhelActions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { rhelTypes } from '../types';
import rhelServices from '../../services/rhelServices';

const getGraphReportsRhel = (query = {}) => dispatch =>
const getGraphReportsRhel = (id = null, query = {}) => dispatch =>
dispatch({
type: rhelTypes.GET_GRAPH_REPORT_RHEL,
payload: rhelServices.getGraphReportsRhel(query),
payload: rhelServices.getGraphReportsRhel(id, query),
meta: {
productId: id,
query,
notifications: {
rejected: {
Expand All @@ -17,11 +18,12 @@ const getGraphReportsRhel = (query = {}) => dispatch =>
}
});

const getGraphCapacityRhel = (query = {}) => dispatch =>
const getGraphCapacityRhel = (id = null, query = {}) => dispatch =>
dispatch({
type: rhelTypes.GET_GRAPH_CAPACITY_RHEL,
payload: rhelServices.getGraphCapacityRhel(query),
payload: rhelServices.getGraphCapacityRhel(id, query),
meta: {
productId: id,
query,
notifications: {
rejected: {
Expand Down
8 changes: 4 additions & 4 deletions src/services/rhelServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,10 @@ import serviceConfig from './config';
* ]
* }
*/
const getGraphReportsRhel = (params = {}) =>
const getGraphReportsRhel = (id, params = {}) =>
axios(
serviceConfig({
url: process.env.REACT_APP_SERVICES_RHSM_REPORT_RHEL,
url: `${process.env.REACT_APP_SERVICES_RHSM_REPORT}${id}`,
params
})
);
Expand Down Expand Up @@ -541,10 +541,10 @@ const getGraphReportsRhel = (params = {}) =>
* ]
* }
*/
const getGraphCapacityRhel = (params = {}) =>
const getGraphCapacityRhel = (id, params = {}) =>
axios(
serviceConfig({
url: process.env.REACT_APP_SERVICES_RHSM_CAPACITY_RHEL,
url: `${process.env.REACT_APP_SERVICES_RHSM_CAPACITY}${id}`,
params
})
);
Expand Down
44 changes: 44 additions & 0 deletions src/types/__tests__/__snapshots__/rhelApiTypes.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

exports[`RhelApiTypes Should have specific API properties: all exported api types 1`] = `
Object {
"RHSM_API_PATH_RHEL_ID_TYPES": Object {
"ARM": "RHEL for ARM",
"COMPUTE_NODE": "RHEL Compute Node",
"DESKTOP": "RHEL Desktop",
"IBM_POWER": "RHEL for IBM Power",
"IBM_Z": "RHEL for IBM z",
"RHEL": "RHEL",
"SERVER": "RHEL Server",
"WORKSTATION": "RHEL Workstation",
"X86": "RHEL for x86",
},
"RHSM_API_QUERY_END_DATE": "ending",
"RHSM_API_QUERY_GRANULARITY": "granularity",
"RHSM_API_QUERY_GRANULARITY_TYPES": Object {
Expand Down Expand Up @@ -38,6 +49,17 @@ Object {
"COUNT": "count",
},
"default": Object {
"RHSM_API_PATH_RHEL_ID_TYPES": Object {
"ARM": "RHEL for ARM",
"COMPUTE_NODE": "RHEL Compute Node",
"DESKTOP": "RHEL Desktop",
"IBM_POWER": "RHEL for IBM Power",
"IBM_Z": "RHEL for IBM z",
"RHEL": "RHEL",
"SERVER": "RHEL Server",
"WORKSTATION": "RHEL Workstation",
"X86": "RHEL for x86",
},
"RHSM_API_QUERY_END_DATE": "ending",
"RHSM_API_QUERY_GRANULARITY": "granularity",
"RHSM_API_QUERY_GRANULARITY_TYPES": Object {
Expand Down Expand Up @@ -75,6 +97,17 @@ Object {
},
},
"rhelApiTypes": Object {
"RHSM_API_PATH_RHEL_ID_TYPES": Object {
"ARM": "RHEL for ARM",
"COMPUTE_NODE": "RHEL Compute Node",
"DESKTOP": "RHEL Desktop",
"IBM_POWER": "RHEL for IBM Power",
"IBM_Z": "RHEL for IBM z",
"RHEL": "RHEL",
"SERVER": "RHEL Server",
"WORKSTATION": "RHEL Workstation",
"X86": "RHEL for x86",
},
"RHSM_API_QUERY_END_DATE": "ending",
"RHSM_API_QUERY_GRANULARITY": "granularity",
"RHSM_API_QUERY_GRANULARITY_TYPES": Object {
Expand Down Expand Up @@ -116,6 +149,17 @@ Object {

exports[`RhelApiTypes Should have specific API properties: specific types 1`] = `
Object {
"RHSM_API_PATH_RHEL_ID_TYPES": Object {
"ARM": "RHEL for ARM",
"COMPUTE_NODE": "RHEL Compute Node",
"DESKTOP": "RHEL Desktop",
"IBM_POWER": "RHEL for IBM Power",
"IBM_Z": "RHEL for IBM z",
"RHEL": "RHEL",
"SERVER": "RHEL Server",
"WORKSTATION": "RHEL Workstation",
"X86": "RHEL for x86",
},
"RHSM_API_QUERY_END_DATE": "ending",
"RHSM_API_QUERY_GRANULARITY": "granularity",
"RHSM_API_QUERY_GRANULARITY_TYPES": Object {
Expand Down
14 changes: 14 additions & 0 deletions src/types/rhelApiTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const RHSM_API_RESPONSE_PRODUCTS_META_TYPES = {
COUNT: 'count'
};

const RHSM_API_PATH_RHEL_ID_TYPES = {
RHEL: 'RHEL',
COMPUTE_NODE: 'RHEL Compute Node',
DESKTOP: 'RHEL Desktop',
SERVER: 'RHEL Server',
WORKSTATION: 'RHEL Workstation',
ARM: 'RHEL for ARM',
IBM_POWER: 'RHEL for IBM Power',
IBM_Z: 'RHEL for IBM z',
X86: 'RHEL for x86'
};

const RHSM_API_QUERY_GRANULARITY = 'granularity';
const RHSM_API_QUERY_GRANULARITY_TYPES = {
DAILY: 'daily',
Expand All @@ -45,6 +57,7 @@ const rhelApiTypes = {
RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES,
RHSM_API_RESPONSE_PRODUCTS_META,
RHSM_API_RESPONSE_PRODUCTS_META_TYPES,
RHSM_API_PATH_RHEL_ID_TYPES,
RHSM_API_QUERY_GRANULARITY,
RHSM_API_QUERY_GRANULARITY_TYPES,
RHSM_API_QUERY_LIMIT,
Expand All @@ -64,6 +77,7 @@ export {
RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES,
RHSM_API_RESPONSE_PRODUCTS_META,
RHSM_API_RESPONSE_PRODUCTS_META_TYPES,
RHSM_API_PATH_RHEL_ID_TYPES,
RHSM_API_QUERY_GRANULARITY,
RHSM_API_QUERY_GRANULARITY_TYPES,
RHSM_API_QUERY_LIMIT,
Expand Down

0 comments on commit 035e9e6

Please sign in to comment.