Skip to content

Commit

Permalink
Merge pull request #68 from Telios-org/beta
Browse files Browse the repository at this point in the history
Merge beta into master
  • Loading branch information
hexadecible authored Jul 5, 2022
2 parents 9542139 + 2493f3f commit c328e9b
Show file tree
Hide file tree
Showing 24 changed files with 1,576 additions and 810 deletions.
28 changes: 13 additions & 15 deletions app/composer_window/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ const Composer = (props: Props) => {
const [prefillRecipients, setPrefillRecipients] = useState(
prefillRecipientsTemplate
);
const [fromAddress, setFromAddress] = useState<{
address: string;
name: string;
} | null>(null);
const [fromAddress, setFromAddress] = useState<
| {
address: string;
name: string;
}[]
| null
>(null);
const [fromDataSet, setFromDataSet] = useState<
{ address: string; name: string }[]
>([]);
Expand Down Expand Up @@ -197,9 +200,9 @@ const Composer = (props: Props) => {
const data = assembleFromDataSet(mb, namespaces, aliases);
setFromDataSet(data);
if (draft.from.length === 1) {
setFromAddress(draft.from[0]);
setFromAddress(draft.from);
} else {
setFromAddress(data[0]);
setFromAddress([data[0]]);
}

setPrefillRecipients(rcp.ui);
Expand Down Expand Up @@ -251,9 +254,9 @@ const Composer = (props: Props) => {
);
setFromDataSet(data);
if (draft.from.length === 1) {
setFromAddress(draft.from[0]);
setFromAddress(draft.from);
} else {
setFromAddress(data[0]);
setFromAddress([data[0]]);
}
setPrefillRecipients(rcp.ui);
setWindowId(windowID);
Expand Down Expand Up @@ -363,12 +366,7 @@ const Composer = (props: Props) => {
to: toArr,
cc: ccArr,
bcc: bccArr,
from: [
{
address: mailbox.address,
name: mailbox.name ? mailbox.name : mailbox.address
}
]
from: [fromAddress]
};

console.log('DRAFT', draft);
Expand Down Expand Up @@ -480,7 +478,7 @@ const Composer = (props: Props) => {
)}
<MessageInputs
fromDataSet={fromDataSet}
fromAddress={fromAddress}
fromAddress={Array.isArray(fromAddress) ? fromAddress[0] : fromAddress}
onFromChange={onFromChange}
onUpdateRecipients={onUpdateRecipients}
defaultRecipients={prefillRecipients}
Expand Down
3 changes: 2 additions & 1 deletion app/composer_window/components/FromInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import MailService from '../../services/mail.service';

// HELPER
import { arrayToObject } from '../../utils/reducer.util';
import sortingHat from '../../utils/helpers/sort';

function classNames(...classes) {
return classes.filter(Boolean).join(' ');
}

type Props = {
fromDataSet: { address: string; name: string }[];
fromAddress: { address: string; name: string };
fromAddress: { address: string; name: string } | null;
onFromChange: (obj: { address: string; name: string }) => void;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FromInput from '../FromInput';

type Props = {
fromDataSet: { address: string; name: string }[];
fromAddress: { address: string; name: string };
fromAddress: { address: string; name: string } | null;
onFromChange: (obj: { address: string; name: string }) => void;
onUpdateRecipients: (recipients: Recipients) => void;
setToRef: (node) => void;
Expand Down
8 changes: 8 additions & 0 deletions app/ipc/Window.ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { ipcMain, nativeTheme, dialog, BrowserView } = require('electron');
const path = require('path');
const { emailTransform, assembleFromDataSet } = require('../utils/draft.utils');
const store = require('../Store');
const { Console } = require('console');

module.exports = (windowManager, createMainWindow, createLoginWindow) => {
const saveDraft = payload => {
Expand Down Expand Up @@ -198,10 +199,17 @@ module.exports = (windowManager, createMainWindow, createLoginWindow) => {
async (event, content) => {
const { message, mailbox, namespaces, aliases, editorAction } = content;

console.log(content);

const newDraft = emailTransform(message, editorAction, true);

console.log(newDraft);


const data = assembleFromDataSet(mailbox, namespaces, aliases);

console.log(data);

let filteredArray = [];
if (message['toJSON']) {
filteredArray = data.filter(value =>
Expand Down
40 changes: 29 additions & 11 deletions app/main_window/actions/mailbox/aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const aliasRegistrationFailure = (error: string, alias: string) => {
};

export const registerAlias = (
namespaceName: string,
namespaceName: string | null,
domain: string,
address: string,
description: string,
Expand Down Expand Up @@ -193,7 +193,7 @@ export const aliasUpdateFailure = (
};

export const updateAlias = (payload: {
namespaceName: string;
namespaceName: string | null;
domain: string;
address: string;
description: string;
Expand All @@ -210,7 +210,12 @@ export const updateAlias = (payload: {
disabled
} = payload;
dispatch(
startAliasUpdate(`${namespaceName}#${address}@${domain}`, payload)
startAliasUpdate(
`${
namespaceName === null ? '' : `${namespaceName}#`
}${address}@${domain}`,
payload
)
);
try {
await Mail.updateAliasAddress({
Expand All @@ -225,7 +230,9 @@ export const updateAlias = (payload: {
dispatch(
aliasUpdateFailure(
error,
`${namespaceName}#${address}@${domain}`,
`${
namespaceName === null ? '' : `${namespaceName}#`
}${address}@${domain}`,
payload
)
);
Expand Down Expand Up @@ -286,7 +293,12 @@ export const removeAlias = (payload: {
return async (dispatch: Dispatch, getState: GetState) => {
const { namespaceName, domain, address } = payload;
dispatch(
startAliasRemove(`${namespaceName}#${address}@${domain}`, payload)
startAliasRemove(
`${
namespaceName === null ? '' : `${namespaceName}#`
}${address}@${domain}`,
payload
)
);

const {
Expand Down Expand Up @@ -319,7 +331,10 @@ export const removeAlias = (payload: {

const aliasMsg = messages
.filter(msg => {
return msg.aliasId === `${namespaceName}#${address}`;
return (
msg.aliasId ===
`${namespaceName === null ? '' : `${namespaceName}#`}${address}`
);
})
.map(msg => {
return {
Expand Down Expand Up @@ -360,7 +375,13 @@ export const removeAlias = (payload: {
};
}

dispatch(aliasRemoveSuccess({ aliasId: `${namespaceName}#${address}` }));
dispatch(
aliasRemoveSuccess({
aliasId: `${
namespaceName === null ? '' : `${namespaceName}#`
}${address}`
})
);
return { status: 'removed', success: true };
};
};
Expand Down Expand Up @@ -481,10 +502,7 @@ export const aliasSelectionFlowFailure = (error: Error) => {
};
};

export const aliasSelection = (
aliasIndex: number,
searchList: any[] = []
) => {
export const aliasSelection = (aliasIndex: number, searchList: any[] = []) => {
return async (dispatch: Dispatch, getState: GetState) => {
dispatch(aliasSelectionFlow(aliasIndex));

Expand Down
19 changes: 15 additions & 4 deletions app/main_window/components/Mail/Aliases/AliasesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@ const AliasesPage = () => {
const [saveSucceeded, setSaveSucceeded] = useState(true);
const [isOpen, setIsOpen] = useState(false);

const closeModal = (isSuccess: boolean, message: string) => {
setIsOpen(false);

const callToaster = (isSuccess: boolean, message: string) => {
if (isSuccess) {
setSaveSucceeded(true);
setNotifMessage(message);
setShowNotification(true);
} else {
setSaveSucceeded(false);
setNotifMessage(message);
setShowNotification(true);
}
};

const closeModal = (isSuccess: boolean, message: string) => {
setIsOpen(false);
callToaster(isSuccess, message);
};

const openModal = (route: string) => {
setModal(route);
setIsOpen(true);
Expand Down Expand Up @@ -80,7 +87,11 @@ const AliasesPage = () => {
</div>
</div>
<div className="py-2 flex flex-col grow relative">
<AliasManagement openModalRoute={openModal} aliasSelection={setAliasSelection}/>
<AliasManagement
openModalRoute={openModal}
aliasSelection={setAliasSelection}
callToaster={callToaster}
/>
<Transition appear show={isOpen} as={Fragment}>
<Dialog
as="div"
Expand Down
10 changes: 7 additions & 3 deletions app/main_window/components/Mail/Aliases/Routes/AliasDelete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ const AliasDelete = forwardRef((props: Props, ref) => {
<div className="mt-2 text-sm text-gray-500">
<p className="leading-relaxed">
<b>
{` ${deleteObj?.namespaceKey}#`}
{` ${
deleteObj?.namespaceKey === null
? ''
: `${deleteObj?.namespaceKey}+`
}`}
<span className="text-purple-600">{deleteObj?.name}</span>
{`@${domain} `}
</b>
will be removed from your list of aliases and its incoming
traffic blocked.
will be removed from your list of aliases and its incoming traffic
blocked.
</p>
{/* <p className="text-xs">
You can recreate this alias only through the app (as opposed to
Expand Down
36 changes: 19 additions & 17 deletions app/main_window/components/Mail/Aliases/Routes/AliasEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const AliasEdit = forwardRef((props: Props, ref) => {
errors
} = useForm({
initialValues: {
namespace: '',
namespace: null,
alias: '',
description: '',
fwdAddresses: []
Expand All @@ -71,6 +71,15 @@ const AliasEdit = forwardRef((props: Props, ref) => {
setSubmitError('');
setLoader(true);

console.log({
namespaceName: namespace,
domain,
address: alias,
description,
fwdAddresses: fwd,
disabled: a.disabled
});

const res = await dispatch(
updateAlias({
namespaceName: namespace,
Expand Down Expand Up @@ -128,8 +137,8 @@ const AliasEdit = forwardRef((props: Props, ref) => {
</Dialog.Title>
<div className="px-6">
<div className="text-sm">
<p className="text-sm text-center font-bold bg-coolGray-100 shadow-sm border border-coolGray-200 py-2 my-3 rounded max-w-sm mx-auto">
{`${form.namespace.length === 0 ? 'namespace' : form.namespace}+`}
<p className="text-sm text-center font-bold bg-coolGray-100 shadow-sm border border-coolGray-200 py-2 my-3 rounded max-w-md mx-auto">
{`${form.namespace === null ? '' : `${form.namespace}+`}`}
<span className="text-purple-600">
{form.alias.length === 0 ? 'alias' : form.alias}
</span>
Expand All @@ -143,7 +152,7 @@ const AliasEdit = forwardRef((props: Props, ref) => {
</span>
</div> */}
</div>
<form className="max-w-sm m-auto">
<form className="max-w-md m-auto">
<div className="mt-6">
<Combobox
value={form.fwdAddresses}
Expand Down Expand Up @@ -231,16 +240,12 @@ const AliasEdit = forwardRef((props: Props, ref) => {
className={({ active }) => {
return classNames(
'relative cursor-default select-none py-2 pl-3 pr-9 focus:outline-none',
active ? 'bg-sky-600 text-white' : 'text-gray-900'
active ? 'bg-sky-500 text-white' : 'text-gray-900'
);
}}
>
Add
<b>
"{queryFwd}
"
</b>
{' '}
Add{' '}
<b>"{queryFwd}"</b>{' '}
</Combobox.Option>
)}
{filteredForwards.map(fwd => (
Expand All @@ -250,7 +255,7 @@ const AliasEdit = forwardRef((props: Props, ref) => {
className={({ active }) => {
return classNames(
'relative cursor-default select-none py-2 pl-3 pr-9 focus:outline-none',
active ? 'bg-sky-600 text-white' : 'text-gray-900'
active ? 'bg-sky-500 text-white' : 'text-gray-900'
);
}}
>
Expand Down Expand Up @@ -308,19 +313,16 @@ const AliasEdit = forwardRef((props: Props, ref) => {
value={form.description}
onChange={handleChange('description')}
className="form-textarea shadow-sm focus:ring-purple-500 focus:border-purple-500 block w-full sm:text-sm border-gray-300 rounded-md"
defaultValue=""
/>
</div>
<div className="text-xs text-red-500 absolute -bottom-7 text-center w-full">
{submitError.length > 0 && submitError}
</div>
</div>
<div className="text-xs text-gray-400 pt-3 mt-6">
<b>Note:</b>
{' '}
The + separator is interchangeable with - or # in case a
<b>Note:</b> The + separator is interchangeable with - or # in case a
website doesn't accept certain characters
</div>
</div>
</form>
<div className="flex justify-end py-3 bg-gray-50 text-right px-6 border-t border-gray-300 mt-4">
<button
Expand Down
Loading

0 comments on commit c328e9b

Please sign in to comment.