Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version bumper/v1.14.0 1 #282

Open
wants to merge 26 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2ade606
build(deps): update dependencies
gnekoz Aug 26, 2024
e57d5b7
chore: fix typo
gnekoz Aug 26, 2024
f884228
Merge pull request #251 from zextras/20240826-rc
gnekoz Aug 26, 2024
4f63856
chore(release): 1.12.0
ZxBot Aug 26, 2024
435c66e
build(deps): update dependencies
nubsthead Nov 18, 2024
c041341
chore: merge conflicts resolution
nubsthead Nov 18, 2024
8d3698c
Merge pull request #271 from zextras/18112024-rc
nubsthead Nov 18, 2024
734fe3b
chore(release): 1.13.0
ZxBot Nov 18, 2024
0478372
fix: removed old sync-data-handler.jsx replaced by tsx version
mbarto Nov 20, 2024
dfcbafc
Merge pull request #274 from zextras/fix_CO-1605
mbarto Nov 20, 2024
0af9801
chore(release): 1.13.1
ZxBot Nov 20, 2024
3541880
feat: add AuthGuard component to segregate authenticated-only content
gnekoz Dec 11, 2024
1dc5826
test: add mock for useAuthenticated hook
gnekoz Dec 11, 2024
e9965bb
refactor: move files
gnekoz Dec 12, 2024
902af12
refactor: encapsulate integration registration in a dedicated component
gnekoz Dec 12, 2024
d2c9577
refactor: encapsulate integration registration in a dedicated component
gnekoz Dec 12, 2024
40dd46f
refactor: encapsulate integration registration in a dedicated component
gnekoz Dec 12, 2024
9d8baed
refactor: encapsulate all the view and route registrations in a dedic…
gnekoz Dec 12, 2024
dc12a84
refactor: encapsulate the folders syncronization hook in a dedicated …
gnekoz Dec 12, 2024
b6abebf
refactor: delegate logic inside App component to specific sub-components
gnekoz Dec 12, 2024
2716ebc
refactor: add FolderSyncronization sub-component to App
gnekoz Dec 12, 2024
172d377
test: add spy for useInitializeFolders
gnekoz Dec 12, 2024
f6b85ac
test: fix integration registration tests
gnekoz Dec 12, 2024
9e7e393
fix: prevent module to load if the user is not authenticated
gnekoz Dec 12, 2024
8727548
chore(release): 1.14.0
ZxBot Dec 12, 2024
07c3dc8
refactor: merge from devel and conflicts resolution
gnekoz Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.14.0](https://github.com/zextras/carbonio-contacts-ui/compare/v1.13.1...v1.14.0) (2024-12-12)


### Features

* add AuthGuard component to segregate authenticated-only content ([3541880](https://github.com/zextras/carbonio-contacts-ui/commit/3541880b21782e99571b4fea6d5a1e2db7af4c5d))


### Bug Fixes

* prevent module to load if the user is not authenticated ([9e7e393](https://github.com/zextras/carbonio-contacts-ui/commit/9e7e3939346cf82c82554604809a1e0cb32e7202))

### [1.13.1](https://github.com/zextras/carbonio-contacts-ui/compare/v1.13.0...v1.13.1) (2024-11-20)


Expand Down
7 changes: 7 additions & 0 deletions __mocks__/@zextras/carbonio-shell-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import shell from '@zextras/carbonio-shell-ui';

export * from '../../src/carbonio-ui-commons/test/mocks/carbonio-shell-ui';

// TODO move it in the Commons submodule
export const useAuthenticated = jest
.fn<ReturnType<typeof shell.useAuthenticated>, Parameters<typeof shell.useAuthenticated>>()
.mockReturnValue(true);
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "carbonio-contacts-ui",
"version": "1.13.1",
"version": "1.14.0",
"description": "Contacts module",
"main": "src/app.tsx",
"engines": {
Expand Down
295 changes: 13 additions & 282 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,295 +3,26 @@
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import React, { lazy, Suspense, useEffect, useMemo } from 'react';
import React from 'react';

import { ModalManager, useSnackbar } from '@zextras/carbonio-design-system';
import {
ACTION_TYPES,
addBoard,
addBoardView,
addRoute,
addSearchView,
addSettingsView,
NewAction,
registerActions,
registerComponents,
registerFunctions,
SearchViewProps,
SecondaryBarComponentProps
} from '@zextras/carbonio-shell-ui';
import { useTranslation } from 'react-i18next';

import { FOLDER_VIEW } from './carbonio-ui-commons/constants';
import { useInitializeFolders } from './carbonio-ui-commons/hooks/use-initialize-folders';
import { AuthGuard } from './app/auth-guard';
import { FoldersSynchronizator } from './app/folders-syncronization';
import { IntegrationsRegistration } from './app/integrations-registration';
import { ViewsRegistration } from './app/views-registration';
import { InitializeTags } from './components/initialize-tags';
import { Spinner } from './components/Spinner';
import {
CONTACTS_APP_ID,
CONTACTS_ROUTE,
NEW_CONTACT_GROUP_BOARD_ID,
GROUPS_ROUTE,
EDIT_CONTACT_GROUP_BOARD_ID,
EDIT_DL_BOARD_ID,
CONTACT_BOARD_ID
} from './constants';
import { ContactInput } from './legacy/integrations/contact-input';
import createContactIntegration from './legacy/integrations/create-contact';
import { StoreProvider } from './legacy/store/redux';
import { SyncDataHandler } from './legacy/views/secondary-bar/sync-data-handler';

const LazyContactsView = lazy(
() => import(/* webpackChunkName: "contacts-view" */ './views/contacts-view')
);
const LazySecondaryBarView = lazy(
() =>
import(/* webpackChunkName: "secondaryBarView" */ './views/distribution-list/SecondaryBarView')
);
const LazyLegacySecondaryBarView = lazy(
() =>
import(
/* webpackChunkName: "legacySecondaryBarView" */ './legacy/views/secondary-bar/secondary-bar-view'
)
);

const LazyDistributionListAppView = lazy(
() => import(/* webpackChunkName: "groupsAppView" */ './views/distribution-list-view')
);
const LazySettingsView = lazy(
() => import(/* webpackChunkName: "settings-view" */ './legacy/views/settings/settings-view')
);
const LazySearchView = lazy(
() => import(/* webpackChunkName: "search-view" */ './legacy/views/search/search-view')
);

const LazyBoardView = lazy(
() => import(/* webpackChunkName: "edit-view" */ './legacy/views/edit/edit-view-board-wrapper')
);

const LazyNewContactGroupBoardView = lazy(
() =>
import(
/* webpackChunkName: "newContactGroupView" */ './views/contact-groups/board/new-contact-group-board'
)
);

const LazyEditContactGroupBoardView = lazy(
() =>
import(
/* webpackChunkName: "editContactGroupView" */ './views/contact-groups/board/edit-contact-group-board'
)
);

const LazyEditDLBoardView = lazy(
() => import(/* webpackChunkName: "edit-dl-view" */ './views/board/edit-dl-board')
);

const ContactsAppView = (): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<StoreProvider>
<ModalManager>
<LazyContactsView />
</ModalManager>
</StoreProvider>
</Suspense>
);

const SecondaryBarView = (props: SecondaryBarComponentProps): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<ModalManager>
<LazySecondaryBarView {...props} />
</ModalManager>
</Suspense>
);

const DistributionListAppView = (): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<LazyDistributionListAppView />
</Suspense>
);

const BoardView = (): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
const App = (): React.JSX.Element => (
<AuthGuard>
<FoldersSynchronizator />
<InitializeTags />
<ViewsRegistration />
<IntegrationsRegistration />
<StoreProvider>
<ModalManager>
<LazyBoardView />
</ModalManager>
</StoreProvider>
</Suspense>
);

const NewContactGroupBoardView = (): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<ModalManager>
<LazyNewContactGroupBoardView />
</ModalManager>
</Suspense>
);

const EditContactGroupBoardView = (): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<ModalManager>
<LazyEditContactGroupBoardView />
</ModalManager>
</Suspense>
);

const EditDLBoardView = (): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<LazyEditDLBoardView />
</Suspense>
);

const SettingsView = (): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<StoreProvider>
<ModalManager>
<LazySettingsView />
</ModalManager>
</StoreProvider>
</Suspense>
);

const SearchView = (props: SearchViewProps): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<StoreProvider>
<ModalManager>
<LazySearchView {...props} />
</ModalManager>
</StoreProvider>
</Suspense>
);

const LegacySecondaryBarView = (props: SecondaryBarComponentProps): React.JSX.Element => (
<Suspense fallback={<Spinner />}>
<StoreProvider>
<ModalManager>
<LazyLegacySecondaryBarView {...props} />
</ModalManager>
</StoreProvider>
</Suspense>
);

const App = (): React.JSX.Element => {
const [t] = useTranslation();
const createSnackbar = useSnackbar();

useInitializeFolders(FOLDER_VIEW.contact);

const newContactAction = useMemo(
(): NewAction => ({
id: 'new-contact',
label: t('label.new_contact', 'New Contact'),
icon: 'ContactsModOutline',
execute: (ev): void => {
ev?.preventDefault?.();
addBoard({
boardViewId: CONTACT_BOARD_ID,
title: t('label.new_contact', 'New Contact')
});
},
disabled: false,
group: CONTACTS_APP_ID,
primary: true
}),
[t]
);

const newContactGroupAction = useMemo(
(): NewAction => ({
id: 'new-contact-group',
label: t('label.newContactGroup', 'New contact group'),
icon: 'PeopleOutline',
execute: (): void => {
addBoard({
boardViewId: NEW_CONTACT_GROUP_BOARD_ID,
title: t('board.newContactGroup.title', 'New Group')
});
},
disabled: false,
primary: false,
group: CONTACTS_APP_ID
}),
[t]
);

useEffect(() => {
addRoute({
route: CONTACTS_ROUTE,
position: 300,
visible: true,
label: t('label.app_name', 'Contacts'),
primaryBar: 'ContactsModOutline',
secondaryBar: LegacySecondaryBarView,
appView: ContactsAppView
});
addRoute({
route: GROUPS_ROUTE,
position: 310,
visible: true,
label: t('label.distribution_list_app_name', 'Distribution Lists'),
primaryBar: 'ListOutline',
secondaryBar: SecondaryBarView,
appView: DistributionListAppView
});
addSettingsView({
route: CONTACTS_ROUTE,
label: t('label.app_name', 'Contacts'),
component: SettingsView
});
addSearchView({
route: CONTACTS_ROUTE,
label: t('label.app_name', 'Contacts'),
component: SearchView
});
addBoardView({
id: CONTACT_BOARD_ID,
component: BoardView
});
addBoardView({
id: NEW_CONTACT_GROUP_BOARD_ID,
component: NewContactGroupBoardView
});
addBoardView({
id: EDIT_CONTACT_GROUP_BOARD_ID,
component: EditContactGroupBoardView
});
addBoardView({
id: EDIT_DL_BOARD_ID,
component: EditDLBoardView
});
}, [t]);

useEffect(() => {
registerComponents({
id: 'contact-input',
component: ContactInput
});

registerActions<NewAction>(
{
action: () => newContactAction,
id: 'new-contact',
type: ACTION_TYPES.NEW
},
{
id: 'new-contact-group',
type: ACTION_TYPES.NEW,
action: () => newContactGroupAction
}
);
registerFunctions({
id: 'create_contact_from_vcard',
fn: createContactIntegration(createSnackbar, t)
});
}, [createSnackbar, newContactAction, newContactGroupAction, t]);

return (
<StoreProvider>
<InitializeTags />
<SyncDataHandler />
</StoreProvider>
);
};
</AuthGuard>
);

export default App;
18 changes: 18 additions & 0 deletions src/app/auth-guard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import React, { ReactNode } from 'react';

import { useAuthenticated } from '@zextras/carbonio-shell-ui';

type AuthGuardProps = {
children: ReactNode;
};

export const AuthGuard: React.FC<AuthGuardProps> = ({ children }) => {
const isAuthenticated = useAuthenticated();

return isAuthenticated ? <>{children}</> : null;
};
Loading