Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
fix(account-actions): Remove "lock/enable account" feature from Accou…
Browse files Browse the repository at this point in the history
…nts (closes #887) (#890)

* feat(account-actions): Remove "lock/enable account" feature from Accounts

* feat(account-actions): Remove "lock/enable account" feature from Accounts - translate error
  • Loading branch information
HeyRoach authored Jan 22, 2018
1 parent 2481a89 commit 375435b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Account } from '../../shared/models/account.model';
(onAccountDelete)="onAccountDelete($event)"
(onAccountDisable)="onAccountDisable($event)"
(onAccountEnable)="onAccountEnable($event)"
(onAccountLock)="onAccountLock($event)"
>
</cs-account-actions>`,
})
Expand All @@ -32,10 +31,6 @@ export class AccountActionsContainerComponent {
) {
}

public onAccountLock(account: Account): void {
this.store.dispatch(new accountActions.LockAccountRequest(account));
}

public onAccountEnable(account: Account): void {
this.store.dispatch(new accountActions.EnableAccountRequest(account));
}
Expand Down
8 changes: 0 additions & 8 deletions src/app/reducers/accounts/redux/accounts.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const ACCOUNT_CREATE_ERROR = '[ACCOUNTS] CREATE_ERROR';

export const DISABLE_ACCOUNT = '[ACCOUNTS] DISABLE_ACCOUNT';
export const ENABLE_ACCOUNT = '[ACCOUNTS] ENABLE_ACCOUNT';
export const LOCK_ACCOUNT = '[ACCOUNTS] LOCK_ACCOUNT';
export const DELETE_ACCOUNT = '[ACCOUNTS] DELETE_ACCOUNT';
export const ACCOUNT_DELETE_SUCCESS = '[ACCOUNTS] ACCOUNT_DELETE_SUCCESS';

Expand Down Expand Up @@ -107,13 +106,6 @@ export class DisableAccountRequest implements Action {
}
}

export class LockAccountRequest implements Action {
readonly type = LOCK_ACCOUNT;

constructor(public payload: Account) {
}
}

export class DeleteAccountRequest implements Action {
readonly type = DELETE_ACCOUNT;

Expand Down
16 changes: 1 addition & 15 deletions src/app/reducers/accounts/redux/accounts.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,10 @@ export class AccountsEffects {
});
});

@Effect()
lockAccount$: Observable<Action> = this.actions$
.ofType(accountActions.LOCK_ACCOUNT)
.switchMap((action: accountActions.LockAccountRequest) => {
return this.accountService.lockAccount(action.payload)
.switchMap(job => {
return this.asyncJobService.queryJob(job, 'account', Account);
})
.map(updatedAccount => new accountActions.UpdateAccount(updatedAccount))
.catch((error: Error) => {
return Observable.of(new accountActions.AccountUpdateError(error));
});
});

@Effect()
deleteAccount$: Observable<Action> = this.actions$
.ofType(accountActions.DELETE_ACCOUNT)
.switchMap((action: accountActions.LockAccountRequest) => {
.switchMap((action: accountActions.DeleteAccountRequest) => {
return this.accountService.removeAccount(action.payload)
.switchMap(job => {
return this.asyncJobService.queryJob(job, 'account', Account);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { DialogService } from '../../../dialog/dialog-service/dialog.service';
})
export class AccountActionsComponent {
@Input() public account: Account;
@Output() public onAccountLock: EventEmitter<Account> = new EventEmitter<Account>();
@Output() public onAccountEnable: EventEmitter<Account> = new EventEmitter<Account>();
@Output() public onAccountDisable: EventEmitter<Account> = new EventEmitter<Account>();
@Output() public onAccountDelete: EventEmitter<Account> = new EventEmitter<Account>();
Expand All @@ -43,10 +42,6 @@ export class AccountActionsComponent {
.filter(res => Boolean(res))
.subscribe(() => {
switch (action.command) {
case 'lock': {
this.onAccountLock.emit(account);
break;
}
case 'enable': {
this.onAccountEnable.emit(account);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,10 @@ const AccountEnableAction = {
canActivate: (account: Account) => account.state !== 'enabled'
};

const AccountLockAction = {
name: 'ACCOUNT_ACTION.LOCK',
command: 'lock',
icon: 'block',
confirmMessage: 'DIALOG_MESSAGES.ACCOUNT.CONFIRM_LOCK',
canActivate: (account: Account) => account.state !== 'locked'
};

export class AccountActionsService {
public actions: Array<Action<Account>> = [
AccountDisableAction,
AccountEnableAction,
AccountLockAction,
AccountDeleteAction
];
}
5 changes: 5 additions & 0 deletions src/app/shared/services/error.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export class ErrorService {
{
regex: /maxSnaps exceeds limit: (\d+) for interval type: hourly/,
translation: 'ERRORS.SNAPSHOT_POLICIES.HOURLY_TURN_OFF'
},
{
regex:
/User (.*) .*or their account.* in domain (.*) is disabled\/locked. Please contact the administrator./,
translation: 'ERRORS.AUTH.DISABLED'
}
];

Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"AUTH": {
"INCORRECT_USERNAME": "Incorrect username",
"INCORRECT_PASSWORD": "Incorrect password",
"INCORRECT_DOMAIN": "Unable to find domain {{ val1 }}"
"INCORRECT_DOMAIN": "Unable to find domain {{ val1 }}",
"DISABLED": "User {{ val1 }} (or their account) {{ val2 }} is disabled. Please contact the administrator."
},
"ISO": {
"VMS_IN_USE": "Unable to delete the ISO as it's used by the following VMs:<br>{{ vms }}"
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"AUTH": {
"INCORRECT_USERNAME": "Неверное имя пользователя",
"INCORRECT_PASSWORD": "Неверный пароль",
"INCORRECT_DOMAIN": "Не удалось найти домен {{ val1 }}"
"INCORRECT_DOMAIN": "Не удалось найти домен {{ val1 }}",
"DISABLED": "Пользователь {{ val1 }} (или его акаунт) {{ val2 }} деактивирован. Пожалуйста свяжитесь с администратором."
},
"ISO": {
"VMS_IN_USE": "Невозможно удалить ISO файл, так как он используется следующими машинами:<br>{{ vms }}"
Expand Down

0 comments on commit 375435b

Please sign in to comment.