From cbab7dbe5e4a08136f75fa0a0ad6f504f1d5fc8f Mon Sep 17 00:00:00 2001 From: Alex Boatwright Date: Thu, 28 Jul 2022 15:13:12 -0700 Subject: [PATCH] fix: optional retention in schema (#5236) --- src/buckets/components/createBucketForm/CreateBucketForm.tsx | 2 +- src/schemas/buckets.ts | 2 +- src/timeMachine/components/SelectorListCreateBucket.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/buckets/components/createBucketForm/CreateBucketForm.tsx b/src/buckets/components/createBucketForm/CreateBucketForm.tsx index 17180670f5..34739e1826 100644 --- a/src/buckets/components/createBucketForm/CreateBucketForm.tsx +++ b/src/buckets/components/createBucketForm/CreateBucketForm.tsx @@ -69,7 +69,7 @@ export const CreateBucketForm: FC = props => { ] = useState(null) const [showSchemaValidation, setShowSchemaValidation] = useState(false) - const retentionRule = state.retentionRules.find( + const retentionRule = state.retentionRules?.find( (rule: RetentionRule) => rule.type === 'expire' ) const retentionSeconds = retentionRule ? retentionRule.everySeconds : 3600 diff --git a/src/schemas/buckets.ts b/src/schemas/buckets.ts index bec1fe2f22..9cf37e20b5 100644 --- a/src/schemas/buckets.ts +++ b/src/schemas/buckets.ts @@ -9,7 +9,7 @@ import {labelSchema} from './labels' import {ruleToString} from 'src/utils/formatting' export const getReadableRetention = (bucket: GenBucket): string => { - const expire = bucket.retentionRules.find(rule => rule.type === 'expire') + const expire = bucket.retentionRules?.find(rule => rule.type === 'expire') if (!expire) { return 'forever' diff --git a/src/timeMachine/components/SelectorListCreateBucket.tsx b/src/timeMachine/components/SelectorListCreateBucket.tsx index c2bc7758e3..811d8e2869 100644 --- a/src/timeMachine/components/SelectorListCreateBucket.tsx +++ b/src/timeMachine/components/SelectorListCreateBucket.tsx @@ -83,7 +83,7 @@ const SelectorListCreateBucket: FC = ({ buttonDisabled = true } - const retentionRule = state.retentionRules.find(r => r.type === 'expire') + const retentionRule = state.retentionRules?.find(r => r.type === 'expire') const retentionSeconds = retentionRule ? retentionRule.everySeconds : 3600 const handleChangeRuleType = (ruleType: RuleType): void => {