Commit 7b235e23 authored by Nikolai R Kristiansen's avatar Nikolai R Kristiansen

馃悰 Fix some bugs

parent bb18429d
......@@ -14,6 +14,7 @@ def deploy(c):
with c.cd(project_path), c.prefix('source {}/venv/bin/activate'.format(project_path)):
c.run('git pull') # Get source
c.run('pip install -U pip')
c.run('pip install -r requirements.txt') # install deps in virtualenv
with c.cd('mailadmin/static/mailadmin'): # install and compile frontend deps
c.run('npm i')
......
......@@ -71,7 +71,7 @@ const AliasListCreate = ({ domain, lists, orgUnits }) => {
<span className="input-group-text">{`@${domain.name}`}</span>
</div>
</div>
<EmailsTextarea source={listName} domainId={domain.id} create={shouldCreate} />
<EmailsTextarea source={listName} domainId={domain.id} create={shouldCreate} setName={setName} />
</div>
</div>
{/* <div className="new-list-result"></div> */}
......
......@@ -5,7 +5,7 @@ import { parseEmails, notify } from '../utils';
import { CREATE_ALIASES_MUTATION } from '../mutations';
import { GET_ALIASES } from '../queries';
const EmailsTextarea = ({ source, domainId, create = false }) => {
const EmailsTextarea = ({ source, domainId, create = false, setName = null }) => {
const [rawAliases, setRawAliases] = useState('');
const [createAliases] = useMutation(CREATE_ALIASES_MUTATION);
......@@ -19,6 +19,9 @@ const EmailsTextarea = ({ source, domainId, create = false }) => {
variables: { input },
update: (cache, { data }) => {
setRawAliases('');
if (setName) {
setName('');
}
const { createAliasesResponse: newAliases } = data;
const { aliases: aliasesFromCache } = cache.readQuery({ query: GET_ALIASES });
cache.writeQuery({
......@@ -35,7 +38,7 @@ const EmailsTextarea = ({ source, domainId, create = false }) => {
console.error(errors);
}
},
[aliases, create, createAliases, domainId, source]
[aliases, create, createAliases, domainId, setName, source]
);
return (
<>
......
......@@ -27,7 +27,8 @@ const MainArea = ({ query, selectedOrgUnit, orgUnits }) => {
'source'
);
const listPrefixes = selectedOrgUnit && orgUnits.find(({ id }) => id === selectedOrgUnit).prefixesRegex;
const selectedOrgUnitObj = selectedOrgUnit && orgUnits.find(({ id }) => id === selectedOrgUnit);
const listPrefixes = selectedOrgUnitObj && selectedOrgUnitObj.prefixesRegex;
const listRegex = listPrefixes && new RegExp(listPrefixes);
return (
......@@ -42,7 +43,7 @@ const MainArea = ({ query, selectedOrgUnit, orgUnits }) => {
}
// Only render lists which matches the org units prefixes
if (listRegex && !listRegex.test(list)) {
return null; // FIXME: use styles to show/hide ?
return null;
}
return <AliasList key={list} list={list} aliases={aliases} domain={domain} query={query} />;
})}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment