-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: remove shell ModalManager BREAKING CHANGE: remove useModal in context-bridge BREAKING CHANGE: remove useSnackbar in context-bridge BREAKING CHANGE: remove CreateModalProps type Refs: SHELL-111 (#411)
- Loading branch information
1 parent
7669fca
commit c288690
Showing
11 changed files
with
144 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { I18nextProvider } from 'react-i18next'; | ||
|
||
import { SHELL_APP_ID } from '../constants'; | ||
import { useI18nStore } from '../store/i18n/store'; | ||
|
||
interface ModuleI18nextProviderProps { | ||
pkg: string; | ||
children: React.ReactNode | React.ReactNode[]; | ||
} | ||
export const ModuleI18nextProvider = ({ | ||
pkg, | ||
children | ||
}: ModuleI18nextProviderProps): React.JSX.Element => { | ||
const { instances, defaultI18n } = useI18nStore.getState(); | ||
const i18n = instances[pkg] ?? instances[SHELL_APP_ID] ?? defaultI18n; | ||
|
||
return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
import React, { useEffect } from 'react'; | ||
|
||
import { act } from '@testing-library/react'; | ||
import { useModal } from '@zextras/carbonio-design-system'; | ||
|
||
import AppViewContainer from './app-view-container'; | ||
import { useAppStore } from '../store/app'; | ||
import { setup } from '../test/utils'; | ||
|
||
const WithUseModalHookView = (): null => { | ||
const createModal = useModal(); | ||
useEffect(() => { | ||
createModal({ id: 'modal-1', title: 'modal test title' }); | ||
}, [createModal]); | ||
|
||
return null; | ||
}; | ||
|
||
test('Using useModal hook without a ModalManager, log a Modal manager context not initialized console error', async () => { | ||
const mockedError = jest.fn(); | ||
console.error = mockedError; | ||
|
||
setup(<AppViewContainer />, { withoutModalManager: true }); | ||
|
||
act(() => { | ||
useAppStore.getState().setApps([ | ||
{ | ||
commit: '', | ||
description: 'Mails module', | ||
display: 'Mails', | ||
icon: 'MailModOutline', | ||
js_entrypoint: '', | ||
name: 'carbonio-mails-ui', | ||
priority: 1, | ||
type: 'carbonio', | ||
version: '0.0.1' | ||
} | ||
]); | ||
useAppStore.getState().addRoute({ | ||
id: 'mails', | ||
route: 'mails', | ||
position: 1, | ||
visible: true, | ||
label: 'Mails', | ||
primaryBar: 'MailModOutline', | ||
appView: WithUseModalHookView, | ||
badge: { show: false }, | ||
app: 'carbonio-mails-ui' | ||
}); | ||
}); | ||
|
||
expect(mockedError).toBeCalled(); | ||
|
||
expect(mockedError).toBeCalledWith('Modal manager context not initialized'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters