diff --git a/app/templates/admin/admin-user-edit.html b/app/templates/admin/admin-user-edit.html index 071700a9..b25abc21 100644 --- a/app/templates/admin/admin-user-edit.html +++ b/app/templates/admin/admin-user-edit.html @@ -2,6 +2,7 @@ {% extends "admin/base.html" %} {% from 'shared/macros/alerts.html' import loading_state %} {% from 'shared/macros/headers.html' import edit_page_header %} +{% from 'shared/macros/modals.html' import confirm_modal %} {% block title %}Edit Admin User{% endblock %} @@ -252,6 +253,18 @@ + + +{{ confirm_modal( + 'removePlatformModal', + 'Remove Platform', + 'Are you sure you want to remove this platform from this admin?', + 'confirmRemovePlatform()', + 'showRemovePlatformModal', + 'Remove', + 'Cancel', + 'warning' +) }} {% endblock %} {% block extra_scripts %} diff --git a/static/admin/js/admin-user-edit.js b/static/admin/js/admin-user-edit.js index e4f3872d..2946138e 100644 --- a/static/admin/js/admin-user-edit.js +++ b/static/admin/js/admin-user-edit.js @@ -23,6 +23,10 @@ function adminUserEditPage() { availablePlatforms: [], selectedPlatformId: null, + // Confirmation modal state + showRemovePlatformModal: false, + platformToRemove: null, + // Initialize async init() { adminUserEditLog.info('=== ADMIN USER EDIT PAGE INITIALIZING ==='); @@ -237,22 +241,23 @@ function adminUserEditPage() { } }, - // Remove platform from admin - async removePlatform(platformId) { - const platform = this.adminUser.platforms.find(p => p.id === platformId); - const platformName = platform ? platform.name : platformId; - + // Show confirmation modal for platform removal + removePlatform(platformId) { // Validate: platform admin must have at least one platform if (this.adminUser.platforms.length <= 1) { Utils.showToast('Platform admin must be assigned to at least one platform', 'error'); return; } - if (!confirm(`Are you sure you want to remove "${platformName}" from this admin?`)) { - adminUserEditLog.info('Platform removal cancelled by user'); - return; - } + this.platformToRemove = this.adminUser.platforms.find(p => p.id === platformId); + this.showRemovePlatformModal = true; + }, + // Confirm and execute platform removal + async confirmRemovePlatform() { + if (!this.platformToRemove) return; + + const platformId = this.platformToRemove.id; adminUserEditLog.info('Removing platform:', platformId); this.saving = true; @@ -275,6 +280,7 @@ function adminUserEditPage() { Utils.showToast(error.message || 'Failed to remove platform', 'error'); } finally { this.saving = false; + this.platformToRemove = null; } },