@zextras/carbonio-ui-commons 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYING +235 -0
- package/README.md +25 -0
- package/lib/components/breadcrumbs/static-breadcrumbs.d.ts +8 -0
- package/lib/components/breadcrumbs/static-breadcrumbs.js +27 -0
- package/lib/components/breadcrumbs/static-breadcrumbs.js.map +1 -0
- package/lib/components/list/list-item.d.ts +3 -0
- package/lib/components/list/list-item.js +37 -0
- package/lib/components/list/list-item.js.map +1 -0
- package/lib/components/list/list.d.ts +3 -0
- package/lib/components/list/list.js +18 -0
- package/lib/components/list/list.js.map +1 -0
- package/lib/components/modals/folder-initialization-error-modal.d.ts +4 -0
- package/lib/components/modals/folder-initialization-error-modal.js +62 -0
- package/lib/components/modals/folder-initialization-error-modal.js.map +1 -0
- package/lib/components/modals/modal-footer.d.ts +3 -0
- package/lib/components/modals/modal-footer.js +89 -0
- package/lib/components/modals/modal-footer.js.map +1 -0
- package/lib/components/modals/modal-header.d.ts +6 -0
- package/lib/components/modals/modal-header.js +24 -0
- package/lib/components/modals/modal-header.js.map +1 -0
- package/lib/components/select/color-select.d.ts +14 -0
- package/lib/components/select/color-select.js +93 -0
- package/lib/components/select/color-select.js.map +1 -0
- package/lib/components/select/folders/flat-folder.d.ts +8 -0
- package/lib/components/select/folders/flat-folder.js +91 -0
- package/lib/components/select/folders/flat-folder.js.map +1 -0
- package/lib/components/select/folders/flat-folders.d.ts +12 -0
- package/lib/components/select/folders/flat-folders.js +83 -0
- package/lib/components/select/folders/flat-folders.js.map +1 -0
- package/lib/components/select/folders/flat-root.d.ts +12 -0
- package/lib/components/select/folders/flat-root.js +98 -0
- package/lib/components/select/folders/flat-root.js.map +1 -0
- package/lib/components/select/folders/folder-accordions-custom-component.d.ts +5 -0
- package/lib/components/select/folders/folder-accordions-custom-component.js +84 -0
- package/lib/components/select/folders/folder-accordions-custom-component.js.map +1 -0
- package/lib/components/select/folders/folder-selector.d.ts +12 -0
- package/lib/components/select/folders/folder-selector.js +73 -0
- package/lib/components/select/folders/folder-selector.js.map +1 -0
- package/lib/components/select/folders/folders-accordion.d.ts +14 -0
- package/lib/components/select/folders/folders-accordion.js +86 -0
- package/lib/components/select/folders/folders-accordion.js.map +1 -0
- package/lib/components/select/folders/hooks.d.ts +29 -0
- package/lib/components/select/folders/hooks.js +61 -0
- package/lib/components/select/folders/hooks.js.map +1 -0
- package/lib/components/select/folders/status-icon.d.ts +5 -0
- package/lib/components/select/folders/status-icon.js +35 -0
- package/lib/components/select/folders/status-icon.js.map +1 -0
- package/lib/components/select/folders/utils.d.ts +12 -0
- package/lib/components/select/folders/utils.js +100 -0
- package/lib/components/select/folders/utils.js.map +1 -0
- package/lib/components/select/folders-selector.d.ts +11 -0
- package/lib/components/select/folders-selector.js +78 -0
- package/lib/components/select/folders-selector.js.map +1 -0
- package/lib/components/select/select-label-factory.d.ts +7 -0
- package/lib/components/select/select-label-factory.js +45 -0
- package/lib/components/select/select-label-factory.js.map +1 -0
- package/lib/components/sidebar/sidebar-accordion-mui.d.ts +3 -0
- package/lib/components/sidebar/sidebar-accordion-mui.js +84 -0
- package/lib/components/sidebar/sidebar-accordion-mui.js.map +1 -0
- package/lib/components/tags/delete-tag-modal.d.ts +3 -0
- package/lib/components/tags/delete-tag-modal.js +85 -0
- package/lib/components/tags/delete-tag-modal.js.map +1 -0
- package/lib/constants/folders.d.ts +30 -0
- package/lib/constants/folders.js +40 -0
- package/lib/constants/folders.js.map +1 -0
- package/lib/constants/participants.d.ts +11 -0
- package/lib/constants/participants.js +19 -0
- package/lib/constants/participants.js.map +1 -0
- package/lib/constants/search.d.ts +22 -0
- package/lib/constants/search.js +124 -0
- package/lib/constants/search.js.map +1 -0
- package/lib/constants/utils/index.d.ts +41 -0
- package/lib/constants/utils/index.js +58 -0
- package/lib/constants/utils/index.js.map +1 -0
- package/lib/helpers/api-wrapper.d.ts +8 -0
- package/lib/helpers/api-wrapper.js +18 -0
- package/lib/helpers/api-wrapper.js.map +1 -0
- package/lib/helpers/email-parser.d.ts +2 -0
- package/lib/helpers/email-parser.js +28 -0
- package/lib/helpers/email-parser.js.map +1 -0
- package/lib/helpers/errors.d.ts +2 -0
- package/lib/helpers/errors.js +11 -0
- package/lib/helpers/errors.js.map +1 -0
- package/lib/helpers/folders.d.ts +100 -0
- package/lib/helpers/folders.js +196 -0
- package/lib/helpers/folders.js.map +1 -0
- package/lib/helpers/identities.d.ts +25 -0
- package/lib/helpers/identities.js +202 -0
- package/lib/helpers/identities.js.map +1 -0
- package/lib/helpers/search.d.ts +2 -0
- package/lib/helpers/search.js +21 -0
- package/lib/helpers/search.js.map +1 -0
- package/lib/helpers/use-history-navigation.d.ts +5 -0
- package/lib/helpers/use-history-navigation.js +25 -0
- package/lib/helpers/use-history-navigation.js.map +1 -0
- package/lib/hooks/use-initialize-folders.d.ts +2 -0
- package/lib/hooks/use-initialize-folders.js +117 -0
- package/lib/hooks/use-initialize-folders.js.map +1 -0
- package/lib/hooks/use-initialize-tags.d.ts +1 -0
- package/lib/hooks/use-initialize-tags.js +27 -0
- package/lib/hooks/use-initialize-tags.js.map +1 -0
- package/lib/hooks/use-update-view.d.ts +1 -0
- package/lib/hooks/use-update-view.js +23 -0
- package/lib/hooks/use-update-view.js.map +1 -0
- package/lib/index.d.ts +76 -0
- package/lib/index.js +116 -0
- package/lib/index.js.map +1 -0
- package/lib/integrations/constants.d.ts +3 -0
- package/lib/integrations/constants.js +15 -0
- package/lib/integrations/constants.js.map +1 -0
- package/lib/integrations/default-contact-input.d.ts +3 -0
- package/lib/integrations/default-contact-input.js +51 -0
- package/lib/integrations/default-contact-input.js.map +1 -0
- package/lib/integrations/hooks.d.ts +3 -0
- package/lib/integrations/hooks.js +14 -0
- package/lib/integrations/hooks.js.map +1 -0
- package/lib/integrations/search/use-run-search.d.ts +2 -0
- package/lib/integrations/search/use-run-search.js +10 -0
- package/lib/integrations/search/use-run-search.js.map +1 -0
- package/lib/integrations/types.d.ts +33 -0
- package/lib/integrations/types.js +8 -0
- package/lib/integrations/types.js.map +1 -0
- package/lib/notice.template.d.ts +1 -0
- package/lib/notice.template.js +8 -0
- package/lib/notice.template.js.map +1 -0
- package/lib/soap/errors/generic-soap-api-error.d.ts +13 -0
- package/lib/soap/errors/generic-soap-api-error.js +20 -0
- package/lib/soap/errors/generic-soap-api-error.js.map +1 -0
- package/lib/soap/errors/soap-api-error.d.ts +7 -0
- package/lib/soap/errors/soap-api-error.js +12 -0
- package/lib/soap/errors/soap-api-error.js.map +1 -0
- package/lib/soap/get-folder.d.ts +5 -0
- package/lib/soap/get-folder.js +25 -0
- package/lib/soap/get-folder.js.map +1 -0
- package/lib/soap/get-share-info.d.ts +13 -0
- package/lib/soap/get-share-info.js +22 -0
- package/lib/soap/get-share-info.js.map +1 -0
- package/lib/soap/no-op.d.ts +1 -0
- package/lib/soap/no-op.js +21 -0
- package/lib/soap/no-op.js.map +1 -0
- package/lib/soap/tags.d.ts +27 -0
- package/lib/soap/tags.js +30 -0
- package/lib/soap/tags.js.map +1 -0
- package/lib/store/zustand/folder/hooks.d.ts +91 -0
- package/lib/store/zustand/folder/hooks.js +180 -0
- package/lib/store/zustand/folder/hooks.js.map +1 -0
- package/lib/store/zustand/folder/store.d.ts +2 -0
- package/lib/store/zustand/folder/store.js +34 -0
- package/lib/store/zustand/folder/store.js.map +1 -0
- package/lib/store/zustand/folder/utils.d.ts +25 -0
- package/lib/store/zustand/folder/utils.js +58 -0
- package/lib/store/zustand/folder/utils.js.map +1 -0
- package/lib/store/zustand/tags/hooks.d.ts +4 -0
- package/lib/store/zustand/tags/hooks.js +20 -0
- package/lib/store/zustand/tags/hooks.js.map +1 -0
- package/lib/store/zustand/tags/index.d.ts +2 -0
- package/lib/store/zustand/tags/index.js +24 -0
- package/lib/store/zustand/tags/index.js.map +1 -0
- package/lib/store/zustand/tags/store.d.ts +2 -0
- package/lib/store/zustand/tags/store.js +18 -0
- package/lib/store/zustand/tags/store.js.map +1 -0
- package/lib/theme/theme-mui.d.ts +3 -0
- package/lib/theme/theme-mui.js +276 -0
- package/lib/theme/theme-mui.js.map +1 -0
- package/lib/theme/theme.d.ts +48 -0
- package/lib/theme/theme.js +8 -0
- package/lib/theme/theme.js.map +1 -0
- package/lib/types/actions/index.d.ts +8 -0
- package/lib/types/actions/index.js +8 -0
- package/lib/types/actions/index.js.map +1 -0
- package/lib/types/folder/index.d.ts +124 -0
- package/lib/types/folder/index.js +3 -0
- package/lib/types/folder/index.js.map +1 -0
- package/lib/types/i18next.d.ts +11 -0
- package/lib/types/i18next.js +3 -0
- package/lib/types/i18next.js.map +1 -0
- package/lib/types/identities/index.d.ts +33 -0
- package/lib/types/identities/index.js +8 -0
- package/lib/types/identities/index.js.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.js +32 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/modals/index.d.ts +31 -0
- package/lib/types/modals/index.js +8 -0
- package/lib/types/modals/index.js.map +1 -0
- package/lib/types/select/index.d.ts +15 -0
- package/lib/types/select/index.js +8 -0
- package/lib/types/select/index.js.map +1 -0
- package/lib/types/sidebar/index.d.ts +179 -0
- package/lib/types/sidebar/index.js +8 -0
- package/lib/types/sidebar/index.js.map +1 -0
- package/lib/types/soap/index.d.ts +13 -0
- package/lib/types/soap/index.js +3 -0
- package/lib/types/soap/index.js.map +1 -0
- package/lib/types/styled-components.d.ts +5 -0
- package/lib/types/styled-components.js +3 -0
- package/lib/types/styled-components.js.map +1 -0
- package/lib/types/tags/index.d.ts +46 -0
- package/lib/types/tags/index.js +8 -0
- package/lib/types/tags/index.js.map +1 -0
- package/lib/types/user-accounts/index.d.ts +13 -0
- package/lib/types/user-accounts/index.js +3 -0
- package/lib/types/user-accounts/index.js.map +1 -0
- package/lib/types/workers/index.d.ts +12 -0
- package/lib/types/workers/index.js +3 -0
- package/lib/types/workers/index.js.map +1 -0
- package/lib/utils/clipboard.d.ts +1 -0
- package/lib/utils/clipboard.js +27 -0
- package/lib/utils/clipboard.js.map +1 -0
- package/lib/utils/get-prefs.d.ts +2 -0
- package/lib/utils/get-prefs.js +15 -0
- package/lib/utils/get-prefs.js.map +1 -0
- package/lib/utils/index.d.ts +15 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/use-prefs.d.ts +2 -0
- package/lib/utils/use-prefs.js +15 -0
- package/lib/utils/use-prefs.js.map +1 -0
- package/lib/utils/utils.d.ts +3 -0
- package/lib/utils/utils.js +55 -0
- package/lib/utils/utils.js.map +1 -0
- package/lib/worker/folder.d.ts +1 -0
- package/lib/worker/folder.js +10 -0
- package/lib/worker/folder.js.map +1 -0
- package/lib/worker/handle-message.d.ts +30 -0
- package/lib/worker/handle-message.js +331 -0
- package/lib/worker/handle-message.js.map +1 -0
- package/lib/worker/index.d.ts +2 -0
- package/lib/worker/index.js +15 -0
- package/lib/worker/index.js.map +1 -0
- package/lib/worker/tags.d.ts +4 -0
- package/lib/worker/tags.js +64 -0
- package/lib/worker/tags.js.map +1 -0
- package/lib/worker/utils.d.ts +8 -0
- package/lib/worker/utils.js +23 -0
- package/lib/worker/utils.js.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SoapApiError = void 0;
|
|
4
|
+
class SoapApiError extends Error {
|
|
5
|
+
fault;
|
|
6
|
+
constructor(fault) {
|
|
7
|
+
super(fault.Reason.Text);
|
|
8
|
+
this.fault = fault;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.SoapApiError = SoapApiError;
|
|
12
|
+
//# sourceMappingURL=soap-api-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"soap-api-error.js","sourceRoot":"","sources":["../../../src/soap/errors/soap-api-error.ts"],"names":[],"mappings":";;;AAQA,MAAsB,YAAa,SAAQ,KAAK;IACzB;IAAtB,YAAsB,KAAgB;QACrC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QADJ,UAAK,GAAL,KAAK,CAAW;IAEtC,CAAC;CAGD;AAND,oCAMC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFolderRequest = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com>
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
8
|
+
*/
|
|
9
|
+
const carbonio_shell_ui_1 = require("@zextras/carbonio-shell-ui");
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const getFolderRequest = async ({ id, view }, account) => {
|
|
12
|
+
const body = (0, lodash_1.omitBy)({
|
|
13
|
+
_jsns: 'urn:zimbraMail',
|
|
14
|
+
folder: id
|
|
15
|
+
? {
|
|
16
|
+
l: id
|
|
17
|
+
}
|
|
18
|
+
: undefined,
|
|
19
|
+
view,
|
|
20
|
+
tr: 1
|
|
21
|
+
}, lodash_1.isNil);
|
|
22
|
+
return (0, carbonio_shell_ui_1.soapFetch)('GetFolder', body, account);
|
|
23
|
+
};
|
|
24
|
+
exports.getFolderRequest = getFolderRequest;
|
|
25
|
+
//# sourceMappingURL=get-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-folder.js","sourceRoot":"","sources":["../../src/soap/get-folder.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,kEAAuD;AACvD,mCAAuC;AAIhC,MAAM,gBAAgB,GAAG,KAAK,EACpC,EAAE,EAAE,EAAE,IAAI,EAAsC,EAChD,OAAgB,EACD,EAAE;IACjB,MAAM,IAAI,GAAG,IAAA,eAAM,EAClB;QACC,KAAK,EAAE,gBAAgB;QACvB,MAAM,EAAE,EAAE;YACT,CAAC,CAAC;gBACA,CAAC,EAAE,EAAE;aACL;YACF,CAAC,CAAC,SAAS;QACZ,IAAI;QACJ,EAAE,EAAE,CAAC;KACL,EACD,cAAK,CACL,CAAC;IACF,OAAO,IAAA,6BAAS,EAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC,CAAC;AAlBW,QAAA,gBAAgB,oBAkB3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ResFolder } from '../utils';
|
|
2
|
+
export type GetShareInfoRequest = {
|
|
3
|
+
_jsns: string;
|
|
4
|
+
includeSelf: number;
|
|
5
|
+
};
|
|
6
|
+
export type GetShareInfoResponse = {
|
|
7
|
+
_jsns: string;
|
|
8
|
+
share: Array<ResFolder>;
|
|
9
|
+
};
|
|
10
|
+
export declare const getShareInfoRequest: () => Promise<{
|
|
11
|
+
isFulfilled: boolean;
|
|
12
|
+
folders: Array<ResFolder>;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getShareInfoRequest = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com>
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
8
|
+
*/
|
|
9
|
+
const carbonio_shell_ui_1 = require("@zextras/carbonio-shell-ui");
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const getShareInfoRequest = async () => {
|
|
12
|
+
const result = await (0, carbonio_shell_ui_1.soapFetch)('GetShareInfo', {
|
|
13
|
+
_jsns: 'urn:zimbraAccount',
|
|
14
|
+
includeSelf: 0
|
|
15
|
+
});
|
|
16
|
+
if ('Fault' in result) {
|
|
17
|
+
return Promise.reject(result.Fault);
|
|
18
|
+
}
|
|
19
|
+
return Promise.resolve({ isFulfilled: !(0, lodash_1.isEmpty)(result), folders: result?.share ?? [] });
|
|
20
|
+
};
|
|
21
|
+
exports.getShareInfoRequest = getShareInfoRequest;
|
|
22
|
+
//# sourceMappingURL=get-share-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-share-info.js","sourceRoot":"","sources":["../../src/soap/get-share-info.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,kEAA8E;AAC9E,mCAAiC;AAc1B,MAAM,mBAAmB,GAAG,KAAK,IAGrC,EAAE;IACJ,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAS,EAC7B,cAAc,EACd;QACC,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,CAAC;KACd,CACD,CAAC;IAEF,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC,IAAA,gBAAO,EAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;AACzF,CAAC,CAAC;AAjBW,QAAA,mBAAmB,uBAiB9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NoOp: () => Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.NoOp = void 0;
|
|
9
|
+
const carbonio_shell_ui_1 = require("@zextras/carbonio-shell-ui");
|
|
10
|
+
const utils_1 = require("../constants/utils");
|
|
11
|
+
const NoOp = async () => {
|
|
12
|
+
const request = {
|
|
13
|
+
_jsns: utils_1.JSNS.MAIL
|
|
14
|
+
};
|
|
15
|
+
const response = await (0, carbonio_shell_ui_1.soapFetch)('NoOp', request);
|
|
16
|
+
if ('Fault' in response) {
|
|
17
|
+
throw new Error(response.Fault.Reason.Text);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.NoOp = NoOp;
|
|
21
|
+
//# sourceMappingURL=no-op.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-op.js","sourceRoot":"","sources":["../../src/soap/no-op.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kEAA8E;AAE9E,8CAA0C;AAQnC,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IAC7C,MAAM,OAAO,GAAG;QACf,KAAK,EAAE,YAAI,CAAC,IAAI;KACP,CAAC;IACX,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAS,EAA4B,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7E,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;AACF,CAAC,CAAC;AARW,QAAA,IAAI,QAQf"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ZimbraRequest } from '../types';
|
|
2
|
+
import { Tag } from '../types/tags';
|
|
3
|
+
export type CreateTagRequest = ZimbraRequest & {
|
|
4
|
+
tag: Omit<Tag, 'id'>;
|
|
5
|
+
};
|
|
6
|
+
export type CreateTagResponse = ZimbraRequest & {
|
|
7
|
+
tag: [Tag];
|
|
8
|
+
};
|
|
9
|
+
export type TagActionRequest = ZimbraRequest & {
|
|
10
|
+
action: {
|
|
11
|
+
op: 'rename' | 'color' | 'delete' | 'update';
|
|
12
|
+
id: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
color?: number;
|
|
15
|
+
rgb?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type TagActionResponse = {
|
|
19
|
+
action: {
|
|
20
|
+
op: string;
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare const createTag: (tag: Omit<Tag, "id">) => Promise<CreateTagResponse>;
|
|
25
|
+
export declare const deleteTag: (id: string) => Promise<TagActionResponse>;
|
|
26
|
+
export declare const renameTag: (id: string, name: string) => Promise<TagActionResponse>;
|
|
27
|
+
export declare const changeTagColor: (id: string, color: string | number) => Promise<TagActionResponse>;
|
package/lib/soap/tags.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.changeTagColor = exports.renameTag = exports.deleteTag = exports.createTag = void 0;
|
|
9
|
+
const carbonio_shell_ui_1 = require("@zextras/carbonio-shell-ui");
|
|
10
|
+
const createTag = (tag) => (0, carbonio_shell_ui_1.soapFetch)('CreateTag', {
|
|
11
|
+
_jsns: 'urn:zimbraMail',
|
|
12
|
+
tag
|
|
13
|
+
});
|
|
14
|
+
exports.createTag = createTag;
|
|
15
|
+
const deleteTag = (id) => (0, carbonio_shell_ui_1.soapFetch)('TagAction', {
|
|
16
|
+
_jsns: 'urn:zimbraMail',
|
|
17
|
+
action: { op: 'delete', id }
|
|
18
|
+
});
|
|
19
|
+
exports.deleteTag = deleteTag;
|
|
20
|
+
const renameTag = (id, name) => (0, carbonio_shell_ui_1.soapFetch)('TagAction', {
|
|
21
|
+
_jsns: 'urn:zimbraMail',
|
|
22
|
+
action: { op: 'rename', id, name }
|
|
23
|
+
});
|
|
24
|
+
exports.renameTag = renameTag;
|
|
25
|
+
const changeTagColor = (id, color) => (0, carbonio_shell_ui_1.soapFetch)('TagAction', {
|
|
26
|
+
_jsns: 'urn:zimbraMail',
|
|
27
|
+
action: typeof color === 'number' ? { op: 'color', color, id } : { op: 'color', rgb: color, id }
|
|
28
|
+
});
|
|
29
|
+
exports.changeTagColor = changeTagColor;
|
|
30
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/soap/tags.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,kEAAuD;AA2BhD,MAAM,SAAS,GAAG,CAAC,GAAoB,EAA8B,EAAE,CAC7E,IAAA,6BAAS,EAAsC,WAAW,EAAE;IAC3D,KAAK,EAAE,gBAAgB;IACvB,GAAG;CACH,CAAC,CAAC;AAJS,QAAA,SAAS,aAIlB;AAEG,MAAM,SAAS,GAAG,CAAC,EAAU,EAA8B,EAAE,CACnE,IAAA,6BAAS,EAAsC,WAAW,EAAE;IAC3D,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;CAC5B,CAAC,CAAC;AAJS,QAAA,SAAS,aAIlB;AAEG,MAAM,SAAS,GAAG,CAAC,EAAU,EAAE,IAAY,EAA8B,EAAE,CACjF,IAAA,6BAAS,EAAsC,WAAW,EAAE;IAC3D,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE;CAClC,CAAC,CAAC;AAJS,QAAA,SAAS,aAIlB;AAEG,MAAM,cAAc,GAAG,CAAC,EAAU,EAAE,KAAsB,EAA8B,EAAE,CAChG,IAAA,6BAAS,EAAsC,WAAW,EAAE;IAC3D,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE;CAChG,CAAC,CAAC;AAJS,QAAA,cAAc,kBAIvB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Folder, Folders, LinkFolder, SearchFolder, Searches } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the folder with given ID or undefined
|
|
4
|
+
* @params id */
|
|
5
|
+
export declare const useFolder: (id: string) => Folder | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the folder with given ID or undefined
|
|
8
|
+
* @params id */
|
|
9
|
+
export declare const getFolder: (id: string) => Folder | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a folders' map including roots and links. Each folder has its own tree structure included inside its children
|
|
12
|
+
*/
|
|
13
|
+
export declare const useFoldersMap: () => Folders;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a folders' map including roots and links. Each folder has its own tree structure included inside its children
|
|
16
|
+
*/
|
|
17
|
+
export declare const getFoldersMap: () => Folders;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a folders' array including only links. Each folder has its own tree structure included inside its children
|
|
20
|
+
*/
|
|
21
|
+
export declare const getLinksArray: (view?: string) => Array<LinkFolder>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the root folder of the provided folderId or undefined
|
|
24
|
+
* @params id
|
|
25
|
+
* @returns the root folder or undefined
|
|
26
|
+
* */
|
|
27
|
+
export declare const useRoot: (id: string) => Folder | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the root folder of the provided folderId or undefined
|
|
30
|
+
* @params id
|
|
31
|
+
* @returns the root folder or undefined
|
|
32
|
+
* */
|
|
33
|
+
export declare const getRoot: (id: string) => Folder | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Returns a roots' array. Each root has its own tree structure included inside its children
|
|
36
|
+
*/
|
|
37
|
+
export declare const useRootsArray: () => Array<Folder>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns a roots' array. Each root has its own tree structure included inside its children
|
|
40
|
+
*/
|
|
41
|
+
export declare const getRootsArray: () => Array<Folder>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a roots' map. Each root has its own tree structure included inside its children
|
|
44
|
+
*/
|
|
45
|
+
export declare const useRootsMap: () => Record<string, Folder>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns a roots' map. Each root has its own tree structure included inside its children
|
|
48
|
+
*/
|
|
49
|
+
export declare const getRootsMap: () => Record<string, Folder>;
|
|
50
|
+
/**
|
|
51
|
+
* Returns a root with given user ID.
|
|
52
|
+
* @params userId
|
|
53
|
+
*/
|
|
54
|
+
export declare const useRootByUser: (userId: string) => Folder | SearchFolder | Record<string, never> | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Returns a root with given user ID.
|
|
57
|
+
* @params userId
|
|
58
|
+
*/
|
|
59
|
+
export declare const getRootByUser: (userId: string) => Folder | SearchFolder | Record<string, never> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the root account id for a given folder
|
|
62
|
+
* @param folder a Folder or LinkFolder
|
|
63
|
+
* @returns the root account id or null if the folder is not a link or the root folder
|
|
64
|
+
*/
|
|
65
|
+
export declare function getRootAccountId(id: string): string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Return a flat array of folder that are children of the given root
|
|
68
|
+
* @param rootId
|
|
69
|
+
*/
|
|
70
|
+
export declare const useFoldersMapByRoot: (rootId: string) => Folders;
|
|
71
|
+
/**
|
|
72
|
+
* Return a flat array of folder that are children of the given root
|
|
73
|
+
* @param rootId
|
|
74
|
+
*/
|
|
75
|
+
export declare const getFoldersArrayByRoot: (rootId: string) => Array<Folder>;
|
|
76
|
+
export declare const useSearchFolder: (id: string) => SearchFolder | undefined;
|
|
77
|
+
export declare const getSearchFolder: (id: string) => SearchFolder | undefined;
|
|
78
|
+
export declare const useSearchFolders: () => Searches;
|
|
79
|
+
export declare const getSearchFolders: () => Searches;
|
|
80
|
+
/**
|
|
81
|
+
* Returns a callback function to update a specific folder.
|
|
82
|
+
*
|
|
83
|
+
* @returns callback function to update a specific folder
|
|
84
|
+
*/
|
|
85
|
+
export declare const useUpdateFolder: () => ((id: string, opt: Partial<Folder>) => void);
|
|
86
|
+
/**
|
|
87
|
+
* Returns a callback function to update a specific folder.
|
|
88
|
+
*
|
|
89
|
+
* @returns callback function to update a specific folder
|
|
90
|
+
*/
|
|
91
|
+
export declare const getUpdateFolder: () => ((id: string, opt: Partial<Folder>) => void);
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-FileCopyrightText: 2021 Zextras <https://www.zextras.com>
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getUpdateFolder = exports.useUpdateFolder = exports.getSearchFolders = exports.useSearchFolders = exports.getSearchFolder = exports.useSearchFolder = exports.getFoldersArrayByRoot = exports.useFoldersMapByRoot = exports.getRootByUser = exports.useRootByUser = exports.getRootsMap = exports.useRootsMap = exports.getRootsArray = exports.useRootsArray = exports.getRoot = exports.useRoot = exports.getLinksArray = exports.getFoldersMap = exports.useFoldersMap = exports.getFolder = exports.useFolder = void 0;
|
|
9
|
+
exports.getRootAccountId = getRootAccountId;
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const lodash_1 = require("lodash");
|
|
12
|
+
const store_1 = require("./store");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const folders_1 = require("../../../constants/folders");
|
|
15
|
+
const utils_2 = require("../../../constants/utils");
|
|
16
|
+
/**
|
|
17
|
+
* Returns the folder with given ID or undefined
|
|
18
|
+
* @params id */
|
|
19
|
+
const useFolder = (id) => (0, store_1.useFolderStore)((s) => s.folders?.[id]);
|
|
20
|
+
exports.useFolder = useFolder;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the folder with given ID or undefined
|
|
23
|
+
* @params id */
|
|
24
|
+
const getFolder = (id) => store_1.useFolderStore.getState()?.folders?.[id];
|
|
25
|
+
exports.getFolder = getFolder;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a folders' map including roots and links. Each folder has its own tree structure included inside its children
|
|
28
|
+
*/
|
|
29
|
+
const useFoldersMap = () => (0, store_1.useFolderStore)((s) => s.folders);
|
|
30
|
+
exports.useFoldersMap = useFoldersMap;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a folders' map including roots and links. Each folder has its own tree structure included inside its children
|
|
33
|
+
*/
|
|
34
|
+
const getFoldersMap = () => store_1.useFolderStore.getState().folders;
|
|
35
|
+
exports.getFoldersMap = getFoldersMap;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a folders' array including only links. Each folder has its own tree structure included inside its children
|
|
38
|
+
*/
|
|
39
|
+
const getLinksArray = (view) => (0, lodash_1.filter)((0, lodash_1.values)(store_1.useFolderStore.getState().folders), (folder) => {
|
|
40
|
+
if (view && folder.view !== view) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return folder.isLink;
|
|
44
|
+
});
|
|
45
|
+
exports.getLinksArray = getLinksArray;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the root folder id for a given folder
|
|
48
|
+
* @param folder a Folder or LinkFolder
|
|
49
|
+
* @returns the root folder id or null if the folder is not a link or the root folder
|
|
50
|
+
*/
|
|
51
|
+
function getRootFolderId(folder) {
|
|
52
|
+
const parent = folder?.parent && (0, exports.getFolder)(folder.parent);
|
|
53
|
+
if ('oname' in folder && folder?.oname === utils_2.ROOT_NAME) {
|
|
54
|
+
return folder.id;
|
|
55
|
+
}
|
|
56
|
+
if (parent) {
|
|
57
|
+
return getRootFolderId(parent);
|
|
58
|
+
}
|
|
59
|
+
return folder.id;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the root folder of the provided folderId or undefined
|
|
63
|
+
* @params id
|
|
64
|
+
* @returns the root folder or undefined
|
|
65
|
+
* */
|
|
66
|
+
const useRoot = (id) => (0, store_1.useFolderStore)((s) => {
|
|
67
|
+
const folder = s.folders?.[id];
|
|
68
|
+
if (folder) {
|
|
69
|
+
const rootFolderId = getRootFolderId(folder);
|
|
70
|
+
return s.folders?.[rootFolderId];
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
});
|
|
74
|
+
exports.useRoot = useRoot;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the root folder of the provided folderId or undefined
|
|
77
|
+
* @params id
|
|
78
|
+
* @returns the root folder or undefined
|
|
79
|
+
* */
|
|
80
|
+
const getRoot = (id) => {
|
|
81
|
+
const folder = store_1.useFolderStore.getState().folders?.[id];
|
|
82
|
+
if (folder) {
|
|
83
|
+
const rootFolderId = getRootFolderId(folder);
|
|
84
|
+
return store_1.useFolderStore.getState().folders?.[rootFolderId];
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
};
|
|
88
|
+
exports.getRoot = getRoot;
|
|
89
|
+
/**
|
|
90
|
+
* Returns a roots' array. Each root has its own tree structure included inside its children
|
|
91
|
+
*/
|
|
92
|
+
const useRootsArray = () => (0, store_1.useFolderStore)((s) => (0, lodash_1.filter)(s.folders, (f) => f.id?.split(':')?.includes(folders_1.FOLDERS.USER_ROOT)));
|
|
93
|
+
exports.useRootsArray = useRootsArray;
|
|
94
|
+
/**
|
|
95
|
+
* Returns a roots' array. Each root has its own tree structure included inside its children
|
|
96
|
+
*/
|
|
97
|
+
const getRootsArray = () => (0, lodash_1.filter)(store_1.useFolderStore.getState().folders, (f) => f.id?.split(':')?.includes(folders_1.FOLDERS.USER_ROOT));
|
|
98
|
+
exports.getRootsArray = getRootsArray;
|
|
99
|
+
/**
|
|
100
|
+
* Returns a roots' map. Each root has its own tree structure included inside its children
|
|
101
|
+
*/
|
|
102
|
+
const useRootsMap = () => (0, store_1.useFolderStore)((s) => (0, lodash_1.keyBy)((0, lodash_1.filter)(s.folders, (f) => f.id?.split(':')?.includes(folders_1.FOLDERS.USER_ROOT)), 'id'));
|
|
103
|
+
exports.useRootsMap = useRootsMap;
|
|
104
|
+
/**
|
|
105
|
+
* Returns a roots' map. Each root has its own tree structure included inside its children
|
|
106
|
+
*/
|
|
107
|
+
const getRootsMap = () => (0, lodash_1.keyBy)((0, lodash_1.filter)(store_1.useFolderStore.getState().folders, (f) => f.id?.split(':')?.includes(folders_1.FOLDERS.USER_ROOT)), 'id');
|
|
108
|
+
exports.getRootsMap = getRootsMap;
|
|
109
|
+
// ROOTS BY VIEW
|
|
110
|
+
/**
|
|
111
|
+
* Returns a root with given user ID.
|
|
112
|
+
* @params userId
|
|
113
|
+
*/
|
|
114
|
+
const useRootByUser = (userId) => (0, store_1.useFolderStore)((s) => (0, lodash_1.find)(s.folders, (f) => f.name === userId));
|
|
115
|
+
exports.useRootByUser = useRootByUser;
|
|
116
|
+
/**
|
|
117
|
+
* Returns a root with given user ID.
|
|
118
|
+
* @params userId
|
|
119
|
+
*/
|
|
120
|
+
const getRootByUser = (userId) => {
|
|
121
|
+
const { folders } = store_1.useFolderStore.getState();
|
|
122
|
+
return (0, lodash_1.find)(folders, (f) => f.name === userId);
|
|
123
|
+
};
|
|
124
|
+
exports.getRootByUser = getRootByUser;
|
|
125
|
+
/**
|
|
126
|
+
* Returns the root account id for a given folder
|
|
127
|
+
* @param folder a Folder or LinkFolder
|
|
128
|
+
* @returns the root account id or null if the folder is not a link or the root folder
|
|
129
|
+
*/
|
|
130
|
+
function getRootAccountId(id) {
|
|
131
|
+
const roots = (0, exports.getRootsArray)();
|
|
132
|
+
const root = (0, lodash_1.find)(roots, (r) => (0, lodash_1.some)(r.id?.split(':'), (v) => id?.split(':')?.includes(v)));
|
|
133
|
+
return root?.id;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Return a flat array of folder that are children of the given root
|
|
137
|
+
* @param rootId
|
|
138
|
+
*/
|
|
139
|
+
const useFoldersMapByRoot = (rootId) => {
|
|
140
|
+
const root = (0, exports.useRoot)(rootId);
|
|
141
|
+
return (0, react_1.useMemo)(() => (0, utils_1.getFlatChildrenFolders)(root?.children ?? []), [root?.children]);
|
|
142
|
+
};
|
|
143
|
+
exports.useFoldersMapByRoot = useFoldersMapByRoot;
|
|
144
|
+
/**
|
|
145
|
+
* Return a flat array of folder that are children of the given root
|
|
146
|
+
* @param rootId
|
|
147
|
+
*/
|
|
148
|
+
const getFoldersArrayByRoot = (rootId) => {
|
|
149
|
+
const root = (0, exports.getRoot)(rootId);
|
|
150
|
+
if (!root) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
return Object.values((0, utils_1.getFlatChildrenFolders)(root.children));
|
|
154
|
+
};
|
|
155
|
+
exports.getFoldersArrayByRoot = getFoldersArrayByRoot;
|
|
156
|
+
// SEARCHES
|
|
157
|
+
const useSearchFolder = (id) => (0, store_1.useFolderStore)((s) => s.searches?.[id]);
|
|
158
|
+
exports.useSearchFolder = useSearchFolder;
|
|
159
|
+
const getSearchFolder = (id) => store_1.useFolderStore.getState().searches[id];
|
|
160
|
+
exports.getSearchFolder = getSearchFolder;
|
|
161
|
+
const useSearchFolders = () => (0, store_1.useFolderStore)((s) => s.searches);
|
|
162
|
+
exports.useSearchFolders = useSearchFolders;
|
|
163
|
+
const getSearchFolders = () => store_1.useFolderStore.getState().searches;
|
|
164
|
+
exports.getSearchFolders = getSearchFolders;
|
|
165
|
+
// useful hooks to update the value of a folder. Created because we don't receive acl data from notify when we modify folder grants.
|
|
166
|
+
/**
|
|
167
|
+
* Returns a callback function to update a specific folder.
|
|
168
|
+
*
|
|
169
|
+
* @returns callback function to update a specific folder
|
|
170
|
+
*/
|
|
171
|
+
const useUpdateFolder = () => (0, store_1.useFolderStore)((s) => s.updateFolder);
|
|
172
|
+
exports.useUpdateFolder = useUpdateFolder;
|
|
173
|
+
/**
|
|
174
|
+
* Returns a callback function to update a specific folder.
|
|
175
|
+
*
|
|
176
|
+
* @returns callback function to update a specific folder
|
|
177
|
+
*/
|
|
178
|
+
const getUpdateFolder = () => store_1.useFolderStore.getState().updateFolder;
|
|
179
|
+
exports.getUpdateFolder = getUpdateFolder;
|
|
180
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../src/store/zustand/folder/hooks.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAoJH,4CAKC;AAvJD,iCAAgC;AAEhC,mCAA2D;AAE3D,mCAAyC;AACzC,mCAAiD;AACjD,wDAAqD;AACrD,oDAAqD;AAGrD;;gBAEgB;AACT,MAAM,SAAS,GAAG,CAAC,EAAU,EAAsB,EAAE,CAAC,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAAvF,QAAA,SAAS,aAA8E;AAEpG;;gBAEgB;AACT,MAAM,SAAS,GAAG,CAAC,EAAU,EAAsB,EAAE,CAC3D,sBAAc,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;AAD7B,QAAA,SAAS,aACoB;AAE1C;;GAEG;AACI,MAAM,aAAa,GAAG,GAAY,EAAE,CAAC,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAAhE,QAAA,aAAa,iBAAmD;AAE7E;;GAEG;AACI,MAAM,aAAa,GAAG,GAAY,EAAE,CAAC,sBAAc,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC;AAAjE,QAAA,aAAa,iBAAoD;AAE9E;;GAEG;AACI,MAAM,aAAa,GAAG,CAAC,IAAa,EAAqB,EAAE,CACjE,IAAA,eAAM,EAAC,IAAA,eAAM,EAAC,sBAAc,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,MAAc,EAAE,EAAE;IACpE,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAClC,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D,EAAE,CACjF,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;AAD1B,QAAA,eAAe,mBACW;AAEvC;;;;GAIG;AACI,MAAM,eAAe,GAAG,GAAiD,EAAE,CACjF,sBAAc,CAAC,QAAQ,EAAE,CAAC,YAAY,CAAC;AAD3B,QAAA,eAAe,mBACY"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.useFolderStore = void 0;
|
|
12
|
+
const immer_1 = __importDefault(require("immer"));
|
|
13
|
+
const zustand_1 = require("zustand");
|
|
14
|
+
const worker_1 = require("../../../worker");
|
|
15
|
+
// extra currying as suggested in https://github.com/pmndrs/zustand/blob/main/docs/guides/typescript.md#basic-usage
|
|
16
|
+
exports.useFolderStore = (0, zustand_1.create)()((set) => ({
|
|
17
|
+
folders: {},
|
|
18
|
+
linksIdMap: {},
|
|
19
|
+
searches: {},
|
|
20
|
+
updateFolder: (id, opt) => {
|
|
21
|
+
set((0, immer_1.default)((state) => {
|
|
22
|
+
if (state?.folders?.[id]) {
|
|
23
|
+
state.folders[id] = {
|
|
24
|
+
...state.folders[id],
|
|
25
|
+
...opt
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
worker_1.folderWorker.onmessage = ({ data }) => {
|
|
32
|
+
exports.useFolderStore.setState(data);
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../src/store/zustand/folder/store.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA4B;AAC5B,qCAAiC;AAGjC,4CAA+C;AAE/C,mHAAmH;AACtG,QAAA,cAAc,GAAG,IAAA,gBAAM,GAAe,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC7D,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,CAAC,EAAU,EAAE,GAAoB,EAAQ,EAAE;QACxD,GAAG,CACF,IAAA,eAAO,EAAC,CAAC,KAAK,EAAE,EAAE;YACjB,IAAI,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC1B,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG;oBACnB,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;oBACpB,GAAG,GAAG;iBACN,CAAC;YACH,CAAC;QACF,CAAC,CAAC,CACF,CAAC;IACH,CAAC;CACD,CAAC,CAAC,CAAC;AAEJ,qBAAY,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,EAAQ,EAAE;IAC3C,sBAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Folders } from '../../../types/folder';
|
|
2
|
+
import type { Folder, FolderView, TreeNode } from '../../../types/folder';
|
|
3
|
+
export declare const isNestedInTrash: (item: {
|
|
4
|
+
absFolderPath?: string;
|
|
5
|
+
}) => boolean;
|
|
6
|
+
export declare const isTrashOrNestedInIt: (item: {
|
|
7
|
+
id: string;
|
|
8
|
+
absFolderPath?: string;
|
|
9
|
+
}) => boolean;
|
|
10
|
+
export declare const folderViewFilter: (v: FolderView) => (deep?: boolean) => (f: Folder) => boolean;
|
|
11
|
+
export declare const filterNodes: <T>(children: TreeNode<T>[], f: (deep?: boolean) => (i: TreeNode<T>) => boolean, sortFunction?: (i: TreeNode<T>) => number | string, deep?: boolean) => TreeNode<T>[];
|
|
12
|
+
type MapNodesOptions<T, U> = {
|
|
13
|
+
mapFunction: (i: TreeNode<T>) => U;
|
|
14
|
+
filterFunction: (deep?: boolean) => (i: TreeNode<T>) => boolean;
|
|
15
|
+
recursionKey: keyof U;
|
|
16
|
+
sortFunction: (i: TreeNode<T>) => number | string;
|
|
17
|
+
deep: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const mapNodes: <T, U>(children: TreeNode<T>[], { mapFunction, filterFunction, recursionKey, sortFunction, deep }: MapNodesOptions<T, U>) => U[];
|
|
20
|
+
/**
|
|
21
|
+
* Recursive function that returns a flat map of the children folders
|
|
22
|
+
* @param children
|
|
23
|
+
*/
|
|
24
|
+
export declare const getFlatChildrenFolders: (children: Array<Folder>) => Folders;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getFlatChildrenFolders = exports.mapNodes = exports.filterNodes = exports.folderViewFilter = exports.isTrashOrNestedInIt = exports.isNestedInTrash = void 0;
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const folders_1 = require("../../../constants/folders");
|
|
11
|
+
const folders_2 = require("../../../helpers/folders");
|
|
12
|
+
const hasId = (f, id) => f.id.split(':').includes(id);
|
|
13
|
+
const isTrash = (f) => hasId(f, folders_1.FOLDERS.TRASH);
|
|
14
|
+
const isNestedInTrash = (item) => !!item?.absFolderPath?.includes(`/Trash/`);
|
|
15
|
+
exports.isNestedInTrash = isNestedInTrash;
|
|
16
|
+
const isTrashOrNestedInIt = (item) => isTrash(item) || (0, exports.isNestedInTrash)(item);
|
|
17
|
+
exports.isTrashOrNestedInIt = isTrashOrNestedInIt;
|
|
18
|
+
const folderViewFilter = (v) => (deep) => (f) => f.view === v || !deep || (typeof f.view === 'undefined' && !(0, folders_2.isRoot)(f.id));
|
|
19
|
+
exports.folderViewFilter = folderViewFilter;
|
|
20
|
+
const filterNodes = (children, f, sortFunction, deep) => {
|
|
21
|
+
const childrenSorted = sortFunction ? (0, lodash_1.sortBy)(children, sortFunction) : children;
|
|
22
|
+
return childrenSorted
|
|
23
|
+
.filter(f(deep))
|
|
24
|
+
.map((i) => ({ ...i, children: (0, exports.filterNodes)(i.children, f, sortFunction, true) }));
|
|
25
|
+
};
|
|
26
|
+
exports.filterNodes = filterNodes;
|
|
27
|
+
const mapNodes = (children, { mapFunction, filterFunction, recursionKey, sortFunction, deep }) => (0, lodash_1.sortBy)(children, sortFunction).reduce((acc, folder) => {
|
|
28
|
+
if (filterFunction(deep)(folder)) {
|
|
29
|
+
acc.push({
|
|
30
|
+
...mapFunction(folder),
|
|
31
|
+
[recursionKey]: (0, exports.mapNodes)(folder.children, {
|
|
32
|
+
mapFunction,
|
|
33
|
+
filterFunction,
|
|
34
|
+
recursionKey,
|
|
35
|
+
sortFunction,
|
|
36
|
+
deep: true
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return acc;
|
|
41
|
+
}, []);
|
|
42
|
+
exports.mapNodes = mapNodes;
|
|
43
|
+
/**
|
|
44
|
+
* Recursive function that returns a flat map of the children folders
|
|
45
|
+
* @param children
|
|
46
|
+
*/
|
|
47
|
+
const getFlatChildrenFolders = (children) => {
|
|
48
|
+
let destination = {};
|
|
49
|
+
children.forEach((child) => {
|
|
50
|
+
destination[child.id] = child;
|
|
51
|
+
if (child.children) {
|
|
52
|
+
destination = { ...destination, ...(0, exports.getFlatChildrenFolders)(child.children) };
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return destination;
|
|
56
|
+
};
|
|
57
|
+
exports.getFlatChildrenFolders = getFlatChildrenFolders;
|
|
58
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/store/zustand/folder/utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAAgC;AAEhC,wDAAqD;AACrD,sDAAkD;AAIlD,MAAM,KAAK,GAAG,CAAC,CAAiB,EAAE,EAAU,EAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAEvF,MAAM,OAAO,GAAG,CAAC,CAAiB,EAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAO,CAAC,KAAK,CAAC,CAAC;AAEjE,MAAM,eAAe,GAAG,CAAC,IAAgC,EAAW,EAAE,CAC5E,CAAC,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;AAD/B,QAAA,eAAe,mBACgB;AAErC,MAAM,mBAAmB,GAAG,CAAC,IAA4C,EAAW,EAAE,CAC5F,OAAO,CAAC,IAAI,CAAC,IAAI,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAC;AAD3B,QAAA,mBAAmB,uBACQ;AAEjC,MAAM,gBAAgB,GAC5B,CAAC,CAAa,EAAE,EAAE,CAClB,CAAC,IAAc,EAAE,EAAE,CACnB,CAAC,CAAS,EAAW,EAAE,CACtB,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,IAAA,gBAAM,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAJ/D,QAAA,gBAAgB,oBAI+C;AAErE,MAAM,WAAW,GAAG,CAC1B,QAAuB,EACv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AAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1B,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;QAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpB,WAAW,GAAG,EAAE,GAAG,WAAW,EAAE,GAAG,IAAA,8BAAsB,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7E,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AAVW,QAAA,sBAAsB,0BAUjC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* SPDX-FileCopyrightText: 2021 Zextras <https://www.zextras.com>
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.useSortedTagsArray = exports.getTags = exports.useTags = void 0;
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const store_1 = require("./store");
|
|
11
|
+
function sortTags(tags) {
|
|
12
|
+
return (0, lodash_1.orderBy)(Object.values(tags), (tag) => tag.name.toLowerCase(), 'asc');
|
|
13
|
+
}
|
|
14
|
+
const useTags = (ids) => (0, store_1.useTagStore)((state) => (ids ? (0, lodash_1.pick)(state.tags, ids) : state.tags));
|
|
15
|
+
exports.useTags = useTags;
|
|
16
|
+
const getTags = (ids) => ids ? (0, lodash_1.pick)(store_1.useTagStore.getState().tags, ids) : store_1.useTagStore.getState().tags;
|
|
17
|
+
exports.getTags = getTags;
|
|
18
|
+
const useSortedTagsArray = () => (0, store_1.useTagStore)((state) => sortTags(state.tags));
|
|
19
|
+
exports.useSortedTagsArray = useSortedTagsArray;
|
|
20
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../src/store/zustand/tags/hooks.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAAuC;AAEvC,mCAAsC;AAGtC,SAAS,QAAQ,CAAC,IAAU;IAC3B,OAAO,IAAA,gBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;AAClF,CAAC;AAEM,MAAM,OAAO,GAAG,CAAC,GAA4B,EAAQ,EAAE,CAC7D,IAAA,mBAAW,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,aAAI,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AADvD,QAAA,OAAO,WACgD;AAE7D,MAAM,OAAO,GAAG,CAAC,GAA4B,EAAQ,EAAE,CAC7D,GAAG,CAAC,CAAC,CAAC,IAAA,aAAI,EAAC,mBAAW,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAW,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;AAD/D,QAAA,OAAO,WACwD;AAErE,MAAM,kBAAkB,GAAG,GAAe,EAAE,CAClD,IAAA,mBAAW,EAAC,CAAC,KAAK,EAAc,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAD7C,QAAA,kBAAkB,sBAC2B"}
|