-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add routing and first pages #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <script lang="ts"> | ||
| import Dashboard from './component/Dashboard.svelte'; | ||
| import ResourcesCount from './component/ResourcesCount.svelte'; | ||
| import Navigation from './Navigation.svelte'; | ||
| import Route from './Route.svelte'; | ||
|
|
||
| let isMounted = false; | ||
| </script> | ||
|
|
||
| <Route path="/*" isAppMounted={isMounted} let:meta> | ||
| <main class="flex flex-col w-screen h-screen overflow-hidden bg-[var(--pd-content-bg)] text-base"> | ||
| <div class="flex flex-row w-full h-full overflow-hidden"> | ||
| <Navigation meta={meta} /> | ||
|
|
||
| <div class="flex flex-col w-full h-full"> | ||
| <Route path="/"> | ||
| <Dashboard /> | ||
| </Route> | ||
|
|
||
| <Route path="/resources-count"> | ||
| <ResourcesCount /> | ||
| </Route> | ||
| </div> | ||
| </div> | ||
| </main> | ||
| </Route> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <script lang="ts"> | ||
| import type { TinroRouteMeta } from 'tinro'; | ||
| import { SettingsNavItem } from '@podman-desktop/ui-svelte'; | ||
|
|
||
| interface Props { | ||
| meta: TinroRouteMeta; | ||
| } | ||
|
|
||
| const { meta }: Props = $props(); | ||
| </script> | ||
|
|
||
| <nav | ||
| class="z-1 w-leftsidebar min-w-leftsidebar shadow-xs flex-col justify-between flex transition-all duration-500 ease-in-out bg-[var(--pd-secondary-nav-bg)] border-[var(--pd-global-nav-bg-border)] border-r-[1px]" | ||
| aria-label="PreferencesNavigation"> | ||
| <div class="flex items-center"> | ||
| <div class="pt-4 pl-3 px-5 mb-10 flex items-center ml-[4px]"> | ||
| <p class="text-xl first-letter:uppercase text-[color:var(--pd-secondary-nav-header-text)]">Kubernetes</p> | ||
| </div> | ||
| </div> | ||
| <div class="h-full overflow-hidden hover:overflow-y-auto" style="margin-bottom:auto"> | ||
| <SettingsNavItem title="Dashboard" selected={meta.url === '/'} href="/" /> | ||
|
|
||
| <div class="pl-3 mt-2 ml-[4px]"> | ||
| <span class="text-[color:var(--pd-secondary-nav-header-text)]">STATES</span> | ||
| </div> | ||
|
|
||
| <SettingsNavItem title="Resources count" selected={meta.url === '/resources-count'} href="/resources-count" /> | ||
| </div> | ||
| </nav> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <script lang="ts"> | ||
| import { createRouteObject } from 'tinro/dist/tinro_lib'; | ||
| import type { TinroRouteMeta } from 'tinro'; | ||
| import type { RouterState } from './models/router-state'; | ||
| import type { WebviewApi } from '@podman-desktop/webview-api'; | ||
| import { getContext } from 'svelte'; | ||
|
|
||
| export let path = '/*'; | ||
| export let fallback = false; | ||
| export let redirect = false; | ||
| export let firstmatch = false; | ||
|
|
||
| export let isAppMounted: boolean = false; | ||
|
|
||
| let showContent = false; | ||
| let params: Record<string, string> = {}; | ||
| let meta: TinroRouteMeta = {} as TinroRouteMeta; | ||
|
|
||
| const webviewApi = getContext<WebviewApi>('WebviewApi'); | ||
|
|
||
| const route = createRouteObject({ | ||
| fallback, | ||
| onShow() { | ||
| showContent = true; | ||
| }, | ||
| onHide() { | ||
| showContent = false; | ||
| }, | ||
| onMeta(newMeta: TinroRouteMeta) { | ||
| meta = newMeta; | ||
| params = meta.params; | ||
|
|
||
| if (isAppMounted) { | ||
| saveRouterState({ url: newMeta.url }).catch(console.error); | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| $: route.update({ | ||
| path, | ||
| redirect, | ||
| firstmatch, | ||
| }); | ||
|
|
||
| async function saveRouterState(state: RouterState): Promise<void> { | ||
| await webviewApi.setState(state); | ||
| } | ||
| </script> | ||
|
|
||
| {#if showContent} | ||
| <slot params={params} meta={meta} /> | ||
| {/if} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <script lang="ts"> | ||
| import { NavPage } from '@podman-desktop/ui-svelte'; | ||
| </script> | ||
|
|
||
| <NavPage title="Dashboard" searchEnabled={false}></NavPage> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,19 @@ | ||
| <script lang="ts"> | ||
| import { getContext } from 'svelte'; | ||
| import { States } from '/@/state/states'; | ||
| import { NavPage } from '@podman-desktop/ui-svelte'; | ||
|
|
||
| const resourcesCount = getContext<States>(States).stateResourcesCountInfoUI; | ||
| </script> | ||
|
|
||
| {#if resourcesCount.data?.counts} | ||
| <ul> | ||
| {#each resourcesCount.data.counts as count, index (index)} | ||
| <li>{count.contextName}/{count.resourceName}: {count.count}</li> | ||
| {/each} | ||
| </ul> | ||
| {/if} | ||
| <NavPage title="Resources count" searchEnabled={false}> | ||
| {#snippet content()} | ||
| {#if resourcesCount.data?.counts} | ||
| <ul> | ||
| {#each resourcesCount.data.counts as count, index (index)} | ||
| <li>{count.contextName}/{count.resourceName}: {count.count}</li> | ||
| {/each} | ||
| </ul> | ||
| {/if} | ||
| {/snippet} | ||
| </NavPage> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /********************************************************************** | ||
| * Copyright (C) 2024 Red Hat, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ***********************************************************************/ | ||
|
|
||
| export interface RouterState { | ||
| url: string; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /********************************************************************** | ||
| * Copyright (C) 2023-2025 Red Hat, Inc. | ||
feloy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ***********************************************************************/ | ||
|
|
||
| declare module 'tinro/dist/tinro_lib'; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.