fix(vipergc-574): Use selected shelve duration for fault management (#7890)

* refactor: `Indefinite` -> `Unlimited`
* refactor: remove unused const
* fix: use the selected shelveDuration
* fix: set and use default if none selected
* fix: bad optional chaining
* fix: handle the case of no provider
* fix: don't assign defaults if no provider
This commit is contained in:
Jesse Mazzella 2024-10-15 16:26:57 -07:00 committed by GitHub
parent 2b8673941a
commit ccf7ed91af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 23 deletions

View File

@ -35,7 +35,7 @@ export const DEFAULT_SHELVE_DURATIONS = [
value: 900000
},
{
name: 'Indefinite',
name: 'Unlimited',
value: null
}
];
@ -136,17 +136,21 @@ export default class FaultManagementAPI {
/**
* Retrieves the available shelve durations from the provider, or the default durations if the
* provider does not provide any.
* @returns {ShelveDuration[]}
* @returns {ShelveDuration[] | undefined}
*/
getShelveDurations() {
return this.provider?.getShelveDurations() ?? DEFAULT_SHELVE_DURATIONS;
if (!this.provider) {
return;
}
return this.provider.getShelveDurations?.() ?? DEFAULT_SHELVE_DURATIONS;
}
}
/**
* @typedef {Object} ShelveDuration
* @property {string} name - The name of the shelve duration
* @property {number|null} value - The value of the shelve duration in milliseconds, or null for indefinite
* @property {number|null} value - The value of the shelve duration in milliseconds, or null for unlimited
*/
/**

View File

@ -330,7 +330,8 @@ export default {
}
shelveData.comment = data.comment || '';
shelveData.shelveDuration = data.shelveDuration ?? this.shelveDurations[0].value;
shelveData.shelveDuration =
data.shelveDuration === undefined ? this.shelveDurations[0].value : data.shelveDuration;
} else {
shelveData = {
shelved: false

View File

@ -42,24 +42,6 @@ export const FAULT_MANAGEMENT_TYPE = 'faultManagement';
export const FAULT_MANAGEMENT_INSPECTOR = 'faultManagementInspector';
export const FAULT_MANAGEMENT_ALARMS = 'alarms';
export const FAULT_MANAGEMENT_GLOBAL_ALARMS = 'global-alarm-status';
export const FAULT_MANAGEMENT_SHELVE_DURATIONS_IN_MS = [
{
name: '5 Minutes',
value: 300000
},
{
name: '10 Minutes',
value: 600000
},
{
name: '15 Minutes',
value: 900000
},
{
name: 'Indefinite',
value: 0
}
];
export const FAULT_MANAGEMENT_VIEW = 'faultManagement.view';
export const FAULT_MANAGEMENT_NAMESPACE = 'faults.taxonomy';
export const FILTER_ITEMS = ['Standard View', 'Acknowledged', 'Unacknowledged', 'Shelved'];