topbar anpassungen
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
import { showAsyncFlash } from './app-async-flash.js';
|
||||
import { warnOnce } from '../core/app-dom.js';
|
||||
|
||||
const setPending = (link, pending) => {
|
||||
link.style.pointerEvents = pending ? 'none' : '';
|
||||
link.style.opacity = pending ? '0.5' : '';
|
||||
if (pending) {
|
||||
link.setAttribute('aria-busy', 'true');
|
||||
} else {
|
||||
link.removeAttribute('aria-busy');
|
||||
}
|
||||
};
|
||||
|
||||
const switchTenant = async (link) => {
|
||||
const tenantId = link.dataset.switchTenant;
|
||||
const csrfKey = link.dataset.csrfKey;
|
||||
@@ -12,8 +23,7 @@ const switchTenant = async (link) => {
|
||||
}
|
||||
|
||||
// Disable link during request
|
||||
link.style.pointerEvents = 'none';
|
||||
link.style.opacity = '0.5';
|
||||
setPending(link, true);
|
||||
|
||||
try {
|
||||
const body = new URLSearchParams({
|
||||
@@ -37,21 +47,18 @@ const switchTenant = async (link) => {
|
||||
window.location.reload();
|
||||
} else {
|
||||
warnOnce('FETCH_FAILED', 'Tenant switch failed', { module: 'tenant-switcher', error: data.error });
|
||||
alert(errorMessage);
|
||||
link.style.pointerEvents = '';
|
||||
link.style.opacity = '';
|
||||
showAsyncFlash('error', errorMessage);
|
||||
setPending(link, false);
|
||||
}
|
||||
} else {
|
||||
warnOnce('FETCH_FAILED', `Tenant switch server error: ${response.status}`, { module: 'tenant-switcher' });
|
||||
alert(errorMessage);
|
||||
link.style.pointerEvents = '';
|
||||
link.style.opacity = '';
|
||||
showAsyncFlash('error', errorMessage);
|
||||
setPending(link, false);
|
||||
}
|
||||
} catch (error) {
|
||||
warnOnce('FETCH_ERROR', 'Tenant switch network error', { module: 'tenant-switcher', error });
|
||||
alert(errorMessage);
|
||||
link.style.pointerEvents = '';
|
||||
link.style.opacity = '';
|
||||
showAsyncFlash('error', errorMessage);
|
||||
setPending(link, false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user