init
This commit is contained in:
64 files changed
+17178
No files matched your search
@@ -0,0 +1,588 @@
|
||||
.nova-tenancy-page {
|
||||
--nt-primary: #7c3aed;
|
||||
--nt-primary-strong: #5b21b6;
|
||||
--nt-surface: rgb(255 255 255 / 0.88);
|
||||
--nt-border: rgb(226 232 240 / 0.9);
|
||||
--nt-muted: #64748b;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
padding-bottom: 3rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-hero {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 15rem;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 2rem;
|
||||
overflow: hidden;
|
||||
border: 1px solid rgb(255 255 255 / 0.16);
|
||||
border-radius: 1.5rem;
|
||||
padding: clamp(1.5rem, 4vw, 3rem);
|
||||
color: white;
|
||||
background:
|
||||
radial-gradient(circle at 12% 10%, rgb(167 139 250 / 0.48), transparent 34%),
|
||||
radial-gradient(circle at 88% 85%, rgb(56 189 248 / 0.3), transparent 38%),
|
||||
linear-gradient(135deg, #251259 0%, #4c1d95 48%, #172554 100%);
|
||||
box-shadow: 0 24px 60px rgb(49 46 129 / 0.22);
|
||||
}
|
||||
|
||||
.nova-tenancy-hero::after {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background-image: linear-gradient(rgb(255 255 255 / 0.04) 1px, transparent 1px),
|
||||
linear-gradient(90deg, rgb(255 255 255 / 0.04) 1px, transparent 1px);
|
||||
background-size: 32px 32px;
|
||||
content: '';
|
||||
mask-image: linear-gradient(to bottom, black, transparent);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.nova-tenancy-hero__glow {
|
||||
position: absolute;
|
||||
top: -8rem;
|
||||
right: -5rem;
|
||||
width: 22rem;
|
||||
height: 22rem;
|
||||
border-radius: 9999px;
|
||||
background: rgb(255 255 255 / 0.09);
|
||||
filter: blur(2px);
|
||||
}
|
||||
|
||||
.nova-tenancy-hero__content,
|
||||
.nova-tenancy-current {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.nova-tenancy-hero__content {
|
||||
max-width: 42rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-kicker {
|
||||
margin: 0 0 0.65rem;
|
||||
color: #c4b5fd;
|
||||
font-size: 0.72rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.16em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.nova-tenancy-title {
|
||||
margin: 0;
|
||||
font-size: clamp(2rem, 5vw, 3.5rem);
|
||||
font-weight: 750;
|
||||
letter-spacing: -0.045em;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.nova-tenancy-description {
|
||||
max-width: 35rem;
|
||||
margin: 1rem 0 0;
|
||||
color: rgb(237 233 254 / 0.82);
|
||||
font-size: 1rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.nova-tenancy-current {
|
||||
display: flex;
|
||||
min-width: min(100%, 17rem);
|
||||
align-items: center;
|
||||
gap: 0.8rem;
|
||||
border: 1px solid rgb(255 255 255 / 0.16);
|
||||
border-radius: 1rem;
|
||||
padding: 0.8rem;
|
||||
background: rgb(255 255 255 / 0.1);
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
.nova-tenancy-current__logo,
|
||||
.nova-tenancy-card__logo {
|
||||
display: grid;
|
||||
flex: none;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
border-radius: 0.9rem;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.nova-tenancy-current__logo {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
color: #4c1d95;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.nova-tenancy-current__logo img,
|
||||
.nova-tenancy-card__logo img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.nova-tenancy-current__copy {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nova-tenancy-current__copy span {
|
||||
color: rgb(237 233 254 / 0.7);
|
||||
font-size: 0.68rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.nova-tenancy-current__copy strong {
|
||||
overflow: hidden;
|
||||
margin-top: 0.15rem;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.nova-tenancy-pulse {
|
||||
width: 0.55rem;
|
||||
height: 0.55rem;
|
||||
border: 2px solid rgb(255 255 255 / 0.8);
|
||||
border-radius: 9999px;
|
||||
background: #34d399;
|
||||
box-shadow: 0 0 0 4px rgb(52 211 153 / 0.2);
|
||||
}
|
||||
|
||||
.nova-tenancy-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-search {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
max-width: 34rem;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
border: 1px solid var(--nt-border);
|
||||
border-radius: 0.9rem;
|
||||
padding-inline: 1rem;
|
||||
background: var(--nt-surface);
|
||||
box-shadow: 0 4px 18px rgb(15 23 42 / 0.04);
|
||||
transition: border-color 160ms, box-shadow 160ms;
|
||||
}
|
||||
|
||||
.nova-tenancy-search:focus-within {
|
||||
border-color: rgb(124 58 237 / 0.55);
|
||||
box-shadow: 0 0 0 3px rgb(124 58 237 / 0.12);
|
||||
}
|
||||
|
||||
.nova-tenancy-search svg {
|
||||
width: 1.2rem;
|
||||
fill: none;
|
||||
stroke: var(--nt-muted);
|
||||
stroke-linecap: round;
|
||||
stroke-width: 1.8;
|
||||
}
|
||||
|
||||
.nova-tenancy-search input {
|
||||
width: 100%;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
padding: 0.85rem 0;
|
||||
color: #0f172a;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.nova-tenancy-count {
|
||||
display: grid;
|
||||
min-width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
place-items: center;
|
||||
border-radius: 9999px;
|
||||
color: var(--nt-primary-strong);
|
||||
font-size: 0.78rem;
|
||||
font-weight: 800;
|
||||
background: #ede9fe;
|
||||
}
|
||||
|
||||
.nova-tenancy-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-card {
|
||||
--tenant-accent: #7c3aed;
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 17rem;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--nt-border);
|
||||
border-radius: 1.25rem;
|
||||
padding: 1.25rem;
|
||||
background: var(--nt-surface);
|
||||
box-shadow: 0 10px 32px rgb(15 23 42 / 0.055);
|
||||
transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
|
||||
}
|
||||
|
||||
.nova-tenancy-card:hover {
|
||||
transform: translateY(-3px);
|
||||
border-color: color-mix(in srgb, var(--tenant-accent) 42%, transparent);
|
||||
box-shadow: 0 18px 42px rgb(15 23 42 / 0.1);
|
||||
}
|
||||
|
||||
.nova-tenancy-card--selected {
|
||||
border-color: color-mix(in srgb, var(--tenant-accent) 70%, transparent);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--tenant-accent) 16%, transparent),
|
||||
0 18px 42px rgb(15 23 42 / 0.09);
|
||||
}
|
||||
|
||||
.nova-tenancy-card__accent {
|
||||
position: absolute;
|
||||
inset: 0 0 auto;
|
||||
height: 0.26rem;
|
||||
background: linear-gradient(90deg, var(--tenant-accent), color-mix(in srgb, var(--tenant-accent) 25%, white));
|
||||
}
|
||||
|
||||
.nova-tenancy-card__header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-card__logo {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
color: var(--tenant-accent);
|
||||
font-size: 1.35rem;
|
||||
background: color-mix(in srgb, var(--tenant-accent) 11%, white);
|
||||
}
|
||||
|
||||
.nova-tenancy-badge {
|
||||
border-radius: 9999px;
|
||||
padding: 0.35rem 0.65rem;
|
||||
color: var(--tenant-accent);
|
||||
font-size: 0.68rem;
|
||||
font-weight: 800;
|
||||
background: color-mix(in srgb, var(--tenant-accent) 10%, white);
|
||||
}
|
||||
|
||||
.nova-tenancy-check {
|
||||
display: grid;
|
||||
width: 1.8rem;
|
||||
height: 1.8rem;
|
||||
place-items: center;
|
||||
border-radius: 9999px;
|
||||
color: white;
|
||||
background: var(--tenant-accent);
|
||||
}
|
||||
|
||||
.nova-tenancy-check svg {
|
||||
width: 1rem;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
.nova-tenancy-card__body {
|
||||
flex: 1;
|
||||
padding-block: 1.2rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-card__body h2 {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
font-size: 1.05rem;
|
||||
font-weight: 750;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.nova-tenancy-card__body p {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
margin: 0.55rem 0 0;
|
||||
color: var(--nt-muted);
|
||||
font-size: 0.84rem;
|
||||
line-height: 1.6;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.nova-tenancy-card__body .nova-tenancy-card__key {
|
||||
color: color-mix(in srgb, var(--tenant-accent) 68%, #64748b);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
}
|
||||
|
||||
.nova-tenancy-select,
|
||||
.nova-tenancy-button,
|
||||
.nova-tenancy-pagination button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.55rem;
|
||||
border: 0;
|
||||
border-radius: 0.75rem;
|
||||
font-weight: 750;
|
||||
cursor: pointer;
|
||||
transition: transform 150ms, background-color 150ms, opacity 150ms;
|
||||
}
|
||||
|
||||
.nova-tenancy-select {
|
||||
width: 100%;
|
||||
min-height: 2.7rem;
|
||||
color: white;
|
||||
background: var(--tenant-accent);
|
||||
}
|
||||
|
||||
.nova-tenancy-select:not(:disabled):hover,
|
||||
.nova-tenancy-button:hover,
|
||||
.nova-tenancy-pagination button:not(:disabled):hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.nova-tenancy-select--selected {
|
||||
color: var(--tenant-accent);
|
||||
background: color-mix(in srgb, var(--tenant-accent) 10%, white);
|
||||
}
|
||||
|
||||
.nova-tenancy-select:disabled,
|
||||
.nova-tenancy-pagination button:disabled {
|
||||
cursor: default;
|
||||
opacity: 0.72;
|
||||
}
|
||||
|
||||
.nova-tenancy-select svg {
|
||||
width: 1rem;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
stroke-width: 1.8;
|
||||
}
|
||||
|
||||
.nova-tenancy-spinner {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
border: 2px solid rgb(255 255 255 / 0.4);
|
||||
border-top-color: white;
|
||||
border-radius: 9999px;
|
||||
animation: nova-tenancy-spin 650ms linear infinite;
|
||||
}
|
||||
|
||||
.nova-tenancy-card--skeleton {
|
||||
gap: 1.3rem;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.nova-tenancy-card--skeleton span {
|
||||
display: block;
|
||||
height: 1rem;
|
||||
border-radius: 9999px;
|
||||
background: linear-gradient(90deg, #f1f5f9, #e2e8f0, #f1f5f9);
|
||||
background-size: 220% 100%;
|
||||
animation: nova-tenancy-shimmer 1.4s ease infinite;
|
||||
}
|
||||
|
||||
.nova-tenancy-card--skeleton span:first-child {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
border-radius: 1rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-card--skeleton span:nth-child(2) { width: 70%; }
|
||||
.nova-tenancy-card--skeleton span:nth-child(3) { width: 45%; }
|
||||
|
||||
.nova-tenancy-state {
|
||||
display: flex;
|
||||
min-height: 18rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
border: 1px dashed var(--nt-border);
|
||||
border-radius: 1.25rem;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
background: var(--nt-surface);
|
||||
}
|
||||
|
||||
.nova-tenancy-state__icon {
|
||||
display: grid;
|
||||
width: 3.5rem;
|
||||
height: 3.5rem;
|
||||
place-items: center;
|
||||
border-radius: 1rem;
|
||||
color: #be123c;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 800;
|
||||
background: #ffe4e6;
|
||||
}
|
||||
|
||||
.nova-tenancy-state__icon--empty {
|
||||
color: var(--nt-primary);
|
||||
background: #ede9fe;
|
||||
}
|
||||
|
||||
.nova-tenancy-state__icon svg {
|
||||
width: 1.8rem;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
stroke-width: 1.5;
|
||||
}
|
||||
|
||||
.nova-tenancy-state h2 {
|
||||
margin: 1rem 0 0;
|
||||
color: #0f172a;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-state p {
|
||||
max-width: 28rem;
|
||||
margin: 0.5rem 0 0;
|
||||
color: var(--nt-muted);
|
||||
}
|
||||
|
||||
.nova-tenancy-button {
|
||||
margin-top: 1rem;
|
||||
padding: 0.65rem 1rem;
|
||||
color: white;
|
||||
background: var(--nt-primary);
|
||||
}
|
||||
|
||||
.nova-tenancy-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.nova-tenancy-pagination button {
|
||||
border: 1px solid var(--nt-border);
|
||||
padding: 0.55rem 0.9rem;
|
||||
color: #334155;
|
||||
background: var(--nt-surface);
|
||||
}
|
||||
|
||||
.nova-tenancy-pagination span {
|
||||
color: var(--nt-muted);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.nova-tenancy-brand {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
max-width: 13.5rem;
|
||||
align-items: center;
|
||||
gap: 0.65rem;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
color: #334155;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nova-tenancy-brand__logo {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
flex: none;
|
||||
border-radius: 0.7rem;
|
||||
object-fit: cover;
|
||||
box-shadow: 0 3px 12px rgb(15 23 42 / 0.12);
|
||||
}
|
||||
|
||||
.nova-tenancy-brand__title {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 0.86rem;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.nova-tenancy-select:focus-visible,
|
||||
.nova-tenancy-button:focus-visible,
|
||||
.nova-tenancy-pagination button:focus-visible,
|
||||
.nova-tenancy-brand:focus-visible {
|
||||
outline: 2px solid var(--nt-primary);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.nova-tenancy-sr-only {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dark .nova-tenancy-page {
|
||||
--nt-surface: rgb(30 41 59 / 0.84);
|
||||
--nt-border: rgb(71 85 105 / 0.72);
|
||||
--nt-muted: #94a3b8;
|
||||
}
|
||||
|
||||
.dark .nova-tenancy-search input,
|
||||
.dark .nova-tenancy-card__body h2,
|
||||
.dark .nova-tenancy-state h2,
|
||||
.dark .nova-tenancy-brand,
|
||||
.dark .nova-tenancy-pagination button {
|
||||
color: #f8fafc;
|
||||
}
|
||||
|
||||
.dark .nova-tenancy-count,
|
||||
.dark .nova-tenancy-state__icon--empty {
|
||||
color: #c4b5fd;
|
||||
background: rgb(91 33 182 / 0.3);
|
||||
}
|
||||
|
||||
.dark .nova-tenancy-card__logo,
|
||||
.dark .nova-tenancy-badge,
|
||||
.dark .nova-tenancy-select--selected {
|
||||
background: color-mix(in srgb, var(--tenant-accent) 22%, #0f172a);
|
||||
}
|
||||
|
||||
.dark .nova-tenancy-card--skeleton span {
|
||||
background: linear-gradient(90deg, #1e293b, #334155, #1e293b);
|
||||
background-size: 220% 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.nova-tenancy-hero {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.nova-tenancy-current {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nova-tenancy-brand__title {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.nova-tenancy-card,
|
||||
.nova-tenancy-select,
|
||||
.nova-tenancy-button,
|
||||
.nova-tenancy-pagination button {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.nova-tenancy-spinner,
|
||||
.nova-tenancy-card--skeleton span {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes nova-tenancy-spin { to { transform: rotate(360deg); } }
|
||||
@keyframes nova-tenancy-shimmer { to { background-position: -220% 0; } }
|
||||
@@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<span
|
||||
ref="brand"
|
||||
class="nova-tenancy-brand"
|
||||
:title="title"
|
||||
@click.stop.prevent="visitBrandDestination"
|
||||
>
|
||||
<img
|
||||
v-if="showLogo"
|
||||
:key="logoUrl"
|
||||
:src="logoUrl"
|
||||
class="nova-tenancy-brand__logo"
|
||||
alt=""
|
||||
/>
|
||||
|
||||
<span v-if="showTitle" class="nova-tenancy-brand__title">
|
||||
{{ title }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import { currentLogoUrl } from '../tenantState'
|
||||
|
||||
const configuration = Nova.config('novaTenancy') || {}
|
||||
const brand = ref(null)
|
||||
const current = ref(configuration.current || null)
|
||||
const revision = ref(Date.now())
|
||||
let parentLink = null
|
||||
|
||||
const showLogo = computed(() => configuration.branding?.show_logo !== false)
|
||||
const showTitle = computed(() => configuration.branding?.show_title !== false)
|
||||
const title = computed(
|
||||
() => current.value?.title || configuration.copy?.selectTenant || 'Select tenant'
|
||||
)
|
||||
const logoUrl = computed(() => {
|
||||
const apiBase = configuration.apiBase || '/nova-vendor/nova-tenancy'
|
||||
const key = current.value?.key ?? 'none'
|
||||
|
||||
return currentLogoUrl(apiBase, key, revision.value)
|
||||
})
|
||||
|
||||
const updateCurrent = payload => {
|
||||
current.value = payload?.current ?? payload ?? null
|
||||
revision.value = Date.now()
|
||||
}
|
||||
|
||||
const refreshCurrent = async () => {
|
||||
try {
|
||||
const response = await Nova.request().get(
|
||||
`${configuration.apiBase || '/nova-vendor/nova-tenancy'}/current`
|
||||
)
|
||||
updateCurrent(response.data)
|
||||
} catch {
|
||||
// Keep the server-provided bootstrap state if the refresh cannot complete.
|
||||
}
|
||||
}
|
||||
|
||||
const brandDestination = () => {
|
||||
const destination = configuration.branding?.link
|
||||
|
||||
if (destination === 'home') {
|
||||
return '/'
|
||||
}
|
||||
|
||||
if (typeof destination === 'string' && destination.startsWith('/')) {
|
||||
return destination
|
||||
}
|
||||
|
||||
return configuration.selectorPath || '/nova-tenancy'
|
||||
}
|
||||
|
||||
const visitBrandDestination = () => {
|
||||
Nova.visit(brandDestination())
|
||||
}
|
||||
|
||||
const interceptParentLink = event => {
|
||||
event.preventDefault()
|
||||
event.stopImmediatePropagation()
|
||||
visitBrandDestination()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
Nova.$on('nova-tenancy:changed', updateCurrent)
|
||||
parentLink = brand.value?.closest('a') || null
|
||||
parentLink?.addEventListener('click', interceptParentLink, true)
|
||||
refreshCurrent()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
Nova.$off('nova-tenancy:changed', updateCurrent)
|
||||
parentLink?.removeEventListener('click', interceptParentLink, true)
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,233 @@
|
||||
<template>
|
||||
<div class="nova-tenancy-page">
|
||||
<Head :title="copy.pageTitle" />
|
||||
|
||||
<section class="nova-tenancy-hero">
|
||||
<div class="nova-tenancy-hero__glow" aria-hidden="true"></div>
|
||||
|
||||
<div class="nova-tenancy-hero__content">
|
||||
<p class="nova-tenancy-kicker">{{ copy.pageKicker }}</p>
|
||||
<h1 class="nova-tenancy-title">{{ copy.pageTitle }}</h1>
|
||||
<p class="nova-tenancy-description">{{ copy.pageDescription }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="activeTenant" class="nova-tenancy-current">
|
||||
<div class="nova-tenancy-current__logo">
|
||||
<img
|
||||
v-if="activeTenant.logoUrl && !failedImages.has(String(activeTenant.key))"
|
||||
:src="activeTenant.logoUrl"
|
||||
alt=""
|
||||
@error="markImageFailed(activeTenant.key)"
|
||||
/>
|
||||
<span v-else>{{ initial(activeTenant.title) }}</span>
|
||||
</div>
|
||||
<div class="nova-tenancy-current__copy">
|
||||
<span>{{ copy.currentTenant }}</span>
|
||||
<strong>{{ activeTenant.title }}</strong>
|
||||
</div>
|
||||
<span class="nova-tenancy-pulse" aria-hidden="true"></span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="nova-tenancy-toolbar" :aria-label="copy.search">
|
||||
<label class="nova-tenancy-search">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="m21 21-4.35-4.35m2.35-5.65a8 8 0 1 1-16 0 8 8 0 0 1 16 0Z" />
|
||||
</svg>
|
||||
<span class="nova-tenancy-sr-only">{{ copy.search }}</span>
|
||||
<input
|
||||
v-model="search"
|
||||
type="search"
|
||||
:placeholder="copy.searchPlaceholder"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<span v-if="!loading" class="nova-tenancy-count">
|
||||
{{ meta.total.toLocaleString() }}
|
||||
</span>
|
||||
</section>
|
||||
|
||||
<div v-if="loading" class="nova-tenancy-grid" aria-busy="true">
|
||||
<div v-for="index in 6" :key="index" class="nova-tenancy-card nova-tenancy-card--skeleton">
|
||||
<span></span><span></span><span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="error" class="nova-tenancy-state" role="alert">
|
||||
<div class="nova-tenancy-state__icon">!</div>
|
||||
<h2>{{ copy.error }}</h2>
|
||||
<button type="button" class="nova-tenancy-button" @click="loadTenants">
|
||||
{{ copy.retry }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-else-if="tenants.length === 0" class="nova-tenancy-state">
|
||||
<div class="nova-tenancy-state__icon nova-tenancy-state__icon--empty">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path d="M3 21h18M5 21V7l7-4 7 4v14M9 10h.01M9 14h.01M9 18h.01M15 10h.01M15 14h.01M15 18h.01" />
|
||||
</svg>
|
||||
</div>
|
||||
<h2>{{ copy.emptyTitle }}</h2>
|
||||
<p>{{ copy.emptyDescription }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="nova-tenancy-grid">
|
||||
<article
|
||||
v-for="tenant in tenants"
|
||||
:key="tenant.key"
|
||||
class="nova-tenancy-card"
|
||||
:class="{ 'nova-tenancy-card--selected': isSelected(tenant) }"
|
||||
:style="tenantStyle(tenant)"
|
||||
:aria-current="isSelected(tenant) ? 'true' : undefined"
|
||||
>
|
||||
<div class="nova-tenancy-card__accent" aria-hidden="true"></div>
|
||||
<div class="nova-tenancy-card__header">
|
||||
<div class="nova-tenancy-card__logo">
|
||||
<img
|
||||
v-if="tenant.logoUrl && !failedImages.has(String(tenant.key))"
|
||||
:src="tenant.logoUrl"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
@error="markImageFailed(tenant.key)"
|
||||
/>
|
||||
<span v-else>{{ initial(tenant.title) }}</span>
|
||||
</div>
|
||||
|
||||
<span v-if="tenant.badge" class="nova-tenancy-badge">{{ tenant.badge }}</span>
|
||||
<span v-else-if="isSelected(tenant)" class="nova-tenancy-check" :title="copy.selected">
|
||||
<svg viewBox="0 0 20 20" aria-hidden="true"><path d="m5 10 3 3 7-7" /></svg>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="nova-tenancy-card__body">
|
||||
<h2>{{ tenant.title }}</h2>
|
||||
<p v-if="tenant.description">{{ tenant.description }}</p>
|
||||
<p v-else class="nova-tenancy-card__key">#{{ tenant.key }}</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="nova-tenancy-select"
|
||||
:class="{ 'nova-tenancy-select--selected': isSelected(tenant) }"
|
||||
:disabled="workingKey !== null || isSelected(tenant)"
|
||||
:aria-busy="workingKey === String(tenant.key)"
|
||||
@click="selectTenant(tenant)"
|
||||
>
|
||||
<span v-if="workingKey === String(tenant.key)" class="nova-tenancy-spinner" aria-hidden="true"></span>
|
||||
<span>{{ isSelected(tenant) ? copy.selected : copy.select }}</span>
|
||||
<svg v-if="!isSelected(tenant)" viewBox="0 0 20 20" aria-hidden="true">
|
||||
<path d="M4 10h12m-4-4 4 4-4 4" />
|
||||
</svg>
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<nav v-if="meta.lastPage > 1" class="nova-tenancy-pagination" aria-label="Pagination">
|
||||
<button type="button" :disabled="meta.currentPage <= 1 || loading" @click="goToPage(meta.currentPage - 1)">
|
||||
{{ copy.previous }}
|
||||
</button>
|
||||
<span>{{ meta.currentPage }} / {{ meta.lastPage }}</span>
|
||||
<button type="button" :disabled="meta.currentPage >= meta.lastPage || loading" @click="goToPage(meta.currentPage + 1)">
|
||||
{{ copy.next }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { sameTenant, tenantInitial, tenantStyle as resolveTenantStyle } from '../tenantState'
|
||||
|
||||
const configuration = Nova.config('novaTenancy') || {}
|
||||
const copy = configuration.copy || {}
|
||||
const tenants = ref([])
|
||||
const currentKey = ref(configuration.current?.key ?? null)
|
||||
const search = ref('')
|
||||
const loading = ref(true)
|
||||
const error = ref(false)
|
||||
const workingKey = ref(null)
|
||||
const failedImages = reactive(new Set())
|
||||
const meta = reactive({
|
||||
currentPage: 1,
|
||||
lastPage: 1,
|
||||
perPage: Number(configuration.perPage || 12),
|
||||
total: 0,
|
||||
})
|
||||
let debounceTimer
|
||||
let requestSequence = 0
|
||||
|
||||
const activeTenant = computed(() => {
|
||||
const visible = tenants.value.find(tenant => isSelected(tenant))
|
||||
return (
|
||||
visible ||
|
||||
(sameTenant(configuration.current?.key ?? null, currentKey.value)
|
||||
? configuration.current
|
||||
: null)
|
||||
)
|
||||
})
|
||||
|
||||
const loadTenants = async () => {
|
||||
const sequence = ++requestSequence
|
||||
loading.value = true
|
||||
error.value = false
|
||||
|
||||
try {
|
||||
const response = await Nova.request().get(
|
||||
`${configuration.apiBase || '/nova-vendor/nova-tenancy'}/tenants`,
|
||||
{ params: { search: search.value || undefined, page: meta.currentPage, perPage: meta.perPage } }
|
||||
)
|
||||
|
||||
if (sequence !== requestSequence) return
|
||||
|
||||
tenants.value = response.data.data
|
||||
currentKey.value = response.data.currentKey
|
||||
Object.assign(meta, response.data.meta)
|
||||
} catch {
|
||||
if (sequence === requestSequence) error.value = true
|
||||
} finally {
|
||||
if (sequence === requestSequence) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const selectTenant = async tenant => {
|
||||
if (workingKey.value !== null || isSelected(tenant)) return
|
||||
|
||||
workingKey.value = String(tenant.key)
|
||||
|
||||
try {
|
||||
const response = await Nova.request().post(
|
||||
`${configuration.apiBase || '/nova-vendor/nova-tenancy'}/current`,
|
||||
{ tenant: String(tenant.key) }
|
||||
)
|
||||
currentKey.value = response.data.current.key
|
||||
Nova.$emit('nova-tenancy:changed', response.data)
|
||||
Nova.visit(response.data.redirectTo || '/')
|
||||
} catch {
|
||||
Nova.$emit('error', copy.error || 'Unable to select tenant.')
|
||||
} finally {
|
||||
workingKey.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const goToPage = page => {
|
||||
meta.currentPage = page
|
||||
loadTenants()
|
||||
}
|
||||
|
||||
const isSelected = tenant => sameTenant(tenant.key, currentKey.value)
|
||||
const initial = tenantInitial
|
||||
const tenantStyle = resolveTenantStyle
|
||||
const markImageFailed = key => failedImages.add(String(key))
|
||||
|
||||
watch(search, () => {
|
||||
clearTimeout(debounceTimer)
|
||||
debounceTimer = setTimeout(() => {
|
||||
meta.currentPage = 1
|
||||
loadTenants()
|
||||
}, Number(configuration.searchDebounce || 300))
|
||||
})
|
||||
|
||||
onMounted(loadTenants)
|
||||
onBeforeUnmount(() => clearTimeout(debounceTimer))
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
export const sameTenant = (left, right) =>
|
||||
left !== null && right !== null && String(left) === String(right)
|
||||
|
||||
export const tenantInitial = title =>
|
||||
String(title || 'T').trim().charAt(0).toLocaleUpperCase()
|
||||
|
||||
export const tenantStyle = tenant => ({
|
||||
'--tenant-accent': tenant.accent || '#7c3aed',
|
||||
})
|
||||
|
||||
export const currentLogoUrl = (apiBase, tenantKey, revision) =>
|
||||
`${apiBase}/current/logo?tenant=${encodeURIComponent(tenantKey ?? 'none')}&v=${revision}`
|
||||
@@ -0,0 +1,25 @@
|
||||
import NovaTenancy from './pages/NovaTenancy.vue'
|
||||
import TenantAppLogo from './components/TenantAppLogo.vue'
|
||||
|
||||
Nova.inertia('NovaTenancy', NovaTenancy)
|
||||
|
||||
Nova.booting(app => {
|
||||
if (Nova.config('novaTenancy')?.branding?.enabled !== false) {
|
||||
app.component('AppLogo', TenantAppLogo)
|
||||
}
|
||||
})
|
||||
|
||||
Nova.request().interceptors.response.use(
|
||||
response => response,
|
||||
error => {
|
||||
if (
|
||||
error.response?.status === 409 &&
|
||||
error.response?.data?.code === 'tenant_selection_required'
|
||||
) {
|
||||
const selectorPath = Nova.config('novaTenancy')?.selectorPath || '/nova-tenancy'
|
||||
Nova.visit(selectorPath)
|
||||
}
|
||||
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
Reference in new issue
Block a user