Skip to content

Commit

Permalink
fix(rhosak): ent-5022 subscription type column activated
Browse files Browse the repository at this point in the history
* locale, subscription type strings
* config, rhosak, replace total capacity with subs type
* rhsmServices, schemas, constants, subs types and mock
  • Loading branch information
cdcabrera committed May 26, 2022
1 parent 66f5d0d commit badcf33
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 29 deletions.
4 changes: 4 additions & 0 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
"label_hasInfiniteQuantity_sockets": "Unlimited sockets",
"label_numberOfGuests_one": "<0>{{count}} guest</0>",
"label_numberOfGuests_other": "<0>{{count}} guests</0>",
"label_subscriptionType": "{{context}}",
"label_subscriptionType_Annual": "Annual",
"label_subscriptionType_On-demand": "On-Demand",
"cloudProvider": "{{context}}",
"cloudProvider_alibaba": "Alibaba",
"cloudProvider_aws": "AWS",
Expand Down Expand Up @@ -150,6 +153,7 @@
"header_subscriptions": "Sockets",
"header_subscriptions_cores": "Cores",
"header_subscriptions_sockets": "Sockets",
"header_subscriptionType": "Subscription type",
"header_Transfer-gibibytes": "Data transfer",
"header_tooltip_Storage-gibibytes": "Measurements in binary gigabyte months",
"header_tooltip_Transfer-gibibytes": "Measurements in binary gigabytes",
Expand Down
27 changes: 8 additions & 19 deletions src/config/product.rhosak.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import {
RHSM_API_PATH_METRIC_TYPES
} from '../services/rhsm/rhsmConstants';
import { dateHelpers, helpers } from '../common';
import { Tooltip } from '../components/tooltip/tooltip';
import { ChartIcon } from '../components/chart/chartIcon';
import { translate } from '../components/i18n/i18n';
import { translate, EMPTY_CONTEXT } from '../components/i18n/i18n';

/**
* ToDo: evaluate separating products/product tags into individual configs...
Expand Down Expand Up @@ -223,22 +221,13 @@ const config = {
isWrappable: true
},
{
id: 'totalCapacity',
header: data => translate('curiosity-inventory.header', { context: ['subscriptions', data?.uom?.value] }),
cell: (data = {}) => {
const { hasInfiniteQuantity, totalCapacity, uom } = data;
if (hasInfiniteQuantity?.value === true) {
const content = translate('curiosity-inventory.label', { context: ['hasInfiniteQuantity', uom?.value] });
return (
<Tooltip content={content}>
<ChartIcon symbol="infinity" aria-label={content} />
</Tooltip>
);
}
return totalCapacity?.value;
},
isSortable: true,
cellWidth: 10,
id: 'subscriptionType',
cell: (data, session, meta) =>
translate('curiosity-inventory.label_subscriptionType', {
context: meta?.subscriptionType || EMPTY_CONTEXT
}),
isSortable: false,
cellWidth: 15,
isWrappable: true
},
{
Expand Down
27 changes: 20 additions & 7 deletions src/services/rhsm/rhsmConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ const RHSM_API_RESPONSE_SLA_TYPES = {
NONE: ''
};

/**
* RHSM response, general parameters for subscription types
*
* @type {{ANNUAL: string, ON_DEMAND: string}}
*/
const RHSM_API_RESPONSE_SUBSCRIPTION_TYPES = {
ANNUAL: 'Annual',
ON_DEMAND: 'On-demand'
};

/**
* RHSM response, query parameters for UOM.
*
Expand Down Expand Up @@ -336,13 +346,14 @@ const RHSM_API_QUERY_SET_TYPES = {
* RHSM_API_RESPONSE_META_TYPES: {PRODUCT: string, COUNT: string}, RHSM_API_RESPONSE_ERRORS_CODE_TYPES: {GENERIC: string,
* OPTIN: string}, RHSM_API_QUERY_GRANULARITY_TYPES: {WEEKLY: string, QUARTERLY: string, DAILY: string, MONTHLY: string},
* RHSM_API_RESPONSE_UOM_TYPES: {CORES: string, SOCKETS: string}, RHSM_API_QUERY_INVENTORY_SORT_DIRECTION_TYPES: {ASCENDING: string,
* DESCENDING: string}, RHSM_API_QUERY_INVENTORY_SORT_TYPES: {CORES: string, STORAGE_GIBIBYTES: string, SOCKETS: string,
* INSTANCE_HOURS: string, TRANSFER_GIBIBYTES: string, BILLING_PROVIDER: string, CORE_SECONDS: string, LAST_SEEN: string,
* NAME: string}, RHSM_API_PATH_PRODUCT_TYPES: {RHEL_ARM: string, OPENSHIFT_METRICS: string, SATELLITE: string,
* RHEL_WORKSTATION: string, RHOSAK: string, RHEL_COMPUTE_NODE: string, RHEL_X86: string, OPENSHIFT: string,
* SATELLITE_SERVER: string, OPENSHIFT_DEDICATED_METRICS: string, RHEL_DESKTOP: string, RHEL: string, SATELLITE_CAPSULE: string,
* RHEL_SERVER: string, RHEL_IBM_Z: string, RHEL_IBM_POWER: string}, RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES: {AZURE: string,
* GCP: string, RED_HAT: string, NONE: string, AWS: string, ORACLE: string}, RHSM_API_RESPONSE_ERRORS_TYPES: {CODE: string},
* DESCENDING: string}, RHSM_API_RESPONSE_SUBSCRIPTION_TYPES: {ANNUAL: string, ON_DEMAND: string},
* RHSM_API_QUERY_INVENTORY_SORT_TYPES: {CORES: string, STORAGE_GIBIBYTES: string, SOCKETS: string, INSTANCE_HOURS: string,
* TRANSFER_GIBIBYTES: string, BILLING_PROVIDER: string, CORE_SECONDS: string, LAST_SEEN: string, NAME: string},
* RHSM_API_PATH_PRODUCT_TYPES: {RHEL_ARM: string, OPENSHIFT_METRICS: string, SATELLITE: string, RHEL_WORKSTATION: string,
* RHOSAK: string, RHEL_COMPUTE_NODE: string, RHEL_X86: string, OPENSHIFT: string, SATELLITE_SERVER: string,
* OPENSHIFT_DEDICATED_METRICS: string, RHEL_DESKTOP: string, RHEL: string, SATELLITE_CAPSULE: string, RHEL_SERVER: string,
* RHEL_IBM_Z: string, RHEL_IBM_POWER: string}, RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string,
* RED_HAT: string, NONE: string, AWS: string, ORACLE: string}, RHSM_API_RESPONSE_ERRORS_TYPES: {CODE: string},
* RHSM_API_QUERY_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string, RED_HAT: string, NONE: string, AWS: string, ORACLE: string},
* RHSM_API_QUERY_USAGE_TYPES: {UNSPECIFIED: string, DISASTER: string, DEVELOPMENT: string, PRODUCTION: string},
* RHSM_API_QUERY_SLA_TYPES: {PREMIUM: string, SELF: string, NONE: string, STANDARD: string},
Expand Down Expand Up @@ -374,6 +385,7 @@ const rhsmConstants = {
RHSM_API_RESPONSE_GRANULARITY_TYPES,
RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES,
RHSM_API_RESPONSE_SLA_TYPES,
RHSM_API_RESPONSE_SUBSCRIPTION_TYPES,
RHSM_API_RESPONSE_UOM_TYPES,
RHSM_API_RESPONSE_USAGE_TYPES,
RHSM_API_QUERY_GRANULARITY_TYPES,
Expand Down Expand Up @@ -407,6 +419,7 @@ export {
RHSM_API_RESPONSE_GRANULARITY_TYPES,
RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES,
RHSM_API_RESPONSE_SLA_TYPES,
RHSM_API_RESPONSE_SUBSCRIPTION_TYPES,
RHSM_API_RESPONSE_UOM_TYPES,
RHSM_API_RESPONSE_USAGE_TYPES,
RHSM_API_QUERY_GRANULARITY_TYPES,
Expand Down
8 changes: 6 additions & 2 deletions src/services/rhsm/rhsmSchemas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import JoiBase from 'joi';
import JoiDate from '@joi/date';
import { schemaResponse } from '../common/helpers';
import { rhsmConstants } from './rhsmConstants';
import RHSM_API_RESPONSE_SUBSCRIPTION_TYPES, { rhsmConstants } from './rhsmConstants';

const Joi = JoiBase.extend(JoiDate);

Expand Down Expand Up @@ -122,7 +122,11 @@ const instancesResponseSchema = Joi.object().keys({
*
* @type {*} Joi schema
*/
const subscriptionsMetaSchema = metaResponseSchema;
const subscriptionsMetaSchema = metaResponseSchema
.keys({
subscription_type: Joi.string().valid(null, ...Object.values(rhsmConstants.RHSM_API_RESPONSE_SUBSCRIPTION_TYPES))
})
.unknown(true);

/**
* Subscriptions response item.
Expand Down
3 changes: 2 additions & 1 deletion src/services/rhsm/rhsmServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,8 @@ const getInstancesInventory = (id, params = {}, options = {}) => {
* ],
* "links": {},
* "meta": {
* "count": 3
* "count": 3,
* "subscription_type": "On-demand"
* }
* }
*
Expand Down

0 comments on commit badcf33

Please sign in to comment.