MINOR: Add condition for welcome page (#19266)

* add condition for welcome page

* create mock for useWelcomeStore

---------

Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
Sweta Agarwalla 2025-01-07 20:51:33 +05:30 committed by GitHub
parent aceadb1cde
commit 29b48bec51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 1 deletions

View File

@ -30,6 +30,7 @@ import PermissionProvider from './context/PermissionProvider/PermissionProvider'
import TourProvider from './context/TourProvider/TourProvider';
import WebSocketProvider from './context/WebSocketProvider/WebSocketProvider';
import { useApplicationStore } from './hooks/useApplicationStore';
import { useWelcomeStore } from './hooks/useWelcomeStore';
import { getCustomUiThemePreference } from './rest/settingConfigAPI';
import { history } from './utils/HistoryUtils';
import i18n from './utils/i18next/LocalUtil';
@ -37,6 +38,7 @@ import { getThemeConfig } from './utils/ThemeUtils';
const App: FC = () => {
const { applicationConfig, setApplicationConfig } = useApplicationStore();
const { setIsWelcomeVisible } = useWelcomeStore();
const fetchApplicationConfig = async () => {
try {
@ -54,6 +56,7 @@ const App: FC = () => {
useEffect(() => {
fetchApplicationConfig();
setIsWelcomeVisible(true);
}, []);
useEffect(() => {

View File

@ -0,0 +1,25 @@
/*
* Copyright 2025 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { create } from 'zustand';
interface WelcomeStore {
isWelcomeVisible: boolean;
setIsWelcomeVisible: (isVisible: boolean) => void;
}
export const useWelcomeStore = create<WelcomeStore>()((set) => ({
isWelcomeVisible: false,
setIsWelcomeVisible: (isVisible: boolean) => {
set({ isWelcomeVisible: isVisible });
},
}));

View File

@ -38,6 +38,7 @@ import { EntityReference } from '../../generated/type/entityReference';
import LimitWrapper from '../../hoc/LimitWrapper';
import { useApplicationStore } from '../../hooks/useApplicationStore';
import { useGridLayoutDirection } from '../../hooks/useGridLayoutDirection';
import { useWelcomeStore } from '../../hooks/useWelcomeStore';
import { getDocumentByFQN } from '../../rest/DocStoreAPI';
import { getActiveAnnouncement } from '../../rest/feedsAPI';
import { searchQuery } from '../../rest/searchAPI';
@ -52,6 +53,7 @@ const ReactGridLayout = WidthProvider(RGL);
const MyDataPage = () => {
const { t } = useTranslation();
const { currentUser, selectedPersona } = useApplicationStore();
const { isWelcomeVisible } = useWelcomeStore();
const [followedData, setFollowedData] = useState<Array<EntityReference>>([]);
const [followedDataCount, setFollowedDataCount] = useState(0);
const [isLoadingOwnedData, setIsLoadingOwnedData] = useState<boolean>(false);
@ -117,7 +119,7 @@ const MyDataPage = () => {
useEffect(() => {
isMounted.current = true;
updateWelcomeScreen(!usernameExistsInCookie);
updateWelcomeScreen(!usernameExistsInCookie && isWelcomeVisible);
return () => updateWelcomeScreen(false);
}, []);

View File

@ -145,6 +145,12 @@ jest.mock('../DataInsightPage/DataInsightProvider', async () => {
return jest.fn().mockImplementation(({ children }) => <>{children}</>);
});
jest.mock('../../hooks/useWelcomeStore', () => ({
useWelcomeStore: jest.fn().mockReturnValue({
isWelcomeVisible: true,
}),
}));
jest.mock('../DataInsightPage/DataInsightProvider', () => {
return {
__esModule: true,