Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirmation prompt for stop/restart app #1437

Merged
merged 2 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions components/cloud-foundry/frontend/i18n/en_US/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@
"start": "Start",
"cli": "CLI Info"
},
"restart-app": {
"title": "Restart Application",
"description": "Are you sure you want to restart application {{app}}?",
"error-message": "There was a problem restarting this application. Please try again. If this error persists, please contact the Administrator.",
"button": {
"yes": "Restart",
"no": "@:buttons.cancel"
},
"success": "Application {{app}} successfully restarted"
},
"stop-app": {
"title": "Stop Application",
"description": "Are you sure you want to stop application {{app}}?",
"error-message": "There was a problem stopping this application. Please try again. If this error persists, please contact the Administrator.",
"button": {
"yes": "Stop",
"no": "@:buttons.cancel"
},
"success": "Application {{app}} successfully stopped"
},
"edit-app": {
"edit-app": "Edit App",
"ssh-access": "Enable SSH Access",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,13 @@
* @description restart an application
* @param {string} cnsiGuid - The GUID of the cloud-foundry server.
* @param {string} guid - the application id
* @returns {promise} a promise object
* @public
*/
function restartApp(cnsiGuid, guid) {

stopApp(cnsiGuid, guid).then(function () {
startApp(cnsiGuid, guid);
return stopApp(cnsiGuid, guid).then(function () {
return startApp(cnsiGuid, guid);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,24 @@
name: 'app.app-info.app-actions.stop',
id: 'stop',
execute: function () {
vm.model.stopApp(cnsiGuid, vm.id);
var appName = vm.model.application.summary.name;
frameworkDialogConfirm({
title: 'app.app-info.stop-app.title',
description: $translate.instant('app.app-info.stop-app.description', { app: appName }),
errorMessage: 'app.app-info.stop-app.error-message',
submitCommit: true,
buttonText: {
yes: 'app.app-info.stop-app.button.yes',
no: 'app.app-info.stop-app.button.no'
},
callback: function () {
return vm.model.stopApp(cnsiGuid, vm.id)
.then(function () {
var message = $translate.instant('app.app-info.stop-app.success', { app: appName });
appEventService.$emit('events.NOTIFY_SUCCESS', {message: message});
});
}
});
},
disabled: true,
icon: 'stop'
Expand All @@ -110,7 +127,24 @@
name: 'app.app-info.app-actions.restart',
id: 'restart',
execute: function () {
vm.model.restartApp(cnsiGuid, vm.id);
var appName = vm.model.application.summary.name;
frameworkDialogConfirm({
title: 'app.app-info.restart-app.title',
description: $translate.instant('app.app-info.restart-app.description', { app: appName }),
errorMessage: 'app.app-info.restart-app.error-message',
submitCommit: true,
buttonText: {
yes: 'app.app-info.restart-app.button.yes',
no: 'app.app-info.restart-app.button.no'
},
callback: function () {
return vm.model.restartApp(cnsiGuid, vm.id)
.then(function () {
var message = $translate.instant('app.app-info.restart-app.success', { app: appName });
appEventService.$emit('events.NOTIFY_SUCCESS', {message: message});
});
}
});
},
disabled: true,
icon: 'settings_backup_restore'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
describe('service-card directive', function () {
var $compile, $httpBackend, $scope, mockBindingsApi, cfServiceInstanceService;
var APP_GUID = '6e23689c-2844-4ebf-ab69-e52ab3439f6b';
var SERVICE_BINDING_GUID = '571b283b-97f9-41e3-abc7-81792ee34e40';
var SERVICE_NAME = 'instance_123';
var cnsiGuid = 'cnsiGuid';
var spaceGuid = 'spaceGuid';

Expand Down Expand Up @@ -91,26 +93,28 @@
serviceCardCtrl = element.controller('serviceCard');
});

it('detach', function () {
it('should call unbindServiceFromApp', function () {
spyOn(cfServiceInstanceService, 'unbindServiceFromApp');
serviceCardCtrl.detach({
entity: {
service_bindings: [{
entity: {
app_guid: APP_GUID
}
}]
}
});
expect(cfServiceInstanceService.unbindServiceFromApp)
.toHaveBeenCalled();
var args = cfServiceInstanceService.unbindServiceFromApp.calls.argsFor(0);
expect(args[0]).toBe('guid');
expect(args[1]).toBe('6e23689c-2844-4ebf-ab69-e52ab3439f6b');
expect(args[2]).toBe('571b283b-97f9-41e3-abc7-81792ee34e40');
expect(args[3]).toBe('instance_123');
it('should call unbindServiceFromApp', function () {
spyOn(cfServiceInstanceService, 'unbindServiceFromApp');
serviceCardCtrl.detach({
entity: {
name: SERVICE_NAME,
service_bindings: [{
metadata: {
guid: SERVICE_BINDING_GUID
},
entity: {
app_guid: APP_GUID
}
}]
}
});
expect(cfServiceInstanceService.unbindServiceFromApp)
.toHaveBeenCalled();
var args = cfServiceInstanceService.unbindServiceFromApp.calls.argsFor(0);
expect(args[0]).toBe('guid');
expect(args[1]).toBe('6e23689c-2844-4ebf-ab69-e52ab3439f6b');
expect(args[2]).toBe('571b283b-97f9-41e3-abc7-81792ee34e40');
expect(args[3]).toBe('instance_123');
});
});
});
Expand Down