Add a way to disable/enable app configure views based on task error
This commit is contained in:
@@ -148,6 +148,40 @@ async function refresh() {
|
||||
refreshTimer = setTimeout(refresh, 2000);
|
||||
}
|
||||
|
||||
function isViewEnabled(view, errorState) {
|
||||
if (!errorState) return true;
|
||||
|
||||
if (view === 'info'
|
||||
|| view === 'display'
|
||||
|| view === 'uninstall'
|
||||
|| view === 'backups'
|
||||
|| view === 'access'
|
||||
|| view === 'proxy'
|
||||
|| view === 'graphs'
|
||||
|| view === 'security'
|
||||
|| view === 'cron'
|
||||
|| view === 'eventlog'
|
||||
) return true;
|
||||
|
||||
if (view === 'location') {
|
||||
return errorState === ISTATES.PENDING_LOCATION_CHANGE;
|
||||
} else if (view === 'repair') {
|
||||
return errorState === ISTATES.PENDING_RESTART || errorState === ISTATES.PENDING_CONFIGURE || ISTATES.PENDING_INSTALL || ISTATES.PENDING_DEBUG;
|
||||
} else if (view === 'resources') {
|
||||
return errorState === ISTATES.PENDING_RESIZE;
|
||||
} else if (view === 'storage') {
|
||||
return errorState === ISTATES.PENDING_DATA_DIR_MIGRATION || errorState === ISTATES.PENDING_RECREATE_CONTAINER;
|
||||
} else if (view === 'services') {
|
||||
return errorState === ISTATES.PENDING_SERVICES_CHANGE;
|
||||
} else if (view === 'email') {
|
||||
return errorState === ISTATES.PENDING_SERVICES_CHANGE;
|
||||
} else if (view === 'update') {
|
||||
return errorState === ISTATES.PENDING_UPDATE;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async function onStopAppTask() {
|
||||
if (!app.value.taskId) return;
|
||||
|
||||
@@ -177,23 +211,23 @@ onMounted(async () => {
|
||||
if (app.value.manifest.addons.turn && app.value.manifest.addons.turn.optional) hasServices = true;
|
||||
if (app.value.manifest.addons.redis && app.value.manifest.addons.redis.optional) hasServices = true;
|
||||
|
||||
views.value.push({ id: 'info', display: t('app.infoTabTitle'), });
|
||||
views.value.push({ id: 'display', display: t('app.displayTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin') views.value.push({ id: 'location', display: t('app.locationTabTitle'), });
|
||||
if (app.value.type === APP_TYPES.PROXIED) views.value.push({ id: 'proxy', display: 'Proxy', });
|
||||
if (app.value.accessLevel === 'admin') views.value.push({ id: 'access', display: t('app.accessControlTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ id: 'resources', display: t('app.resourcesTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED && hasServices) views.value.push({ id: 'services', display: t('app.servicesTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin' && app.value.type !== APP_TYPES.PROXIED) views.value.push({ id: 'storage', display: t('app.storageTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ id: 'graphs', display: t('app.graphsTabTitle'), });
|
||||
views.value.push({ id: 'security', display: t('app.securityTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin' && hasEmail.value && app.value.type !== APP_TYPES.PROXIED) views.value.push({ id: 'email', display: t('app.emailTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ id: 'cron', display: t('app.cronTabTitle'), });
|
||||
views.value.push({ id: 'updates', display: t('app.updatesTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ id: 'backups', display: t('app.backupsTabTitle'), });
|
||||
views.value.push({ id: 'repair', display: t('app.repairTabTitle'), });
|
||||
views.value.push({ id: 'eventlog', display: t('app.eventlogTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin') views.value.push({ id: 'uninstall', display: t('app.uninstallTabTitle'), });
|
||||
views.value.push({ enabled: true, id: 'info', display: t('app.infoTabTitle'), });
|
||||
views.value.push({ enabled: true, id: 'display', display: t('app.displayTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin') views.value.push({ enabled: true, id: 'location', display: t('app.locationTabTitle'), });
|
||||
if (app.value.type === APP_TYPES.PROXIED) views.value.push({ enabled: true, id: 'proxy', display: 'Proxy', });
|
||||
if (app.value.accessLevel === 'admin') views.value.push({ enabled: true, id: 'access', display: t('app.accessControlTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ enabled: true, id: 'resources', display: t('app.resourcesTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED && hasServices) views.value.push({ enabled: true, id: 'services', display: t('app.servicesTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin' && app.value.type !== APP_TYPES.PROXIED) views.value.push({ enabled: true, id: 'storage', display: t('app.storageTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ enabled: true, id: 'graphs', display: t('app.graphsTabTitle'), });
|
||||
views.value.push({ enabled: true, id: 'security', display: t('app.securityTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin' && hasEmail.value && app.value.type !== APP_TYPES.PROXIED) views.value.push({ enabled: true, id: 'email', display: t('app.emailTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ enabled: true, id: 'cron', display: t('app.cronTabTitle'), });
|
||||
views.value.push({ enabled: true, id: 'updates', display: t('app.updatesTabTitle'), });
|
||||
if (app.value.type !== APP_TYPES.PROXIED) views.value.push({ enabled: true, id: 'backups', display: t('app.backupsTabTitle'), });
|
||||
views.value.push({ enabled: true, id: 'repair', display: t('app.repairTabTitle'), });
|
||||
views.value.push({ enabled: true, id: 'eventlog', display: t('app.eventlogTabTitle'), });
|
||||
if (app.value.accessLevel === 'admin') views.value.push({ enabled: true, id: 'uninstall', display: t('app.uninstallTabTitle'), });
|
||||
|
||||
onSetView(parts[1] || 'info');
|
||||
|
||||
@@ -252,7 +286,7 @@ onBeforeUnmount(() => {
|
||||
|
||||
<div class="configure-body">
|
||||
<div class="configure-menu pankow-no-mobile">
|
||||
<div class="configure-menu-item" v-for="view in views" :key="view.id" @click="onSetView(view.id)" :active="currentView === view.id ? true : null">{{ view.display }}</div>
|
||||
<div class="configure-menu-item" v-for="view in views" :key="view.id" @click="onSetView(view.id)" :active="currentView === view.id ? true : null" :disabled="isViewEnabled(view.id, app.error?.details?.installationState) ? null : true">{{ view.display }}</div>
|
||||
</div>
|
||||
<div class="configure-content">
|
||||
<Transition name="slide-fade" mode="out-in">
|
||||
@@ -396,6 +430,11 @@ onBeforeUnmount(() => {
|
||||
color: var(--pankow-color-primary-hover);
|
||||
}
|
||||
|
||||
.configure-menu-item[disabled] {
|
||||
color: gray;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.configure-content {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user