Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
3c1882f5
Commit
3c1882f5
authored
Jun 20, 2018
by
Juorder Gonzalez quiñonez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix revoke admins, now its working, new request for search admins for specific domain
parent
40ac230a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
46 deletions
+76
-46
domain_admin_list.jsx
src/components/domain/domain_admin_list.jsx
+31
-46
client.jsx
src/utils/client.jsx
+45
-0
No files found.
src/components/domain/domain_admin_list.jsx
View file @
3c1882f5
...
...
@@ -37,38 +37,27 @@ export default class DomainAdminList extends React.Component {
};
}
getAdmins
(
getAllFromAPI
)
{
const
domain
=
this
.
props
.
domain
;
const
getStuffFromAPI
=
getAllFromAPI
||
false
;
if
(
!
getStuffFromAPI
)
{
return
domain
.
getAdmins
((
err
,
data
)
=>
{
const
admins
=
data
.
account
||
[];
if
(
this
.
isStoreEnabled
)
{
DomainStore
.
setAdmins
(
domain
,
admins
);
}
this
.
setState
({
admins
});
});
getAdmins
()
{
const
{
domain
}
=
this
.
props
;
if
(
domain
)
{
return
Client
.
getAdminByDomainName
(
domain
.
name
,
'givenName, displayName, sn, cn'
).
then
(({
account
:
admins
})
=>
{
this
.
setState
({
admins
});
}).
catch
();
}
return
Client
.
getDomain
(
domain
.
name
,
(
data
)
=>
{
return
data
.
getAdmins
((
err
,
res
)
=>
{
const
admins
=
res
.
account
||
[];
if
(
this
.
isStoreEnabled
)
{
DomainStore
.
setAdmins
(
domain
,
admins
);
}
return
this
.
setState
({
admins
});
});
Client
.
getAdminByDomainName
(
data
.
name
).
then
(({
account
:
admins
})
=>
{
this
.
setState
({
admins
});
}).
catch
();
},
(
err
)
=>
{
return
err
;
});
}
handleRemoveAdmin
(
e
,
admin
)
{
const
plans
=
Object
.
keys
(
window
.
manager_config
.
plans
).
filter
((
plan
)
=>
{
return
window
.
manager_config
.
plans
[
plan
].
forRights
;
});
e
.
preventDefault
();
const
response
=
{
title
:
'Se ha borrado con éxito'
,
type
:
'success'
...
...
@@ -86,28 +75,22 @@ export default class DomainAdminList extends React.Component {
},
(
isDeleted
)
=>
{
if
(
isDeleted
)
{
this
.
props
.
domain
.
removeAdmin
(
admin
.
name
,
plans
,
(
error
)
=>
{
if
(
error
)
{
response
.
title
=
'Ha ocurrido un error.'
;
response
.
type
=
'error'
;
response
.
confirmButtonText
=
'Intentar de nuevo'
;
response
.
confirmButtonColor
=
'#DD6B55'
;
return
sweetAlert
(
response
);
}
if
(
this
.
isStoreEnabled
)
{
DomainStore
.
removeAdmin
(
admin
.
id
);
}
else
{
DomainStore
.
emitAdminsChange
();
}
return
sweetAlert
(
response
);
}
);
const
{
id
}
=
admin
;
const
{
admins
}
=
this
.
state
;
Client
.
revokeAdmin
(
id
).
then
(()
=>
{
// let's remove the admin for state to avoid search it into api
const
nextAdmins
=
admins
.
filter
((
admin
)
=>
admin
.
id
!==
id
);
this
.
setState
({
admins
:
nextAdmins
});
return
sweetAlert
(
response
);
}).
catch
(()
=>
{
response
.
title
=
'Ha ocurrido un error.'
;
response
.
type
=
'error'
;
response
.
confirmButtonText
=
'Intentar de nuevo'
;
response
.
confirmButtonColor
=
'#DD6B55'
;
return
sweetAlert
(
response
);
});
}
}
);
...
...
@@ -116,10 +99,10 @@ export default class DomainAdminList extends React.Component {
onAdminsChange
()
{
const
admins
=
this
.
isStoreEnabled
?
DomainStore
.
getAdmins
(
this
.
props
.
domain
)
:
null
;
if
(
!
admins
)
{
return
this
.
getAdmins
(
true
);
return
this
.
getAdmins
();
}
return
this
.
setState
({
admins
});
return
this
.
setState
({
admins
});
}
componentDidMount
()
{
...
...
@@ -129,9 +112,11 @@ export default class DomainAdminList extends React.Component {
this
.
getAdmins
();
}
}
componentWillUnmount
()
{
DomainStore
.
removeAdminsChangeListener
(
this
.
onAdminsChange
);
}
render
()
{
let
btnAddNewAdmin
=
null
;
if
(
!
this
.
state
.
admins
)
{
...
...
src/utils/client.jsx
View file @
3c1882f5
...
...
@@ -307,6 +307,51 @@ export function getDomain(id, success, error) {
);
}
export
function
getAdminByDomainName
(
domain
,
attributes
)
{
const
searchObject
=
{
query
:
'(|(zimbraIsDelegatedAdminAccount=TRUE)(zimbraIsAdminAccount=TRUE))'
,
types
:
'accounts'
,
maxResults
:
0
,
attrs
:
'zimbraIsDelegatedAdminAccount,zimbraIsAdminAccount'
,
domain
};
if
(
attributes
&&
typeof
attributes
===
'string'
)
{
let
_attributes
=
searchObject
.
attrs
.
split
(
','
);
const
customAttributes
=
attributes
.
split
(
','
).
map
((
attribute
)
=>
attribute
.
trim
());
_attributes
=
[...
_attributes
,
...
customAttributes
];
searchObject
.
attrs
=
_attributes
.
join
(
','
);
}
return
new
Promise
((
resolve
,
reject
)
=>
{
initZimbra
().
then
(
(
zimbra
)
=>
{
zimbra
.
directorySearch
(
searchObject
,
(
err
,
data
)
=>
{
if
(
err
)
{
const
e
=
handleError
(
'getAdminByDomainName'
,
err
);
return
reject
(
e
);
}
return
resolve
(
data
);
});
},
(
err
)
=>
{
const
e
=
handleError
(
'getAdminByDomainName'
,
err
);
return
reject
(
e
);
}
);
});
}
export
function
revokeAdmin
(
zimbraId
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
modifyAccount
(
zimbraId
,
{
zimbraIsDelegatedAdminAccount
:
'FALSE'
,
zimbraIsAdminAccount
:
'FALSE'
},
resolve
,
reject
);
});
}
export
function
createDomain
(
domain
,
success
,
error
)
{
initZimbra
().
then
(
(
zimbra
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment