mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-19 17:14:45 +00:00
use instant translation (#382)
* use instant translation * update code and tests * fix tests
This commit is contained in:
parent
20ad62d035
commit
aca73e2ff2
@ -108,11 +108,10 @@ export class NodeCopyDirective {
|
|||||||
const undo = (numberOfCopiedItems > 0) ? this.translation.instant('APP.ACTIONS.UNDO') : '';
|
const undo = (numberOfCopiedItems > 0) ? this.translation.instant('APP.ACTIONS.UNDO') : '';
|
||||||
const withUndo = (numberOfCopiedItems > 0) ? '_WITH_UNDO' : '';
|
const withUndo = (numberOfCopiedItems > 0) ? '_WITH_UNDO' : '';
|
||||||
|
|
||||||
this.translation.get(i18nMessageString, { success: numberOfCopiedItems, failed: failedItems }).subscribe(message => {
|
const message = this.translation.instant(i18nMessageString, { success: numberOfCopiedItems, failed: failedItems });
|
||||||
this.notification.openSnackMessageAction(message, undo, NodeActionsService[`SNACK_MESSAGE_DURATION${withUndo}`])
|
this.notification.openSnackMessageAction(message, undo, NodeActionsService[`SNACK_MESSAGE_DURATION${withUndo}`])
|
||||||
.onAction()
|
.onAction()
|
||||||
.subscribe(() => this.deleteCopy(newItems));
|
.subscribe(() => this.deleteCopy(newItems));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private deleteCopy(nodes: MinimalNodeEntity[]) {
|
private deleteCopy(nodes: MinimalNodeEntity[]) {
|
||||||
@ -138,9 +137,8 @@ export class NodeCopyDirective {
|
|||||||
i18nMessageString = 'APP.MESSAGES.ERRORS.PERMISSION';
|
i18nMessageString = 'APP.MESSAGES.ERRORS.PERMISSION';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.translation.get(i18nMessageString).subscribe(message => {
|
const message = this.translation.instant(i18nMessageString);
|
||||||
this.notification.openSnackMessageAction(message, '', NodeActionsService.SNACK_MESSAGE_DURATION);
|
this.notification.openSnackMessageAction(message, '', NodeActionsService.SNACK_MESSAGE_DURATION);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -65,24 +65,21 @@ export class NodeDeleteDirective {
|
|||||||
.subscribe(
|
.subscribe(
|
||||||
(data) => {
|
(data) => {
|
||||||
const processedData = this.processStatus(data);
|
const processedData = this.processStatus(data);
|
||||||
|
const message = this.getDeleteMessage(processedData);
|
||||||
|
const withUndo = processedData.someSucceeded ? this.translation.instant('APP.ACTIONS.UNDO') : '';
|
||||||
|
|
||||||
this.getDeleteMessage(processedData)
|
this.notification.openSnackMessageAction(message, withUndo, NodeDeleteDirective.DELETE_MESSAGE_DURATION)
|
||||||
.subscribe((message) => {
|
.onAction()
|
||||||
const withUndo = processedData.someSucceeded ? this.translation.translate.instant('APP.ACTIONS.UNDO') : '';
|
.subscribe(() => this.restore(processedData.success));
|
||||||
|
|
||||||
this.notification.openSnackMessageAction(message, withUndo, NodeDeleteDirective.DELETE_MESSAGE_DURATION)
|
if (processedData.someSucceeded) {
|
||||||
.onAction()
|
this.content.nodeDeleted.next(null);
|
||||||
.subscribe(() => this.restore(processedData.success));
|
}
|
||||||
|
|
||||||
if (processedData.someSucceeded) {
|
|
||||||
this.content.nodeDeleted.next(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private restore(items): void {
|
private restore(items: any[]): void {
|
||||||
const batch = [];
|
const batch = [];
|
||||||
|
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
@ -95,12 +92,10 @@ export class NodeDeleteDirective {
|
|||||||
const processedData = this.processStatus(data);
|
const processedData = this.processStatus(data);
|
||||||
|
|
||||||
if (processedData.failed.length) {
|
if (processedData.failed.length) {
|
||||||
this.getRestoreMessage(processedData)
|
const message = this.getRestoreMessage(processedData);
|
||||||
.subscribe((message) => {
|
this.notification.openSnackMessageAction(
|
||||||
this.notification.openSnackMessageAction(
|
message, '' , NodeDeleteDirective.RESTORE_MESSAGE_DURATION
|
||||||
message, '' , NodeDeleteDirective.RESTORE_MESSAGE_DURATION
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processedData.someSucceeded) {
|
if (processedData.someSucceeded) {
|
||||||
@ -178,39 +173,39 @@ export class NodeDeleteDirective {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRestoreMessage(status): Observable<string> {
|
private getRestoreMessage(status): string {
|
||||||
if (status.someFailed && !status.oneFailed) {
|
if (status.someFailed && !status.oneFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.NODE_RESTORE_PLURAL',
|
'APP.MESSAGES.ERRORS.NODE_RESTORE_PLURAL',
|
||||||
{ number: status.failed.length }
|
{ number: status.failed.length }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.oneFailed) {
|
if (status.oneFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.NODE_RESTORE',
|
'APP.MESSAGES.ERRORS.NODE_RESTORE',
|
||||||
{ name: status.failed[0].name }
|
{ name: status.failed[0].name }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDeleteMessage(status): Observable<string> {
|
private getDeleteMessage(status): string {
|
||||||
if (status.allFailed && !status.oneFailed) {
|
if (status.allFailed && !status.oneFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.NODE_DELETION_PLURAL',
|
'APP.MESSAGES.ERRORS.NODE_DELETION_PLURAL',
|
||||||
{ number: status.failed.length }
|
{ number: status.failed.length }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.allSucceeded && !status.oneSucceeded) {
|
if (status.allSucceeded && !status.oneSucceeded) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.NODE_DELETION.PLURAL',
|
'APP.MESSAGES.INFO.NODE_DELETION.PLURAL',
|
||||||
{ number: status.success.length }
|
{ number: status.success.length }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.someFailed && status.someSucceeded && !status.oneSucceeded) {
|
if (status.someFailed && status.someSucceeded && !status.oneSucceeded) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_PLURAL',
|
'APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_PLURAL',
|
||||||
{
|
{
|
||||||
success: status.success.length,
|
success: status.success.length,
|
||||||
@ -220,7 +215,7 @@ export class NodeDeleteDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status.someFailed && status.oneSucceeded) {
|
if (status.someFailed && status.oneSucceeded) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_SINGULAR',
|
'APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_SINGULAR',
|
||||||
{
|
{
|
||||||
success: status.success.length,
|
success: status.success.length,
|
||||||
@ -230,14 +225,14 @@ export class NodeDeleteDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status.oneFailed && !status.someSucceeded) {
|
if (status.oneFailed && !status.someSucceeded) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.NODE_DELETION',
|
'APP.MESSAGES.ERRORS.NODE_DELETION',
|
||||||
{ name: status.failed[0].name }
|
{ name: status.failed[0].name }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.oneSucceeded && !status.someFailed) {
|
if (status.oneSucceeded && !status.someFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.NODE_DELETION.SINGULAR',
|
'APP.MESSAGES.INFO.NODE_DELETION.SINGULAR',
|
||||||
{ name: status.success[0].name }
|
{ name: status.success[0].name }
|
||||||
);
|
);
|
||||||
|
@ -128,20 +128,21 @@ export class NodeMoveDirective {
|
|||||||
|
|
||||||
const initialParentId = this.nodeActionsService.getEntryParentId(this.selection[0].entry);
|
const initialParentId = this.nodeActionsService.getEntryParentId(this.selection[0].entry);
|
||||||
|
|
||||||
this.translation.get(
|
const messages = this.translation.instant(
|
||||||
[successMessage, partialSuccessMessage, failedMessage],
|
[successMessage, partialSuccessMessage, failedMessage],
|
||||||
{ success: succeeded, failed: failures, partially: partiallySucceeded}).subscribe(messages => {
|
{ success: succeeded, failed: failures, partially: partiallySucceeded}
|
||||||
|
);
|
||||||
|
|
||||||
this.notification.openSnackMessageAction(
|
// TODO: review in terms of i18n
|
||||||
messages[successMessage]
|
this.notification.openSnackMessageAction(
|
||||||
+ beforePartialSuccessMessage + messages[partialSuccessMessage]
|
messages[successMessage]
|
||||||
+ beforeFailedMessage + messages[failedMessage],
|
+ beforePartialSuccessMessage + messages[partialSuccessMessage]
|
||||||
undo,
|
+ beforeFailedMessage + messages[failedMessage],
|
||||||
NodeActionsService[`SNACK_MESSAGE_DURATION${withUndo}`]
|
undo,
|
||||||
)
|
NodeActionsService[`SNACK_MESSAGE_DURATION${withUndo}`]
|
||||||
.onAction()
|
)
|
||||||
.subscribe(() => this.revertMoving(moveResponse, initialParentId));
|
.onAction()
|
||||||
});
|
.subscribe(() => this.revertMoving(moveResponse, initialParentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
getErrorMessage(errorObject): string {
|
getErrorMessage(errorObject): string {
|
||||||
@ -207,10 +208,8 @@ export class NodeMoveDirective {
|
|||||||
i18nMessageString = 'APP.MESSAGES.ERRORS.PERMISSION';
|
i18nMessageString = 'APP.MESSAGES.ERRORS.PERMISSION';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.translation.get(i18nMessageString).subscribe(message => {
|
const message = this.translation.instant(i18nMessageString);
|
||||||
this.notification.openSnackMessage(
|
this.notification.openSnackMessage(message, NodeActionsService.SNACK_MESSAGE_DURATION);
|
||||||
message, NodeActionsService.SNACK_MESSAGE_DURATION);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ describe('NodePermanentDeleteDirective', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
nodesService = alfrescoService.getInstance().nodes;
|
nodesService = alfrescoService.getInstance().nodes;
|
||||||
|
|
||||||
spyOn(translation, 'get').and.returnValue(Observable.of('message'));
|
spyOn(translation, 'instant').and.returnValue(Observable.of('message'));
|
||||||
spyOn(notificationService, 'openSnackMessage').and.returnValue({});
|
spyOn(notificationService, 'openSnackMessage').and.returnValue({});
|
||||||
|
|
||||||
spyOn(dialog, 'open').and.returnValue({
|
spyOn(dialog, 'open').and.returnValue({
|
||||||
@ -138,7 +138,7 @@ describe('NodePermanentDeleteDirective', () => {
|
|||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_SINGULAR',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_SINGULAR',
|
||||||
{ name: 'name1', failed: 2 }
|
{ name: 'name1', failed: 2 }
|
||||||
);
|
);
|
||||||
@ -175,7 +175,7 @@ describe('NodePermanentDeleteDirective', () => {
|
|||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_PLURAL',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_PLURAL',
|
||||||
{ number: 2, failed: 2 }
|
{ number: 2, failed: 2 }
|
||||||
);
|
);
|
||||||
@ -193,7 +193,7 @@ describe('NodePermanentDeleteDirective', () => {
|
|||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.SINGULAR',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.SINGULAR',
|
||||||
{ name: 'name1' }
|
{ name: 'name1' }
|
||||||
);
|
);
|
||||||
@ -211,7 +211,7 @@ describe('NodePermanentDeleteDirective', () => {
|
|||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.SINGULAR',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.SINGULAR',
|
||||||
{ name: 'name1' }
|
{ name: 'name1' }
|
||||||
);
|
);
|
||||||
@ -238,7 +238,7 @@ describe('NodePermanentDeleteDirective', () => {
|
|||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PLURAL',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PLURAL',
|
||||||
{ number: 2 }
|
{ number: 2 }
|
||||||
);
|
);
|
||||||
@ -265,7 +265,7 @@ describe('NodePermanentDeleteDirective', () => {
|
|||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
expect(notificationService.openSnackMessage).toHaveBeenCalled();
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.PLURAL',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.PLURAL',
|
||||||
{ number: 2 }
|
{ number: 2 }
|
||||||
);
|
);
|
||||||
|
@ -116,15 +116,13 @@ export class NodePermanentDeleteDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private purgeNotification(status): void {
|
private purgeNotification(status): void {
|
||||||
this.getPurgeMessage(status)
|
const message = this.getPurgeMessage(status);
|
||||||
.subscribe((message) => {
|
this.notification.openSnackMessage(message, 3000);
|
||||||
this.notification.openSnackMessage(message, 3000);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPurgeMessage(status): Observable<string|any> {
|
private getPurgeMessage(status): string {
|
||||||
if (status.oneSucceeded && status.someFailed && !status.oneFailed) {
|
if (status.oneSucceeded && status.someFailed && !status.oneFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_SINGULAR',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_SINGULAR',
|
||||||
{
|
{
|
||||||
name: status.success[0].name,
|
name: status.success[0].name,
|
||||||
@ -134,7 +132,7 @@ export class NodePermanentDeleteDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status.someSucceeded && !status.oneSucceeded && status.someFailed) {
|
if (status.someSucceeded && !status.oneSucceeded && status.someFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_PLURAL',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_PLURAL',
|
||||||
{
|
{
|
||||||
number: status.success.length,
|
number: status.success.length,
|
||||||
@ -144,28 +142,28 @@ export class NodePermanentDeleteDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status.oneSucceeded) {
|
if (status.oneSucceeded) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.SINGULAR',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.SINGULAR',
|
||||||
{ name: status.success[0].name }
|
{ name: status.success[0].name }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.oneFailed) {
|
if (status.oneFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.SINGULAR',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.SINGULAR',
|
||||||
{ name: status.fail[0].name }
|
{ name: status.fail[0].name }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.allSucceeded) {
|
if (status.allSucceeded) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PLURAL',
|
'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PLURAL',
|
||||||
{ number: status.success.length }
|
{ number: status.success.length }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.allFailed) {
|
if (status.allFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.PLURAL',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.PLURAL',
|
||||||
{ number: status.fail.length }
|
{ number: status.fail.length }
|
||||||
);
|
);
|
||||||
|
@ -84,7 +84,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
nodesService = alfrescoService.getInstance().nodes;
|
nodesService = alfrescoService.getInstance().nodes;
|
||||||
coreApi = alfrescoService.getInstance().core;
|
coreApi = alfrescoService.getInstance().core;
|
||||||
|
|
||||||
spyOn(translation, 'get').and.returnValue(Observable.of('message'));
|
spyOn(translation, 'instant').and.returnValue(Observable.of('message'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not restore nodes if no selection', () => {
|
it('does not restore nodes if no selection', () => {
|
||||||
@ -209,7 +209,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
element.triggerEventHandler('click', null);
|
element.triggerEventHandler('click', null);
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.PARTIAL_PLURAL',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.PARTIAL_PLURAL',
|
||||||
{ number: 2 }
|
{ number: 2 }
|
||||||
);
|
);
|
||||||
@ -229,7 +229,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
element.triggerEventHandler('click', null);
|
element.triggerEventHandler('click', null);
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.NODE_EXISTS',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.NODE_EXISTS',
|
||||||
{ name: 'name1' }
|
{ name: 'name1' }
|
||||||
);
|
);
|
||||||
@ -249,7 +249,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
element.triggerEventHandler('click', null);
|
element.triggerEventHandler('click', null);
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.GENERIC',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.GENERIC',
|
||||||
{ name: 'name1' }
|
{ name: 'name1' }
|
||||||
);
|
);
|
||||||
@ -269,7 +269,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
element.triggerEventHandler('click', null);
|
element.triggerEventHandler('click', null);
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.LOCATION_MISSING',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.LOCATION_MISSING',
|
||||||
{ name: 'name1' }
|
{ name: 'name1' }
|
||||||
);
|
);
|
||||||
@ -296,7 +296,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
element.triggerEventHandler('click', null);
|
element.triggerEventHandler('click', null);
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.PLURAL'
|
'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.PLURAL'
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
@ -313,7 +313,7 @@ describe('NodeRestoreDirective', () => {
|
|||||||
element.triggerEventHandler('click', null);
|
element.triggerEventHandler('click', null);
|
||||||
tick();
|
tick();
|
||||||
|
|
||||||
expect(translation.get).toHaveBeenCalledWith(
|
expect(translation.instant).toHaveBeenCalledWith(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.SINGULAR',
|
'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.SINGULAR',
|
||||||
{ name: 'name1' }
|
{ name: 'name1' }
|
||||||
);
|
);
|
||||||
|
@ -190,11 +190,11 @@ export class NodeRestoreDirective {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRestoreMessage(): Observable<string|any> {
|
private getRestoreMessage(): string {
|
||||||
const { restoreProcessStatus: status } = this;
|
const { restoreProcessStatus: status } = this;
|
||||||
|
|
||||||
if (status.someFailed && !status.oneFailed) {
|
if (status.someFailed && !status.oneFailed) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.PARTIAL_PLURAL',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.PARTIAL_PLURAL',
|
||||||
{
|
{
|
||||||
number: status.fail.length
|
number: status.fail.length
|
||||||
@ -204,14 +204,14 @@ export class NodeRestoreDirective {
|
|||||||
|
|
||||||
if (status.oneFailed && status.fail[0].statusCode) {
|
if (status.oneFailed && status.fail[0].statusCode) {
|
||||||
if (status.fail[0].statusCode === 409) {
|
if (status.fail[0].statusCode === 409) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.NODE_EXISTS',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.NODE_EXISTS',
|
||||||
{
|
{
|
||||||
name: status.fail[0].entry.name
|
name: status.fail[0].entry.name
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.GENERIC',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.GENERIC',
|
||||||
{
|
{
|
||||||
name: status.fail[0].entry.name
|
name: status.fail[0].entry.name
|
||||||
@ -221,7 +221,7 @@ export class NodeRestoreDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status.oneFailed && !status.fail[0].statusCode) {
|
if (status.oneFailed && !status.fail[0].statusCode) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.LOCATION_MISSING',
|
'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.LOCATION_MISSING',
|
||||||
{
|
{
|
||||||
name: status.fail[0].entry.name
|
name: status.fail[0].entry.name
|
||||||
@ -230,11 +230,11 @@ export class NodeRestoreDirective {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (status.allSucceeded && !status.oneSucceeded) {
|
if (status.allSucceeded && !status.oneSucceeded) {
|
||||||
return this.translation.get('APP.MESSAGES.INFO.TRASH.NODES_RESTORE.PLURAL');
|
return this.translation.instant('APP.MESSAGES.INFO.TRASH.NODES_RESTORE.PLURAL');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.allSucceeded && status.oneSucceeded) {
|
if (status.allSucceeded && status.oneSucceeded) {
|
||||||
return this.translation.get(
|
return this.translation.instant(
|
||||||
'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.SINGULAR',
|
'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.SINGULAR',
|
||||||
{
|
{
|
||||||
name: status.success[0].entry.name
|
name: status.success[0].entry.name
|
||||||
@ -246,13 +246,11 @@ export class NodeRestoreDirective {
|
|||||||
private restoreNotification(): void {
|
private restoreNotification(): void {
|
||||||
const status = Object.assign({}, this.restoreProcessStatus);
|
const status = Object.assign({}, this.restoreProcessStatus);
|
||||||
const action = (status.oneSucceeded && !status.someFailed) ? this.translation.translate.instant('APP.ACTIONS.VIEW') : '';
|
const action = (status.oneSucceeded && !status.someFailed) ? this.translation.translate.instant('APP.ACTIONS.VIEW') : '';
|
||||||
|
const message = this.getRestoreMessage();
|
||||||
|
|
||||||
this.getRestoreMessage()
|
this.notification.openSnackMessageAction(message, action, 3000)
|
||||||
.subscribe((message) => {
|
.onAction()
|
||||||
this.notification.openSnackMessageAction(message, action, 3000)
|
.subscribe(() => this.navigateLocation(status.success[0].entry.path));
|
||||||
.onAction()
|
|
||||||
.subscribe(() => this.navigateLocation(status.success[0].entry.path));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private refresh(): void {
|
private refresh(): void {
|
||||||
|
@ -71,8 +71,8 @@ export class NodeVersionsDirective {
|
|||||||
VersionManagerDialogAdapterComponent,
|
VersionManagerDialogAdapterComponent,
|
||||||
<any>{ data: { contentEntry }, panelClass: 'adf-version-manager-dialog', width: '630px' });
|
<any>{ data: { contentEntry }, panelClass: 'adf-version-manager-dialog', width: '630px' });
|
||||||
} else {
|
} else {
|
||||||
const translatedErrorMessage: any = this.translation.get('APP.MESSAGES.ERRORS.PERMISSION');
|
const translatedErrorMessage = this.translation.instant('APP.MESSAGES.ERRORS.PERMISSION');
|
||||||
this.notification.openSnackMessage(translatedErrorMessage.value, 4000);
|
this.notification.openSnackMessage(translatedErrorMessage, 4000);
|
||||||
|
|
||||||
this.nodeVersionError.emit();
|
this.nodeVersionError.emit();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user