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

feat!: separate search module #556

Merged
merged 12 commits into from
Dec 19, 2024
139 changes: 45 additions & 94 deletions api-extractor/carbonio-shell-ui.api.md

Large diffs are not rendered by default.

557 changes: 445 additions & 112 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "./lib/lib.js",
"types": "./lib/lib.d.ts",
"exports": {
".": "./lib/lib.js"
".": "./lib/lib.js",
"./*": null
},
"engines": {
"node": "v18",
Expand Down Expand Up @@ -39,8 +40,7 @@
},
"files": [
"lib/",
"COPYING",
"README.md"
"THIRDPARTIES"
],
"keywords": [
"zextras"
Expand All @@ -64,14 +64,15 @@
"@tsconfig/node18": "^18.2.4",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.4",
"@types/node": "^18.19.54",
"@types/node": "^18.19.67",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"@types/ua-parser-js": "^0.7.39",
"@types/webpack": "^5.28.5",
"@types/webpack-env": "^1.18.4",
"@zextras/carbonio-ui-configs": "^1.0.3",
"@zextras/carbonio-search-ui": "github:zextras/carbonio-search-ui#fix-ci-package-preparation",
"@zextras/carbonio-ui-configs": "^2.0.1",
"@zextras/carbonio-ui-sdk": "^1.7.10",
"autoprefixer": "^10.4.17",
"babel-loader": "^9.2.1",
Expand Down Expand Up @@ -106,11 +107,12 @@
"@sentry/browser": "^7.103.0",
"@tinymce/tinymce-react": "^4.3.2",
"@zextras/carbonio-design-system": "9.0.0-devel.7",
"@zextras/carbonio-ui-preview": "^3.1.0-devel.2",
"@zextras/carbonio-ui-preview": "^3.1.0",
"darkreader": "^4.9.79",
"date-fns": "^4.1.0",
"history": "^5.3.0",
"i18next": "^22.5.1",
"i18next-chained-backend": "^4.6.2",
"i18next-http-backend": "^2.5.0",
"immer": "^10.0.3",
"lodash": "^4.17.21",
Expand All @@ -127,7 +129,7 @@
},
"peerDependencies": {
"@zextras/carbonio-design-system": "9.0.0-devel.7",
"@zextras/carbonio-ui-preview": "3.1.0-devel.2",
"@zextras/carbonio-ui-preview": "^3.1.0",
"core-js": "^3.39.0",
"lodash": "^4.17.21",
"react": "^18.3.1",
Expand Down
5 changes: 0 additions & 5 deletions src/boot/app/app-dependant-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
normalizeBoardView,
normalizePrimaryAccessoryView,
normalizeRoute,
normalizeSearchView,
normalizeSecondaryAccessoryView,
normalizeSettingsView,
normalizeUtilityView
Expand All @@ -29,7 +28,6 @@ import type {
BoardView,
CarbonioModule,
PrimaryAccessoryView,
SearchView,
SecondaryAccessoryView,
SettingsView,
UtilityView
Expand All @@ -40,7 +38,6 @@ export type AppDependantExports = {
addRoute: (data: Partial<AppRouteDescriptor>) => ReturnType<StoreAppSetters['addRoute']>;
addBoardView: (data: Omit<BoardView, 'app'>) => ReturnType<StoreAppSetters['addBoardView']>;
addSettingsView: (data: Partial<SettingsView>) => ReturnType<StoreAppSetters['addSettingsView']>;
addSearchView: (data: Partial<SearchView>) => ReturnType<StoreAppSetters['addSearchView']>;
addUtilityView: (data: Partial<UtilityView>) => ReturnType<StoreAppSetters['addUtilityView']>;
addPrimaryAccessoryView: (
data: Partial<PrimaryAccessoryView>
Expand Down Expand Up @@ -79,8 +76,6 @@ export const getAppDependantExports = (pkg: CarbonioModule): AppDependantExports
appStore.addBoardView(normalizeBoardView(data, pkg)),
addSettingsView: (data: Partial<SettingsView>) =>
appStore.addSettingsView(normalizeSettingsView(data, pkg)),
addSearchView: (data: Partial<SearchView>) =>
appStore.addSearchView(normalizeSearchView(data, pkg)),
addUtilityView: (data: Partial<UtilityView>) =>
appStore.addUtilityView(normalizeUtilityView(data, pkg)),
addPrimaryAccessoryView: (data: Partial<PrimaryAccessoryView>) =>
Expand Down
3 changes: 0 additions & 3 deletions src/boot/app/app-direct-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ export {

export { getNotificationManager } from '../../notification/NotificationManager';

export { runSearch } from '../../search/run-search';

export { useLocalStorage } from '../../shell/hooks/useLocalStorage';

export const {
Expand All @@ -88,7 +86,6 @@ export const {
removeRoute,
removeBoardView,
removeSettingsView,
removeSearchView,
removeUtilityView,
removePrimaryAccessoryView,
removeSecondaryAccessoryView,
Expand Down
19 changes: 1 addition & 18 deletions src/boot/app/default-views.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';
import { produce } from 'immer';

import { DefaultViewsRegister } from './default-views';
import { SEARCH_APP_ID, SETTINGS_APP_ID, SHELL_APP_ID } from '../../constants';
import { SETTINGS_APP_ID, SHELL_APP_ID } from '../../constants';
import { useAccountStore } from '../../store/account';
import { useAppStore } from '../../store/app';
import { useLoginConfigStore } from '../../store/login/store';
Expand All @@ -17,23 +17,6 @@ import type { AccountSettingsAttrs } from '../../types/account';
import type { AppRouteDescriptor, SettingsView } from '../../types/apps';

describe('DefaultViews', () => {
it('should register search module', () => {
setup(<DefaultViewsRegister />);
expect(useAppStore.getState().routes).toMatchObject<Record<string, AppRouteDescriptor>>({
[SEARCH_APP_ID]: {
id: SEARCH_APP_ID,
app: SEARCH_APP_ID,
route: SEARCH_APP_ID,
label: 'Search',
position: 1000,
visible: true,
primaryBar: 'SearchModOutline',
badge: { show: false },
appView: expect.any(Function)
}
});
});

it.each<AccountSettingsAttrs['zimbraFeatureOptionsEnabled']>(['TRUE', undefined])(
'should register settings module if zimbraFeatureOptionsEnabled is %s',
(value) => {
Expand Down
33 changes: 1 addition & 32 deletions src/boot/app/default-views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { useEffect, useMemo } from 'react';

import { useTranslation } from 'react-i18next';

import { SEARCH_APP_ID, SETTINGS_APP_ID, SHELL_APP_ID } from '../../constants';
import { SearchAppView } from '../../search/search-app-view';
import { SETTINGS_APP_ID, SHELL_APP_ID } from '../../constants';
import { WrappedAccountsSettings } from '../../settings/accounts-settings';
import GeneralSettings from '../../settings/general-settings';
import { useSettingsSubSections } from '../../settings/general-settings-sub-sections';
Expand All @@ -19,34 +18,6 @@ import { useAccountStore } from '../../store/account';
import { useAppStore } from '../../store/app';
import type { AppRouteDescriptor, SettingsView } from '../../types/apps';

const useSearchModule = (): void => {
const [t] = useTranslation();

const searchRouteDescriptor = useMemo<AppRouteDescriptor>(
() => ({
id: SEARCH_APP_ID,
app: SEARCH_APP_ID,
route: SEARCH_APP_ID,
appView: SearchAppView,
badge: {
show: false
},
label: t('search.app', 'Search'),
position: 1000,
visible: true,
primaryBar: 'SearchModOutline'
}),
[t]
);
useEffect(() => {
useAppStore.getState().addRoute(searchRouteDescriptor);

return (): void => {
useAppStore.getState().removeRoute(searchRouteDescriptor.id);
};
}, [searchRouteDescriptor]);
};

const useSettingsModule = (): void => {
const [t] = useTranslation();
const settingsAttrs = useAccountStore((state) => state.settings.attrs);
Expand Down Expand Up @@ -116,8 +87,6 @@ const useSettingsModule = (): void => {
};

export const DefaultViewsRegister = (): null => {
useSearchModule();
useSettingsModule();

return null;
};
2 changes: 0 additions & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const SETTINGS_APP_ID = 'settings';
* @deprecated This constant is not used and will be deleted in next releases
*/
export const ACCOUNTS_APP_ID = 'accounts';
export const SEARCH_APP_ID = 'search';

export const ACTION_TYPES = {
/** @deprecated this action does not belong to shell, and therefore it will be removed in next releases */
Expand Down Expand Up @@ -73,7 +72,6 @@ export const DARK_READER_VALUES = ['auto', 'enabled', 'disabled'] as const;

export const LOCAL_STORAGE_SETTINGS_KEY = 'settings';
export const LOCAL_STORAGE_LAST_PRIMARY_KEY = 'config';
export const LOCAL_STORAGE_SEARCH_KEY = 'search_suggestions';
export const LOCAL_STORAGE_BOARD_SIZE = 'board_size';
export const SCALING_OPTIONS = [
{ value: 75, label: 'xs' },
Expand Down
2 changes: 1 addition & 1 deletion src/jest-polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Object.defineProperty(window, 'ResizeObserver', {
Object.defineProperty(window.crypto, 'subtle', {
writable: true,
value: {
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer> {
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<Buffer> {
return new Promise((resolve) => {
const decoder = new TextDecoder();
const dataString = decoder.decode(data);
Expand Down
4 changes: 0 additions & 4 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export declare const setAppContext: AppDependantExports['setAppContext'];
export declare const addRoute: AppDependantExports['addRoute'];
export declare const addBoardView: AppDependantExports['addBoardView'];
export declare const addSettingsView: AppDependantExports['addSettingsView'];
export declare const addSearchView: AppDependantExports['addSearchView'];
export declare const addUtilityView: AppDependantExports['addUtilityView'];
export declare const addPrimaryAccessoryView: AppDependantExports['addPrimaryAccessoryView'];
export declare const addSecondaryAccessoryView: AppDependantExports['addSecondaryAccessoryView'];
Expand Down Expand Up @@ -66,7 +65,6 @@ export type {
BoardViewComponentProps,
AppViewComponentProps,
SettingsViewProps,
SearchViewProps,
PrimaryAccessoryViewProps,
SecondaryAccessoryViewProps,
SettingsSubSection,
Expand Down Expand Up @@ -94,8 +92,6 @@ export type {
PopupNotificationConfig
} from './notification/NotificationManager';

export type { QueryItem, QueryChip } from './types/search';

export type { Grant } from './types/misc';

export type {
Expand Down
24 changes: 0 additions & 24 deletions src/search/module-selector.test.tsx

This file was deleted.

107 changes: 0 additions & 107 deletions src/search/module-selector.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions src/search/run-search.ts

This file was deleted.

Loading