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

fix(admin): show error on user deletion #3742

Merged
merged 1 commit into from
Sep 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<div class="col-xs-6 text-right">
<button class="btn btn-primary"
ng-click="$close()">{{ 'GENERIC_CONFIRMATION_PROCEED' | translate }}</button>
ng-click="delete()">{{ 'GENERIC_CONFIRMATION_PROCEED' | translate }}</button>
</div>
</div>
</div>
Expand Down
65 changes: 38 additions & 27 deletions webapps/frontend/ui/admin/client/scripts/pages/groupEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,40 +323,51 @@ var Controller = [
template: confirmationTemplate,
controller: [
'$scope',
function($dialogScope) {
'$timeout',
function($dialogScope, $timeout) {
$dialogScope.question = $translate.instant(
'GROUP_EDIT_DELETE_CONFIRM',
{group: $scope.group.id}
);
$dialogScope.delete = () => {
GroupResource.delete({id: $scope.decodedGroupId}, function(
err
) {
if (err === null) {
$timeout(() => {
Notifications.addMessage({
type: 'success',
status: $translate.instant(
'NOTIFICATIONS_STATUS_SUCCESS'
),
message: $translate.instant(
'GROUP_EDIT_DELETE_SUCCESS',
{
group: $scope.group.id
}
)
});
}, 200);
$location.path('/groups');
$dialogScope.$close();
} else {
const {
response: {
body: {message}
}
} = err;
Notifications.addError({
status: $translate.instant('NOTIFICATIONS_STATUS_FAILED'),
message: $translate.instant('GROUP_EDIT_DELETE_FAILED', {
message
})
});
}
});
};
}
]
})
.result.then(function() {
GroupResource.delete({id: $scope.decodedGroupId}, function(err) {
if (err === null) {
Notifications.addMessage({
type: 'success',
status: $translate.instant('NOTIFICATIONS_STATUS_SUCCESS'),
message: $translate.instant('GROUP_EDIT_DELETE_SUCCESS', {
group: $scope.group.id
})
});
$location.path('/groups');
} else {
const {
response: {
body: {message}
}
} = err;
Notifications.addError({
status: $translate.instant('NOTIFICATIONS_STATUS_FAILED'),
message: $translate.instant('GROUP_EDIT_DELETE_FAILED', {
message
})
});
}
});
})
.catch(angular.noop);
};

Expand Down
92 changes: 53 additions & 39 deletions webapps/frontend/ui/admin/client/scripts/pages/tenantEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var Controller = [
}
]);
}

refreshBreadcrumbs();

$scope.tenant = null;
Expand Down Expand Up @@ -219,6 +220,7 @@ var Controller = [
}

$scope.canSortUserEntries = true;

function updateTenantUserView() {
var prep = prepareTenantMemberView(tenantUserPages);

Expand Down Expand Up @@ -291,47 +293,59 @@ var Controller = [
// delete group form /////////////////////////////

$scope.deleteTenant = function() {
$modal
.open({
template: confirmationTemplate,
controller: [
'$scope',
function($dialogScope) {
$dialogScope.question = $translate.instant(
'TENANTS_TENANT_DELETE_CONFIRM',
{tenant: $scope.tenant.id}
);
}
]
})
.result.then(function() {
TenantResource.delete({id: $scope.decodedTenantId}, function(err) {
if (err === null) {
Notifications.addMessage({
type: 'success',
status: $translate.instant('NOTIFICATIONS_STATUS_SUCCESS'),
message: $translate.instant('TENANTS_TENANT_DELETE_SUCCESS', {
tenant: $scope.tenant.id
})
});
$location.path('/tenants');
} else {
const {
response: {
body: {message}
$modal.open({
template: confirmationTemplate,
controller: [
'$scope',
'$timeout',
function($dialogScope, $timeout) {
$dialogScope.question = $translate.instant(
'TENANTS_TENANT_DELETE_CONFIRM',
{tenant: $scope.tenant.id}
);
$dialogScope.delete = () => {
TenantResource.delete({id: $scope.decodedTenantId}, function(
err
) {
if (err === null) {
$timeout(() => {
Notifications.addMessage({
type: 'success',
status: $translate.instant(
'NOTIFICATIONS_STATUS_SUCCESS'
),
message: $translate.instant(
'TENANTS_TENANT_DELETE_SUCCESS',
{
tenant: $scope.tenant.id
}
)
});
}, 200);
$location.path('/tenants');
$dialogScope.$close();
} else {
const {
response: {
body: {message}
}
} = err;
Notifications.addError({
status: $translate.instant('NOTIFICATIONS_STATUS_FAILED'),
message: $translate.instant(
'TENANTS_TENANT_DELETE_FAILED',
{
tenant: $scope.tenant.id,
message
}
)
});
}
} = err;
Notifications.addError({
status: $translate.instant('NOTIFICATIONS_STATUS_FAILED'),
message: $translate.instant('TENANTS_TENANT_DELETE_FAILED', {
tenant: $scope.tenant.id,
message
})
});
}
});
})
.catch(angular.noop);
};
}
]
});
};

// page controls ////////////////////////////////////
Expand Down
139 changes: 73 additions & 66 deletions webapps/frontend/ui/admin/client/scripts/pages/userEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,75 +256,82 @@ module.exports = [
// delete user form /////////////////////////////

$scope.deleteUser = function() {
$modal
.open({
template: confirmationTemplate,
controller: [
'$scope',
'$timeout',
function($dialogScope, $timeout) {
$dialogScope.question = $translate.instant(
'USERS_USER_DELETE_CONFIRM',
{user: $scope.user.id}
);
$timeout(() =>
Notifications.addMessage({
type: 'info',
status: 'Warning',
unsafe: true,
message: $translate.instant('USERS_USER_DELETE_INFO')
})
);
}
]
})
.result.then(function() {
UserResource.delete({id: $scope.decodedUserId}, function(err) {
if (err === null) {
if ($scope.authenticatedUser.name !== $scope.user.id) {
Notifications.addMessage({
type: 'success',
status: $translate.instant(
'NOTIFICATIONS_STATUS_SUCCESS'
),
message: $translate.instant(
'USERS_USER_DELETE_SUCCESS',
{
user: $scope.user.id
$modal.open({
template: confirmationTemplate,
controller: [
'$scope',
'$timeout',
function($dialogScope, $timeout) {
$dialogScope.question = $translate.instant(
'USERS_USER_DELETE_CONFIRM',
{user: $scope.user.id}
);
$dialogScope.delete = () => {
UserResource.delete({id: $scope.decodedUserId}, function(
err
) {
if (err === null) {
if ($scope.authenticatedUser.name !== $scope.user.id) {
$timeout(() => {
Notifications.addMessage({
type: 'success',
status: $translate.instant(
'NOTIFICATIONS_STATUS_SUCCESS'
),
message: $translate.instant(
'USERS_USER_DELETE_SUCCESS',
{
user: $scope.user.id
}
)
});
}, 200);
$location.path('/users');
} else {
$http
.get(Uri.appUri('engine://engine/'))
.then(function(response) {
var engines = response.data;

engines.forEach(function(engine) {
AuthenticationService.logout(engine.name);
});
})
.catch(angular.noop);
}
$dialogScope.$close();
} else {
const {
response: {
body: {message}
}
)
});

$location.path('/users');
} else {
$http
.get(Uri.appUri('engine://engine/'))
.then(function(response) {
var engines = response.data;

engines.forEach(function(engine) {
AuthenticationService.logout(engine.name);
});
})
.catch(angular.noop);
}
} else {
const {
response: {
body: {message}
} = err;
Notifications.addError({
status: $translate.instant(
'NOTIFICATIONS_STATUS_ERROR'
),
message: $translate.instant(
'USERS_USER_DELETE_FAILED',
{
user: $scope.user.id,
message
}
)
});
}
} = err;
Notifications.addError({
status: $translate.instant('NOTIFICATIONS_STATUS_ERROR'),
message: $translate.instant('USERS_USER_DELETE_FAILED', {
user: $scope.user.id,
message
})
});
}
});
})
.catch(angular.noop);
};
$timeout(() =>
Notifications.addMessage({
type: 'info',
status: $translate.instant('USERS_WARNING'),
unsafe: true,
message: $translate.instant('USERS_USER_DELETE_INFO')
})
);
}
]
});
};

// Unlock User
Expand Down