ui: change tooltips and info boxes

This commit is contained in:
Andras Bacsai
2022-09-01 11:20:22 +02:00
parent e1697848a5
commit f6bb14f7c4
28 changed files with 428 additions and 290 deletions

View File

@@ -40,7 +40,7 @@
}
};
} catch (error) {
console.log(error)
console.log(error);
return handlerNotFoundLoad(error, url);
}
};
@@ -56,12 +56,16 @@
import { errorNotification, handlerNotFoundLoad } from '$lib/common';
import { appSession } from '$lib/store';
import DeleteIcon from '$lib/components/DeleteIcon.svelte';
import Tooltip from '$lib/components/Tooltip.svelte';
const { id } = $page.params;
const isDestinationDeletable = destination?.application.length === 0 && destination?.database.length === 0 && destination?.service.length === 0
const isDestinationDeletable =
destination?.application.length === 0 &&
destination?.database.length === 0 &&
destination?.service.length === 0;
async function deleteDestination(destination: any) {
if (!isDestinationDeletable) return
if (!isDestinationDeletable) return;
const sure = confirm($t('application.confirm_to_delete', { name: destination.name }));
if (sure) {
try {
@@ -74,12 +78,12 @@
}
function deletable() {
if (!isDestinationDeletable) {
return "Please delete all resources before deleting this."
return 'Please delete all resources before deleting this.';
}
if ($appSession.isAdmin) {
return $t('destination.delete_destination')
return $t('destination.delete_destination');
} else {
return $t('destination.permission_denied_delete_destination')
return $t('destination.permission_denied_delete_destination');
}
}
</script>
@@ -87,14 +91,15 @@
{#if id !== 'new'}
<nav class="nav-side">
<button
id="delete"
on:click={() => deleteDestination(destination)}
type="submit"
disabled={!$appSession.isAdmin && isDestinationDeletable}
class:hover:text-red-500={$appSession.isAdmin && isDestinationDeletable}
class="icons tooltip tooltip-primary tooltip-left bg-transparent text-sm"
class:text-stone-600={!isDestinationDeletable}
data-tip={deletable()}><DeleteIcon /></button
class="icons bg-transparent text-sm"
class:text-stone-600={!isDestinationDeletable}><DeleteIcon /></button
>
</nav>
<Tooltip triggeredBy="#delete">{deletable()}</Tooltip>
{/if}
<slot />