github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/redux/uiDataSelectors.ts (about) 1 // Copyright 2020 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 import { createSelector } from "reselect"; 12 13 import { AdminUIState } from "src/redux/state"; 14 import { RELEASE_NOTES_SIGNUP_DISMISSED_KEY, UIDataStatus } from "src/redux/uiData"; 15 16 export const dismissReleaseNotesSignupForm = createSelector( 17 (state: AdminUIState) => state.uiData[RELEASE_NOTES_SIGNUP_DISMISSED_KEY], 18 (hideFormData) => { 19 // Do not show subscription form if data is not initialized yet. 20 // It avoids form flickering in case value is set to `false` (hide form) and it 21 // is shown for a moment before response is received back. 22 if (!hideFormData) { 23 return true; 24 } 25 if (hideFormData.status === UIDataStatus.VALID) { 26 // If data is successfully loaded and have no values, 27 // return default `false` value (do not hide subscription form) 28 if (hideFormData?.data === undefined) { 29 return false; 30 } 31 return hideFormData?.data; 32 } 33 // Do not show subscription form if request is loading 34 return true; 35 }, 36 );