From aff72b55c71b23f74f642f7ebb5b4ee5de1e1814 Mon Sep 17 00:00:00 2001
From: Adonis Puente <60629070+adonispuente@users.noreply.github.com>
Date: Wed, 13 Dec 2023 08:07:56 -0500
Subject: [PATCH] fix(ESSNTL-5612): Update Staleness & Deletion Keys + Route
Protection (#2114)
* fix(ESSNTL-5612): Update Staleness & Deletion Keys
* fix(RHINENG-5860): Add feature flag for staleness route
* fix(ESSNTL-5612): Update Staleness & Deletion Keys
---
src/Routes.js | 10 +-
.../__test__/InventoryHostStaleness.test.js | 12 +-
.../InventoryHostStaleness/constants.js | 176 +++++++++---------
3 files changed, 103 insertions(+), 95 deletions(-)
diff --git a/src/Routes.js b/src/Routes.js
index c761e2acf..995167d4d 100644
--- a/src/Routes.js
+++ b/src/Routes.js
@@ -11,6 +11,7 @@ import { getSearchParams } from './constants';
import RenderWrapper from './Utilities/Wrapper';
import useFeatureFlag from './Utilities/useFeatureFlag';
import { Bullseye, Spinner } from '@patternfly/react-core';
+import LostPage from './components/LostPage';
import AsyncComponent from '@redhat-cloud-services/frontend-components/AsyncComponent';
import ErrorState from '@redhat-cloud-services/frontend-components/ErrorState';
import { inventoryHasEdgeSystems } from './Utilities/edge';
@@ -52,6 +53,9 @@ export const Routes = () => {
const edgeParityInventoryListEnabled = useFeatureFlag(
'edgeParity.inventory-list'
);
+
+ const stalenessAndDeletionEnabled = useFeatureFlag('hbi.custom-staleness');
+
useEffect(() => {
try {
(async () => {
@@ -103,7 +107,11 @@ export const Routes = () => {
},
{
path: '/staleness-and-deletion',
- element:
{ Staleness must be before stale warning
); - } else if (formValue > newFormValues['conventional_culling_delta']) { + } else if (formValue > newFormValues['conventional_time_to_delete']) { return ({ return
Maximum: 7 days
; } } - if (apiKey === 'conventional_stale_warning_delta') { - if (formValue > newFormValues['conventional_culling_delta']) { + if (apiKey === 'conventional_time_to_stale_warning') { + if (formValue > newFormValues['conventional_time_to_delete']) { return ({ Stale warning must be before deletion
); - } else if (formValue < newFormValues['conventional_staleness_delta']) { + } else if (formValue < newFormValues['conventional_time_to_stale']) { return ({ ); } } - if (apiKey === 'conventional_culling_delta') { - if (formValue < newFormValues['conventional_stale_warning_delta']) { + if (apiKey === 'conventional_time_to_delete') { + if (formValue < newFormValues['conventional_time_to_stale_warning']) { return (
{ Deletion must be after staleness
); - } else if (formValue < newFormValues['conventional_staleness_delta']) { + } else if (formValue < newFormValues['conventional_time_to_stale']) { return ({ } } - if (apiKey === 'immutable_staleness_delta') { - if (formValue > newFormValues['immutable_stale_warning_delta']) { + if (apiKey === 'immutable_time_to_stale') { + if (formValue > newFormValues['immutable_time_to_stale_warning']) { return (
{ Staleness must be before stale warning
); - } else if (formValue > newFormValues['immutable_culling_delta']) { + } else if (formValue > newFormValues['immutable_time_to_delete']) { return ({ ); } } - if (apiKey === 'immutable_stale_warning_delta') { - if (formValue > newFormValues['immutable_culling_delta']) { + if (apiKey === 'immutable_time_to_stale_warning') { + if (formValue > newFormValues['immutable_time_to_delete']) { return (
{ Stale warning must be before deletion
); - } else if (formValue < newFormValues['immutable_staleness_delta']) { + } else if (formValue < newFormValues['immutable_time_to_stale']) { return ({ ); } } - if (apiKey === 'immutable_culling_delta') { - if (formValue < newFormValues['immutable_stale_warning_delta']) { + if (apiKey === 'immutable_time_to_delete') { + if (formValue < newFormValues['immutable_time_to_stale_warning']) { return (
{ Deletion must be after staleness
); - } else if (formValue < newFormValues['immutable_staleness_delta']) { + } else if (formValue < newFormValues['immutable_time_to_stale']) { return ({ name: '1 day', value: 1, apiKey: activeTabKey - ? 'immutable_staleness_delta' - : 'conventional_staleness_delta', + ? 'immutable_time_to_stale' + : 'conventional_time_to_stale', title: 'System staleness', modalMessage: 'A stale status on a system indicates that your system has not checked-in in a certain amount of time.', @@ -361,43 +361,43 @@ export const systemStalenessItems = (activeTabKey) => { name: '2 days', value: 2, apiKey: activeTabKey - ? 'immutable_staleness_delta' - : 'conventional_staleness_delta', + ? 'immutable_time_to_stale' + : 'conventional_time_to_stale', }, { name: '3 days', value: 3, apiKey: activeTabKey - ? 'immutable_staleness_delta' - : 'conventional_staleness_delta', + ? 'immutable_time_to_stale' + : 'conventional_time_to_stale', }, { name: '4 days', value: 4, apiKey: activeTabKey - ? 'immutable_staleness_delta' - : 'conventional_staleness_delta', + ? 'immutable_time_to_stale' + : 'conventional_time_to_stale', }, { name: '5 days', value: 5, apiKey: activeTabKey - ? 'immutable_staleness_delta' - : 'conventional_staleness_delta', + ? 'immutable_time_to_stale' + : 'conventional_time_to_stale', }, { name: '6 days', value: 6, apiKey: activeTabKey - ? 'immutable_staleness_delta' - : 'conventional_staleness_delta', + ? 'immutable_time_to_stale' + : 'conventional_time_to_stale', }, { name: '7 days', value: 7, apiKey: activeTabKey - ? 'immutable_staleness_delta' - : 'conventional_staleness_delta', + ? 'immutable_time_to_stale' + : 'conventional_time_to_stale', }, ]; }; @@ -408,8 +408,8 @@ export const systemStalenessWarningItems = (activeTabKey) => { name: '7 days', value: 7, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', title: 'System stale warning', modalMessage: 'A stale warning status on a system indicates that your system has not checked-in in a while, and is at risk of being deleted from your inventory.', @@ -418,57 +418,57 @@ export const systemStalenessWarningItems = (activeTabKey) => { name: '14 days', value: 14, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, { name: '21 days', value: 21, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, { name: '30 days', value: 30, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, { name: '60 days', value: 60, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, { name: '90 days', value: 90, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, { name: '120 days', value: 120, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, { name: '150 days', value: 150, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, { name: '180 days', value: 180, apiKey: activeTabKey - ? 'immutable_stale_warning_delta' - : 'conventional_stale_warning_delta', + ? 'immutable_time_to_stale_warning' + : 'conventional_time_to_stale_warning', }, ]; }; @@ -479,8 +479,8 @@ export const systemDeletionItems = (activeTabKey) => { name: '14 days', value: 14, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', title: 'System deletion', modalMessage: 'This is the time at which your system will be deleted from your inventory. Once your system is deleted, it will have to be re-registered to be added back to your inventory.', @@ -489,64 +489,64 @@ export const systemDeletionItems = (activeTabKey) => { name: '21 days', value: 21, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '30 days', value: 30, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '60 days', value: 60, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '90 days', value: 90, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '120 days', value: 120, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '150 days', value: 150, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '180 days', value: 180, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '1 year', value: 365, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, { name: '2 years', value: 730, apiKey: activeTabKey - ? 'immutable_culling_delta' - : 'conventional_culling_delta', + ? 'immutable_time_to_delete' + : 'conventional_time_to_delete', }, ]; }; @@ -557,29 +557,29 @@ export const formValidation = async (newFormValues, setIsFormValid) => { let formValue = newFormValues[apiKey]; if ( - apiKey === 'conventional_staleness_delta' && - formValue > newFormValues['conventional_stale_warning_delta'] + apiKey === 'conventional_time_to_stale' && + formValue > newFormValues['conventional_time_to_stale_warning'] ) { setIsFormValid(false); break; } if ( - apiKey === 'immutable_staleness_delta' && - formValue > newFormValues['immutable_stale_warning_delta'] + apiKey === 'immutable_time_to_stale' && + formValue > newFormValues['immutable_time_to_stale_warning'] ) { setIsFormValid(false); break; } if ( - apiKey === 'conventional_stale_warning_delta' && - formValue > newFormValues['conventional_culling_delta'] + apiKey === 'conventional_time_to_stale_warning' && + formValue > newFormValues['conventional_time_to_delete'] ) { setIsFormValid(false); break; } if ( - apiKey === 'immutable_stale_warning_delta' && - formValue > newFormValues['immutable_culling_delta'] + apiKey === 'immutable_time_to_stale_warning' && + formValue > newFormValues['immutable_time_to_delete'] ) { setIsFormValid(false); break;