Skip to content

Commit

Permalink
update ConfirmDialogService
Browse files Browse the repository at this point in the history
Dialog window can have now only one button.

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
  • Loading branch information
akurinnoy committed Oct 21, 2019
1 parent 18381d0 commit f0e9f31
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class AdminsUserManagementCtrl {
*/
removeUser(event: MouseEvent, user: any): void {
let content = 'Are you sure you want to remove \'' + user.email + '\'?';
let promise = this.confirmDialogService.showConfirmDialog('Remove user', content, 'Delete', 'Cancel');
let promise = this.confirmDialogService.showConfirmDialog('Remove user', content, { resolve: 'Delete', reject: 'Cancel' });

promise.then(() => {
this.isLoading = true;
Expand Down Expand Up @@ -231,7 +231,7 @@ export class AdminsUserManagementCtrl {
content += 'user?';
}

return this.confirmDialogService.showConfirmDialog('Remove users', content, 'Delete', 'Cancel');
return this.confirmDialogService.showConfirmDialog('Remove users', content, { resolve: 'Delete', reject: 'Cancel' });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class DockerRegistryListController {
} else {
content += 'this selected registry?';
}
return this.confirmDialogService.showConfirmDialog('Remove registries', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove registries', content, { resolve: 'Delete' });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class FactoryInformationController {

const title = 'Warning',
content = `You have unsaved changes in JSON configuration. Would you like to save changes now?`;
return this.confirmDialogService.showConfirmDialog(title, content, 'Continue').then(() => {
return this.confirmDialogService.showConfirmDialog(title, content, { resolve: 'Continue' }).then(() => {
this.updateFactoryContent();
});
}
Expand Down Expand Up @@ -296,7 +296,7 @@ export class FactoryInformationController {
*/
deleteFactory(): void {
let content = 'Please confirm removal for the factory \'' + (this.factory.name ? this.factory.name : this.factory.id) + '\'.';
let promise = this.confirmDialogService.showConfirmDialog('Remove the factory', content, 'Delete');
let promise = this.confirmDialogService.showConfirmDialog('Remove the factory', content, { resolve: 'Delete' });

promise.then(() => {
// remove it !
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,6 @@ export class ListFactoriesController {
} else {
content += 'this selected factory?';
}
return this.confirmDialogService.showConfirmDialog('Remove factories', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove factories', content, { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class ListOrganizationsController {
content += 'this selected organization?';
}

return this.confirmDialogService.showConfirmDialog('Delete organizations', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Delete organizations', content, { resolve: 'Delete' });
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ export class OrganizationsItemController {
*/
confirmRemoval(): ng.IPromise<any> {
return this.confirmDialogService.showConfirmDialog('Delete organization',
'Would you like to delete organization \'' + this.organization.name + '\'?', 'Delete');
'Would you like to delete organization \'' + this.organization.name + '\'?', { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export class OrganizationDetailsController {
*/
deleteOrganization(): void {
let promise = this.confirmDialogService.showConfirmDialog('Delete organization',
'Would you like to delete organization \'' + this.organization.name + '\'?', 'Delete');
'Would you like to delete organization \'' + this.organization.name + '\'?', { resolve: 'Delete' });

promise.then(() => {
let promise = this.cheOrganization.deleteOrganization(this.organization.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export class ListOrganizationMembersController {
* @param member
*/
removeMember(member: che.IMember): void {
let promise = this.confirmDialogService.showConfirmDialog('Remove member', 'Would you like to remove member ' + member.email + ' ?', 'Delete');
let promise = this.confirmDialogService.showConfirmDialog('Remove member', 'Would you like to remove member ' + member.email + ' ?', { resolve: 'Delete' });

promise.then(() => {
this.removePermissions(member);
Expand Down Expand Up @@ -507,6 +507,6 @@ export class ListOrganizationMembersController {
confirmTitle += 'the selected member?';
}

return this.confirmDialogService.showConfirmDialog('Remove members', confirmTitle, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove members', confirmTitle, { resolve: 'Delete' });
}
}
2 changes: 1 addition & 1 deletion dashboard/src/app/teams/list/list-teams.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,6 @@ export class ListTeamsController {
content += 'this selected team?';
}

return this.confirmDialogService.showConfirmDialog('Delete teams', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Delete teams', content, { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class TeamItemController {
*/
confirmRemoval(): ng.IPromise<any> {
let promise = this.confirmDialogService.showConfirmDialog('Delete team',
'Would you like to delete team \'' + this.team.name + '\'?', 'Delete');
'Would you like to delete team \'' + this.team.name + '\'?', { resolve: 'Delete' });
return promise;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ tab: Object = Tab;
*/
deleteTeam(event: MouseEvent): void {
let promise = this.confirmDialogService.showConfirmDialog('Delete team',
'Would you like to delete team \'' + this.team.name + '\'?', 'Delete');
'Would you like to delete team \'' + this.team.name + '\'?', { resolve: 'Delete' });

promise.then(() => {
let promise = this.cheTeam.deleteTeam(this.team.id);
Expand All @@ -334,7 +334,7 @@ tab: Object = Tab;
*/
leaveTeam(): void {
let promise = this.confirmDialogService.showConfirmDialog('Leave team',
'Would you like to leave team \'' + this.team.name + '\'?', 'Leave');
'Would you like to leave team \'' + this.team.name + '\'?', { resolve: 'Leave' });

promise.then(() => {
let promise = this.chePermissions.removeOrganizationPermissions(this.team.id, this.cheUser.getUser().id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,6 @@ export class ListTeamMembersController {
confirmTitle += 'the selected member?';
}

return this.confirmDialogService.showConfirmDialog('Remove members', confirmTitle, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove members', confirmTitle, { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class MemberItemController {
* @param event - the $event
*/
removeMember(event: MouseEvent): void {
let promise = this.confirmDialogService.showConfirmDialog('Remove member', 'Would you like to remove member ' + this.member.email + ' ?', 'Delete');
let promise = this.confirmDialogService.showConfirmDialog('Remove member', 'Would you like to remove member ' + this.member.email + ' ?', { resolve: 'Delete' });

promise.then(() => {
if (this.member.isPending) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@ export class CreateWorkspaceSvc {
});

projects.push(template);
});
});

return this.checkEditingProgress().then(() => {
sourceDevfile.projects = projects;

// If no projects defined in devfile were added - remove the commands from devfile as well:
if (noProjectsFromDevfile) {
sourceDevfile.commands = [];
}

return this.cheWorkspace.createWorkspaceFromDevfile(namespaceId, sourceDevfile, attributes).then((workspace: che.IWorkspace) => {
return this.cheWorkspace.fetchWorkspaces().then(() => this.cheWorkspace.getWorkspaceById(workspace.id));
})
Expand Down Expand Up @@ -246,7 +246,7 @@ export class CreateWorkspaceSvc {

const title = 'Warning',
content = `You have project editing, that is not completed. Would you like to proceed to workspace creation without these changes?`;
return this.confirmDialogService.showConfirmDialog(title, content, 'Continue');
return this.confirmDialogService.showConfirmDialog(title, content, { resolve: 'Continue' });
}

/**
Expand Down Expand Up @@ -289,7 +289,7 @@ export class CreateWorkspaceSvc {

/**
* Returns name of the pointed workspace.
*
*
* @param workspace workspace
*/
getWorkspaceName(workspace: che.IWorkspace): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class ListWorkspacesCtrl {
content += 'this selected workspace?';
}

return this.confirmDialogService.showConfirmDialog('Remove workspaces', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove workspaces', content, { resolve: 'Delete' });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export class ShareWorkspaceController {
content += 'this selected member?';
}

return this.confirmDialogService.showConfirmDialog('Remove members', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove members', content, { resolve: 'Delete' });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class UserItemController {
*/
removeUser(): void {
let content = 'Please confirm removal for the member \'' + this.user.email + '\'.';
let promise = this.confirmDialogService.showConfirmDialog('Remove the member', content, 'Delete');
let promise = this.confirmDialogService.showConfirmDialog('Remove the member', content, { resolve: 'Delete' });

promise.then(() => {
// callback is set in scope definition:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class ListEnvVariablesController {
content += 'this selected variable?';
}

return this.confirmDialogService.showConfirmDialog('Remove variables', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove variables', content, { resolve: 'Delete' });
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class ListServersController {
content += 'this selected server?';
}

return this.confirmDialogService.showConfirmDialog('Remove servers', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove servers', content, { resolve: 'Delete' });
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class WorkspaceMachineConfigController {
deleteMachine($event: MouseEvent): void {
let promise;
if (!this.machineConfig.isDev) {
promise = this.confirmDialogService.showConfirmDialog('Remove container', 'Would you like to delete this container?', 'Delete');
promise = this.confirmDialogService.showConfirmDialog('Remove container', 'Would you like to delete this container?', { resolve: 'Delete' });
} else {
promise = this.showDeleteDevMachineDialog($event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,6 @@ export class ListCommandsController {
content += 'this selected command?';
}

return this.confirmDialogService.showConfirmDialog('Remove commands', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove commands', content, { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,21 @@ export class WorkspaceDetailsController {
this.$scope.$broadcast('edit-workspace-details', { status: 'cancelled' });
}

runWorkspace(): ng.IPromise<any> {
runWorkspace(): ng.IPromise<void> {
this.errorMessage = '';

if (this.workspaceDetailsService.isWorkspaceModified(this.workspaceId)) {
return this.workspaceDetailsService.notifyUnsavedChangesDialog();
}
return this.workspaceDetailsService.runWorkspace(this.workspaceDetails).catch((error: any) => {
this.errorMessage = error.message;
});
}

stopWorkspace(): ng.IPromise<any> {
stopWorkspace(): ng.IPromise<void> {
if (this.workspaceDetailsService.isWorkspaceModified(this.workspaceId)) {
return this.workspaceDetailsService.notifyUnsavedChangesDialog();
}
return this.workspaceDetailsService.stopWorkspace(this.workspaceDetails.id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {CheWorkspace, WorkspaceStatus} from '../../../components/api/workspace/c
import {CheService} from '../../../components/api/che-service.factory';
import {PluginRegistry} from '../../../components/api/plugin-registry.factory';
import {WorkspaceDataManager} from '../../../components/api/workspace/workspace-data-manager';
import {ConfirmDialogService} from '../../../../target/dist/components/service/confirm-dialog/confirm-dialog.service';
import { ConfirmDialogService } from '../../../components/service/confirm-dialog/confirm-dialog.service';

interface IPage {
title: string;
Expand Down Expand Up @@ -462,7 +462,7 @@ export class WorkspaceDetailsService {
* Shows modal window with notification about unsaved changes.
*/
notifyUnsavedChangesDialog(): ng.IPromise<void> {
return this.confirmDialogService.showConfirmDialog('Unsaved Changes', `You're editing this workspace configuration. Please save or discard changes to be able to run or stop the workspace.`, 'Close');
return this.confirmDialogService.showConfirmDialog('Unsaved Changes', `You're editing this workspace configuration. Please save or discard changes to be able to run or stop the workspace.`, { reject: 'Close' });
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class EnvVariablesController {
* @param variableName {string}
*/
deleteEnvVariable(variableName: string): void {
const promise = this.confirmDialogService.showConfirmDialog('Remove variable', 'Would you like to delete this variable?', 'Delete');
const promise = this.confirmDialogService.showConfirmDialog('Remove variable', 'Would you like to delete this variable?', { resolve: 'Delete' });
promise.then(() => {
delete this.envVariables[variableName];
this.environmentManager.setEnvVariables(this.selectedMachine, this.envVariables);
Expand All @@ -212,6 +212,6 @@ export class EnvVariablesController {
content += 'this selected variable?';
}

return this.confirmDialogService.showConfirmDialog('Remove variables', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove variables', content, { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class MachineServersController {
* @param reference {string}
*/
deleteServer(reference: string): void {
const promise = this.confirmDialogService.showConfirmDialog('Remove server', 'Would you like to delete this server?', 'Delete');
const promise = this.confirmDialogService.showConfirmDialog('Remove server', 'Would you like to delete this server?', { resolve: 'Delete' });
promise.then(() => {
delete this.servers[reference];
this.environmentManager.setServers(this.selectedMachine, this.servers);
Expand All @@ -225,6 +225,6 @@ export class MachineServersController {
content += 'this selected server?';
}

return this.confirmDialogService.showConfirmDialog('Remove servers', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove servers', content, { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class MachineVolumesController {
* @param variableName {string}
*/
deleteMachineVolume(variableName: string): void {
const promise = this.confirmDialogService.showConfirmDialog('Remove variable', 'Would you like to delete this variable?', 'Delete');
const promise = this.confirmDialogService.showConfirmDialog('Remove variable', 'Would you like to delete this variable?', { resolve: 'Delete' });
promise.then(() => {
delete this.machineVolumes[variableName];
this.environmentManager.setMachineVolumes(this.selectedMachine, this.machineVolumes);
Expand All @@ -162,6 +162,6 @@ export class MachineVolumesController {
content += 'this selected variable?';
}

return this.confirmDialogService.showConfirmDialog('Remove variables', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove variables', content, { resolve: 'Delete' });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class WorkspaceMachinesController {
content += 'these ' + selectedItems.length + ' machines?';
}

return this.confirmDialogService.showConfirmDialog('Remove machines', content, 'Delete').then(() => {
return this.confirmDialogService.showConfirmDialog('Remove machines', content, { resolve: 'Delete' }).then(() => {
return selectedItems;
});
}
Expand Down Expand Up @@ -276,7 +276,7 @@ export class WorkspaceMachinesController {
* @param name {string}
*/
deleteMachine(name: string): void {
this.confirmDialogService.showConfirmDialog('Remove machine', 'Would you like to delete this machine?', 'Delete').then(() => {
this.confirmDialogService.showConfirmDialog('Remove machine', 'Would you like to delete this machine?', { resolve: 'Delete' }).then(() => {
this.machineOnDelete(name);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export class WorkspaceDetailsOverviewController {
*/
deleteWorkspace(): void {
const content = 'Would you like to delete workspace \'' + this.cheWorkspace.getWorkspaceDataManager().getName(this.workspaceDetails) + '\'?';
this.confirmDialogService.showConfirmDialog('Delete workspace', content, 'Delete').then(() => {
this.confirmDialogService.showConfirmDialog('Delete workspace', content, { resolve: 'Delete' }).then(() => {
if ([RUNNING, STARTING].indexOf(this.getWorkspaceStatus()) !== -1) {
this.cheWorkspace.stopWorkspace(this.workspaceDetails.id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class WorkspaceDetailsProjectsCtrl {
content += 'this selected project?';
}

return this.confirmDialogService.showConfirmDialog('Remove projects', content, 'Delete');
return this.confirmDialogService.showConfirmDialog('Remove projects', content, { resolve: 'Delete' });
}

workspaceIsRunning(): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<div class="che-confirm-dialog-notification">
<div>{{cheConfirmDialogController.content}}</div>
<div layout="row" flex layout-align="end end">
<che-button-primary che-button-title="{{cheConfirmDialogController.resolveButtonTitle}}"
<che-button-primary ng-if="cheConfirmDialogController.buttons.resolve"
che-button-title="{{cheConfirmDialogController.buttons.resolve}}"
id="ok-dialog-button"
ng-click="cheConfirmDialogController.hide()">
</che-button-primary>
<che-button-notice che-button-title="{{cheConfirmDialogController.rejectButtonTitle}}"
<che-button-notice che-button-title="{{cheConfirmDialogController.buttons.reject}}"
id="cancel-dialog-button"
ng-click="cheConfirmDialogController.cancel()">
</che-button-notice>
Expand Down
Loading

0 comments on commit f0e9f31

Please sign in to comment.