Commit afa7d80e authored by Viacheslav Pavlov's avatar Viacheslav Pavlov

Merge branch '689-extend-user-account' into 'master'

Extend user account

Closes #689

See merge request genesys-pgr/genesys-ui!672
parents 77591d40 24d8fa92
......@@ -2631,6 +2631,7 @@
"lock": "Lock",
"disable": "Disable",
"enable": "Enable",
"extend": "Extend",
"sendEmail": "Send validation E-mail"
},
"edit": {
......
......@@ -20,6 +20,7 @@ const URL_UNLOCK_ACCOUNT = UrlTemplate.parse(`/api/v1/user/u/{uuid}/unlock`);
const URL_ARCHIVE_ACCOUNT = UrlTemplate.parse(`/api/v1/user/u/{uuid}/archive`);
const URL_SEND_EMAIL = UrlTemplate.parse(`/api/v1/user/u/{uuid}/email-verification`);
const URL_UPDATE_USER = `/api/v1/user/user`;
const URL_EXTEND_ACCOUNT = UrlTemplate.parse('/api/v1/user/u/{uuid}/extend');
export class UserService {
......@@ -271,4 +272,22 @@ export class UserService {
...content,
}).then(({ data }) => data as User);
}
/**
* extendAccount at /api/v1/user/u/{uuid}/extend
*
* @param uuid uuid
*/
public static extendAccount(uuid: string, xhrConfig?): Promise<User> {
const apiUrl = URL_EXTEND_ACCOUNT.expand({uuid});
const content = { /* No content in request body */ };
return axiosBackend({
...xhrConfig,
url: apiUrl,
method: 'POST',
...content,
}).then(({ data }) => data as User);
}
}
......@@ -31,6 +31,7 @@ const apiArchiveAccount = createPureApiCaller(UserService.archiveAccount);
const apiSendEmail = createPureApiCaller(UserService.sendEmail);
const apiUpdateUser = createApiCaller(UserService.updateUser, ADMIN_RECEIVE_USER);
const apiListUsers = createApiCaller(UserService.listUsers, ADMIN_APPEND_USERS);
const apiExtendAccount = createApiCaller(UserService.extendAccount, ADMIN_RECEIVE_USER);
const apiListOauthClients = createApiCaller(OAuthManagementService.listClients, ADMIN_APPEND_OAUTH_CLIENTS);
const apiLoadOauthClientDetails = createApiCaller(OAuthManagementService.clientDetailsInfo, ADMIN_RECEIVE_OAUTH_CLIENT_DETAILS);
......@@ -69,6 +70,11 @@ export const deleteAccount = (uuid: string) => (dispatch) => {
});
};
export const extendAccount = (uuid: string) => (dispatch) => {
return dispatch(apiExtendAccount(uuid))
.then(() => dispatch(showSnackbar(`Account is extended`)));
};
export const sendVerificationEmail = (uuid: string) => (dispatch) => {
return dispatch(apiSendEmail(uuid))
.then(() => dispatch(showSnackbar(`Email is sent`)));
......
......@@ -83,6 +83,7 @@
"lock": "Lock",
"disable": "Disable",
"enable": "Enable",
"extend": "Extend",
"sendEmail": "Send validation E-mail"
},
"edit": {
......
......@@ -4,7 +4,7 @@ import {bindActionCreators} from 'redux';
import { WithTranslation, withTranslation } from 'react-i18next';
// Actions
import {deleteAccount, enableAccount, loadUser, lockAccount, sendVerificationEmail} from 'user/actions/admin';
import {deleteAccount, enableAccount, loadUser, lockAccount, sendVerificationEmail, extendAccount} from 'user/actions/admin';
import navigateTo from 'actions/navigation';
// Models
......@@ -30,6 +30,7 @@ interface IDisplayPageProps extends React.ClassAttributes<any>, WithTranslation
enableAccount: (uuid: string, enable?: boolean) => void;
lockAccount: (uuid: string, lock?: boolean) => void;
deleteAccount: (uuid: string) => void;
extendAccount: (uuid: string) => void;
sendVerificationEmail: (uuid: string) => void;
loadUser: (uuid: string) => void;
navigateTo: (path: string) => void;
......@@ -67,7 +68,7 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
public render() {
const {user, loading, enableAccount, lockAccount, sendVerificationEmail, navigateTo, t} = this.props;
const {user, loading, enableAccount, lockAccount, sendVerificationEmail, extendAccount, navigateTo, t} = this.props;
return loading ? (<Loading/>) : (
<div>
......@@ -81,6 +82,7 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
{ user.accountLocked ? <ActionButton title="user.admin.p.display.unlock" action={ () => lockAccount(user.uuid, false) }/>
: <ActionButton title={ t('user.admin.p.display.lock') } action={ () => lockAccount(user.uuid) }/>
}
<ActionButton title={ t('user.admin.p.display.extend') } action={ () => extendAccount(user.uuid) }/>
{ user.active ? <ActionButton title={ t('user.admin.p.display.disable') } action={ () => enableAccount(user.uuid, false) }/>
: <ActionButton title={ t('user.admin.p.display.enable') } action={ () => enableAccount(user.uuid) }/>
}
......@@ -111,6 +113,7 @@ const mapDispatchToProps = (dispatch) => bindActionCreators({
enableAccount,
lockAccount,
deleteAccount,
extendAccount,
sendVerificationEmail,
navigateTo,
}, dispatch);
......
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