Skip to content

Commit

Permalink
fix: filter out log if logStreamUrl is not configured
Browse files Browse the repository at this point in the history
Signed-off-by: Akiff Manji <[email protected]>
  • Loading branch information
amanji committed Jan 10, 2025
1 parent 2b6b472 commit 2e3909f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
17 changes: 10 additions & 7 deletions services/tenant-ui/frontend/src/components/layout/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</h1>
<!-- eslint-disable-next-line @intlify/vue-i18n/no-raw-text -->
<h1 class="sidebar-app-title small">T</h1>
<PanelMenu :model="items" class="mt-5">
<PanelMenu :model="sidebarItems" class="mt-5">
<template #item="{ item }">
<PanelMenuItemLink :item="item" />
</template>
Expand All @@ -19,16 +19,16 @@ import { ref } from 'vue';
import PanelMenu from 'primevue/panelmenu';
import ProgressSpinner from 'primevue/progressspinner';
import { storeToRefs } from 'pinia';
import { useTenantStore } from '../../store';
import { useI18n } from 'vue-i18n';
import { useConfigStore, useTenantStore } from '../../store';
import PanelMenuItemLink from '../common/PanelMenuItemLink.vue';
const { t } = useI18n();
const { config } = useConfigStore();
// tenant should be loaded by login...
const { tenant, loading } = storeToRefs(useTenantStore());
const items = ref([
const sidebarItems = [
{
label: t('dashboard.dashboard'),
icon: 'pi pi-fw pi-chart-bar',
Expand Down Expand Up @@ -103,11 +103,14 @@ const items = ref([
icon: 'pi pi-fw pi-question-circle',
route: '/about',
},
];
{
const { logStreamUrl } = config?.frontend;

Check failure on line 108 in services/tenant-ui/frontend/src/components/layout/Sidebar.vue

View workflow job for this annotation

GitHub Actions / Build Tenant UI

Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError
if (logStreamUrl) {
sidebarItems.push({
label: t('log.log'),
icon: 'pi pi-fw pi-file',
route: '/log',
},
]);
});
}
</script>
7 changes: 7 additions & 0 deletions services/tenant-ui/frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ async function loadApp() {
console.warn('Matomo not configured');
}

// Log Setup
const { logStreamUrl } = configStore?.config?.frontend;

Check failure on line 71 in services/tenant-ui/frontend/src/main.ts

View workflow job for this annotation

GitHub Actions / Build Tenant UI

Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError
if (!logStreamUrl) {
console.warn('Log not configured');
router.removeRoute('Log');
}

// 4. load/initialize other components
app.use(i18n);
app.use(PrimeVue);
Expand Down
2 changes: 1 addition & 1 deletion services/tenant-ui/frontend/src/store/logStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const useLogStore = defineStore('log', () => {
}
if (!logStream.value) {
logStream.value = new WebSocket(
`${config.frontend.logStreamUrl}?token=${token}`
`${config?.frontend?.logStreamUrl}?token=${token}`
);
logStream.value.onopen = () => {
logStreamState.value = LogStreamState.OPEN;
Expand Down

0 comments on commit 2e3909f

Please sign in to comment.