Skip to content

Commit

Permalink
fix(Staleness): Update staleness page to match new backend specs (#2082)
Browse files Browse the repository at this point in the history
* fix(RHINENG-2911): Update values in staleness api request

* fix(ESSNTL-5595): remove unknown option in status filter

* fix(ESSNTL-5605): Update popover edge system values

* fix(ESSNTL-5538): Add buffer to convetional 1 day option

* feat(ESSNTL-5538): Update RBAC roles for staleness

* chore(ESSNTL-5538): Update no access text
  • Loading branch information
adonispuente authored Nov 10, 2023
1 parent 17e4195 commit 910cb2c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/Utilities/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const staleness = [
{ label: 'Fresh', value: 'fresh' },
{ label: 'Stale', value: 'stale' },
{ label: 'Stale warning', value: 'stale_warning' },
{ label: 'Unknown', value: 'unknown' },
];

export const currentDate = new Date().toISOString();
Expand Down
10 changes: 7 additions & 3 deletions src/components/InventoryHostStaleness/HostStalenessCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ const HostStalenessCard = ({ canModifyHostStaleness }) => {
apiKeys.forEach(
(filterKey) =>
filterKey !== 'id' &&
(apiData[filterKey] = daysToSecondsConversion(newFormValues[filterKey]))
newFormValues[filterKey] &&
(apiData[filterKey] = daysToSecondsConversion(
newFormValues[filterKey],
filterKey
))
);

// system_default means the account has no record, therefor, post for new instance of record.
Expand All @@ -91,7 +95,7 @@ const HostStalenessCard = ({ canModifyHostStaleness }) => {
dismissable: true,
})
);
fetchStalenessData();
fetchApiStalenessData();
setIsEditing(!isEditing);
setIsModalOpen(false);
})
Expand All @@ -117,7 +121,7 @@ const HostStalenessCard = ({ canModifyHostStaleness }) => {
dismissable: true,
})
);
fetchStalenessData();
fetchApiStalenessData();
setIsEditing(!isEditing);
setIsModalOpen(false);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const HostStalenessNoAccess = () => {
Access permissions needed
</Title>
<EmptyStateBody className="pf-u-mb-xl">
You do not have the necessary Inventory staleness and deletion viewer
role required to view this page.
You do not have the necessary Staleness and Deletion viewer role
required to view this page.
</EmptyStateBody>
<Button
variant="link"
Expand Down
31 changes: 20 additions & 11 deletions src/components/InventoryHostStaleness/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const IMMUTABLE_TAB_TOOLTIP =
'With OSTree, you can manage the system software by referencing a central image repository. OSTree images contain a complete operating system ready to be remotely installed at scale. You can track updates to images through commits and enable secure updates that only address changes and keep the operating system unchanged. The updates are quick, and the rollbacks are easy.';

export const GENERAL_HOST_STALENESS_WRITE_PERMISSION =
'inventory:staleness:write';
'staleness:staleness:write';
export const GENERAL_HOST_STALENESS_READ_PERMISSION =
'inventory:staleness:read';
'staleness:staleness:read';

export const HOST_STALENESS_ADMINISTRATOR_PERMISSIONS = [
GENERAL_HOST_STALENESS_READ_PERMISSION,
Expand All @@ -21,7 +21,20 @@ export const HOST_STALENESS_ADMINISTRATOR_PERMISSIONS = [

//86400 seconds in one day -> divide each by secodns in a day to get day values
export const secondsToDaysConversion = (seconds) => {
return seconds / 86400;
if (seconds === 104400) {
return 1;
} else {
return seconds / 86400;
}
};

export const daysToSecondsConversion = (days, filterKey) => {
//backend requires a buffer specifically for 1 this option
if (filterKey === 'conventional_staleness_delta' && days === 1) {
return 104400;
} else {
return days * 86400;
}
};

export const hostStalenessApiKeys = [
Expand All @@ -39,10 +52,6 @@ export const conventionalApiKeys = [
'conventional_culling_delta',
];

export const daysToSecondsConversion = (days) => {
return days * 86400;
};

export const conditionalDropdownError = (newFormValues, dropdownItems) => {
//this runs on every select every time
let apiKey = dropdownItems[0].apiKey;
Expand Down Expand Up @@ -225,12 +234,12 @@ export const HostStalenessResetDefaultPopover = ({ activeTabKey }) => {
- Systems are marked as stale after 2 days since last check-in.
</span>
<span className="pf-u-font-size-sm">
- Systems are marked as stale warning after 120 days since last
- Systems are marked as stale warning after 180 days since last
check-in.
</span>

<span className="pf-u-font-size-sm">
- Systems are deleted after 180 days since last check-in.
- Systems are deleted after 2 years since last check-in.
</span>
</Flex>
) : (
Expand Down Expand Up @@ -314,11 +323,11 @@ export const InventoryHostStalenessPopover = ({ hasEdgeSystems }) => {
</p>
</span>
<span className="pf-u-font-size-sm">
- Systems are marked as stale warning after 120 days since last
- Systems are marked as stale warning after 180 days since last
check-in.
</span>
<span className="pf-u-font-size-sm">
- Systems are deleted after 180 days since last check-in.
- Systems are deleted after 2 years since last check-in.
</span>
</Flex>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ exports[`EntityTableToolbar DOM should render correctly - no data 1`] = `
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -189,10 +185,6 @@ exports[`EntityTableToolbar DOM should render correctly - with children 1`] = `
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -446,10 +438,6 @@ exports[`EntityTableToolbar DOM should render correctly - with custom activeFilt
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -721,10 +709,6 @@ exports[`EntityTableToolbar DOM should render correctly - with custom filters 1`
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -984,10 +968,6 @@ exports[`EntityTableToolbar DOM should render correctly - with customFilters 1`]
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -1272,10 +1252,6 @@ exports[`EntityTableToolbar DOM should render correctly - with default filters 1
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -1519,10 +1495,6 @@ exports[`EntityTableToolbar DOM should render correctly - with default tag filte
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -1780,10 +1752,6 @@ exports[`EntityTableToolbar DOM should render correctly - with no access 1`] = `
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -2033,10 +2001,6 @@ exports[`EntityTableToolbar DOM should render correctly - with tags 1`] = `
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down Expand Up @@ -2316,10 +2280,6 @@ exports[`EntityTableToolbar DOM should render correctly 1`] = `
"label": "Stale warning",
"value": "stale_warning",
},
Object {
"label": "Unknown",
"value": "unknown",
},
],
"onChange": [Function],
"placeholder": "Filter by status",
Expand Down

0 comments on commit 910cb2c

Please sign in to comment.