-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: let user manage allowing and blocking addresses
* refactor: renamed domainWhitelistSubsection into trustedAddressesSubSection * feat: added Allowed senders list item to mail subsections * feat: added senders-list component * test: add tests for settings subsections * feat: add blocked senders subsection * feat: added allowed and blocked address lists to settings-view * chore: moved tooltip under the title in senders-list * chore: extracted getMessage function * chore: extracted type ListType * test: added some tests for senders-list * feat: added widget for adding email to senders-list * test: added add widget test for blocked list * feat: added behaviour for add button in senders-list * feat: added settings update on add sender in senders-list * feat: added settings read in senders-list * test: added test for updateSettings with list not empty for senders-list * test: clean input after add in senders-list * feat: added email validation on add in senders-list * refactor: inverted logic of isInvalid to isAddEnabled in senders-list * test: add tests for getSettingsSubSections * chore: review of input error messages in senders-list * feat: added list of addresses in senders-list * feat: implemented address removal in senders-list * fix: test on item removal in senders-list * chore: removed extra dividers * refactor(trustee-list-item): rename file and component, add data-testid, fix typization, change export refactor(trustee-addresses): change DS list component * feat: use SendersListItem component and tests * fix: remove useless component * chore: remove unused store * chore: inline method and code reformat * chore: remove duplicated test * test: parametrize test * chore: remove useless async keyword * feat: switched reading amavis attributes from get-info attrs * chore: renamed settingsObj into currentPrefs * feat: extended array support in differenceObject to amavis related attributes * feat: added support for attributes saving / reading in settings-view * fix: senders list can arrive as a single string from the backend * feat: introduced saveSettings to avoid using the shell-ui editSettings functionality * chore: aligned code to work with shell-ui 7.0.x * chore: completed save settings with account store update * fix: disable save button after successful save * chore(idea): load prettier configuration * refactor: extract updateAccountStore function * refactor: use more specific name for amavis attributes request function * feat: update settings.attrs property after save * refactor: make updateAccountStore void * refactor: properly handle promise status after save with then and catch * wip: updateSettings from shell * wip: updateAccount from shell * refactor(settings): update Shell settings/account store * refactor: update import method for updateSettings and updateAccount - Changed the import method for better readability and maintainability - Ensured compatibility with the existing codebase * refactor: remove unused code when generating API request to modify the identities * refactor(settings): update saveSettings type * refactor(settings): remove no more useful MailMods type * refactor(type): change Shell types import * refactor: copied some types from shell that are not exported anymore and updated UpdateAccount type * feat: added labels for empty table and for address conflict to senders-list * chore: improved style of conflict label in senders-list * build(dep): update Shell dependency * refactor: align tests with the new SoapFault type * refactor: replace board url with context * chore: fixed alignment of text and buttons in senders-list * feat: added label with items vs max in senders-list * chore: fixed alignment of add button in trusted addresses * feat: added check to avoid adding more items than max * refactor: review logic to enable / disable inputs and buttons in senders-list * fix: uncommented code * fix: failing tests due to shell changes * fix: removed duplicated declaration --------- Co-authored-by: Luca Stauble <luca.stauble@zextras.com> Co-authored-by: Matteo Baglini <matteo.baglini@gmail.com> Co-authored-by: gabriele <gabriele.marino@zextras.com> Co-authored-by: Luca Stauble <luca.stauble@gmail.com>
- Loading branch information
1 parent
3b1a09e
commit b777212
Showing
17 changed files
with
849 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
/junit.xml | ||
/coverage | ||
.DS_Store | ||
.tool-versions | ||
.vscode/ | ||
coverage | ||
zextras-carbonio-*.tgz |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Submodule carbonio-ui-commons
updated
2 files
+1 −1 | helpers/email-parser.ts | |
+0 −56 | helpers/tests/email-parser.test.ts |
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,109 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com> | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
import { Identity, updateAccount, updateSettings, xmlSoapFetch } from '@zextras/carbonio-shell-ui'; | ||
import { isArray, map } from 'lodash'; | ||
|
||
import { MAIL_APP_ID } from '../../constants'; | ||
|
||
type AccountSettings = { | ||
[key: string]: string | number | Array<string | number> | undefined; | ||
}; | ||
|
||
type AccountSettingsPrefs = AccountSettings; | ||
type AccountSettingsAttrs = AccountSettings; | ||
type IdentityAttrs = AccountSettings; | ||
|
||
type PropsMods = Record<string, { app: string; value: unknown }>; | ||
type PrefsMods = Record<string, unknown> & AccountSettingsPrefs; | ||
type AttrsMods = Record<string, unknown> & AccountSettingsAttrs; | ||
|
||
type IdentityMods = { | ||
modifyList?: Record<string, { id: string; prefs: Partial<IdentityAttrs> }>; | ||
deleteList?: string[]; | ||
createList?: { prefs: Partial<IdentityAttrs> }[]; | ||
}; | ||
|
||
interface Mods extends Record<string, Record<string, unknown> | undefined> { | ||
props?: PropsMods; | ||
prefs?: PrefsMods; | ||
attrs?: AttrsMods; | ||
identity?: IdentityMods; | ||
} | ||
|
||
export type SaveSettingsResponse = { | ||
CreateIdentityResponse?: { | ||
identity: [Identity]; | ||
}[]; | ||
}; | ||
|
||
function getRequestForProps(props: PropsMods | undefined, appId: string): string { | ||
return props | ||
? `<ModifyPropertiesRequest xmlns="urn:zimbraAccount">${map( | ||
props, | ||
(prop, key) => `<prop name="${key}" zimlet="${prop.app ?? appId}">${prop.value}</prop>` | ||
)}</ModifyPropertiesRequest>` | ||
: ''; | ||
} | ||
|
||
function getRequestForAmavisSendersListAttrs(attrs: AttrsMods | undefined): string { | ||
return attrs?.amavisWhitelistSender || attrs?.amavisBlacklistSender | ||
? `<ModifyWhiteBlackListRequest xmlns="urn:zimbraAccount">${ | ||
attrs?.amavisWhitelistSender && isArray(attrs?.amavisWhitelistSender) | ||
? `<whiteList>${attrs?.amavisWhitelistSender | ||
.map((email) => `<addr>${email}</addr>`) | ||
.join('')}</whiteList>` | ||
: '' | ||
}${ | ||
attrs?.amavisBlacklistSender && isArray(attrs?.amavisBlacklistSender) | ||
? `<blackList>${attrs?.amavisBlacklistSender | ||
.map((email) => `<addr>${email}</addr>`) | ||
.join('')}</blackList>` | ||
: '' | ||
}</ModifyWhiteBlackListRequest>` | ||
: ''; | ||
} | ||
|
||
function getRequestForIdentities(identity: IdentityMods | undefined): string { | ||
return `${ | ||
identity?.modifyList | ||
? map( | ||
identity.modifyList, | ||
(item) => | ||
`<ModifyIdentityRequest xmlns="urn:zimbraAccount" requestId="0"><identity id="${ | ||
item.id | ||
}">${map(item.prefs, (value, key) => `<a name="${key}">${value}</a>`).join( | ||
'' | ||
)}</identity></ModifyIdentityRequest>` | ||
).join('') | ||
: '' | ||
}`; | ||
} | ||
|
||
export const saveSettings = ( | ||
mods: Mods, | ||
appId = MAIL_APP_ID | ||
): Promise<{ | ||
CreateIdentityResponse?: { | ||
identity: [Identity]; | ||
}[]; | ||
}> => | ||
xmlSoapFetch<string, SaveSettingsResponse>( | ||
'Batch', | ||
`<BatchRequest xmlns="urn:zimbra" onerror="stop"> | ||
${getRequestForProps(mods.props, appId)} | ||
${getRequestForAmavisSendersListAttrs(mods.attrs)} | ||
${getRequestForIdentities(mods.identity)} | ||
</BatchRequest>` | ||
).then((resp) => { | ||
updateSettings(mods); | ||
if (mods.identity) { | ||
updateAccount( | ||
mods.identity, | ||
resp.CreateIdentityResponse?.map((item) => item?.identity[0]) ?? [] | ||
); | ||
} | ||
return resp; | ||
}); |
Oops, something went wrong.