Skip to content

Commit

Permalink
Change openURL by OpenURI, accepting URI instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Jan 29, 2024
1 parent ff1fecd commit cb1e582
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export class StudioApiImpl implements StudioAPI {
return 'pong';
}

async openURL(url: string): Promise<boolean> {
return await podmanDesktopApi.env.openExternal(podmanDesktopApi.Uri.parse(url));
async openURI(uri: podmanDesktopApi.Uri): Promise<boolean> {
return await podmanDesktopApi.env.openExternal(uri);
}

async getPullingStatus(recipeId: string): Promise<RecipeStatus> {
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/lib/markdown/LinkComponent.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<script lang="ts">
import { studioClient } from '/@/utils/client.js';
import * as podmanDesktopApi from '@podman-desktop/api';
export let href: string = "";
export let title: string | undefined = undefined;
export let text: string = "";
const onClick = () => {
studioClient.openURL(href);
studioClient.openURI(podmanDesktopApi.Uri.parse(href));
}
</script>
<!-- href set to void operator to avoid any redirect -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import ListItemButtonIcon from "../../button/ListItemButtonIcon.svelte";
import { studioClient } from "/@/utils/client";
import Modal from "../../Modal.svelte";
import Button from "../../button/Button.svelte";
import * as podmanDesktopApi from '@podman-desktop/api';
export let object: ModelInfo;
let deleteConfirmVisible: boolean = false;
Expand All @@ -21,7 +23,7 @@ async function goDeleteModel() {
function openModelFolder() {
if (object && object.file) {
studioClient.openURL('file://'+object.file.path);
studioClient.openURI(podmanDesktopApi.Uri.file(object.file.path));
}
}
</script>
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/pages/Recipe.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { getDisplayName } from '/@/utils/versionControlUtils';
import { getIcon } from '/@/utils/categoriesUtils';
import RecipeModels from './RecipeModels.svelte';
import { catalog } from '/@/stores/catalog';
import { recipes } from '/@/stores/recipe';
import { recipes } from '/@/stores/recipe';
import * as podmanDesktopApi from '@podman-desktop/api';
export let recipeId: string;
Expand All @@ -31,7 +32,7 @@ const onPullingRequest = async () => {
const onClickRepository = () => {
if (recipe) {
studioClient.openURL(recipe.repository);
studioClient.openURI(podmanDesktopApi.Uri.parse(recipe.repository));
}
}
</script>
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/src/StudioAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import type { ModelInfo } from './models/IModelInfo';
import type { QueryState } from './models/IPlaygroundQueryState';
import type { Catalog } from './models/ICatalog';
import type { PlaygroundState } from './models/IPlaygroundState';
import * as podmanDesktopApi from '@podman-desktop/api';

Check failure on line 6 in packages/shared/src/StudioAPI.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / windows-2022

'@podman-desktop/api' should be listed in the project's dependencies. Run 'npm i -S @podman-desktop/api' to add it

Check failure on line 6 in packages/shared/src/StudioAPI.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / windows-2022

All imports in the declaration are only used as types. Use `import type`

Check failure on line 6 in packages/shared/src/StudioAPI.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / ubuntu-22.04

'@podman-desktop/api' should be listed in the project's dependencies. Run 'npm i -S @podman-desktop/api' to add it

Check failure on line 6 in packages/shared/src/StudioAPI.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / ubuntu-22.04

All imports in the declaration are only used as types. Use `import type`

Check failure on line 6 in packages/shared/src/StudioAPI.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / macos-12

'@podman-desktop/api' should be listed in the project's dependencies. Run 'npm i -S @podman-desktop/api' to add it

Check failure on line 6 in packages/shared/src/StudioAPI.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / macos-12

All imports in the declaration are only used as types. Use `import type`

export abstract class StudioAPI {
abstract ping(): Promise<string>;
abstract getCatalog(): Promise<Catalog>;
abstract getPullingStatus(recipeId: string): Promise<RecipeStatus>;
abstract getPullingStatuses(): Promise<Map<string, RecipeStatus>>;
abstract pullApplication(recipeId: string): Promise<void>;
abstract openURL(url: string): Promise<boolean>;
abstract openURI(uri: podmanDesktopApi.Uri): Promise<boolean>;
/**
* Get the information of models saved locally into the user's directory
*/
Expand Down

0 comments on commit cb1e582

Please sign in to comment.