|
3 | 3 | ------------------------------------------------------------------------------------------------>
|
4 | 4 | <script lang="ts">
|
5 | 5 | import { createEventDispatcher } from "svelte";
|
6 |
| - import HoverOptions from "../components/HoverOptions.svelte"; |
7 |
| - import type { HoverOption } from "../protocol/components"; |
8 | 6 | import type { GitpodPortObject, PortCommand } from "../protocol/gitpod";
|
9 |
| - import { commandIconMap, getCommands, getNLSTitle } from "../utils/commands"; |
| 7 | + import PortHoverActions from "./PortHoverActions.svelte"; |
10 | 8 |
|
11 | 9 | export let port: GitpodPortObject;
|
12 | 10 |
|
13 |
| - const copyOpt: HoverOption = { |
14 |
| - icon: "copy", |
15 |
| - title: "Copy URL", |
16 |
| - command: "urlCopy", |
17 |
| - }; |
18 |
| -
|
19 |
| - function getHoverOption(port?: GitpodPortObject) { |
20 |
| - if (port == null) { |
21 |
| - return []; |
22 |
| - } |
23 |
| - const opts: HoverOption[] = getCommands(port).map((e) => ({ |
24 |
| - icon: commandIconMap[e], |
25 |
| - title: getNLSTitle(e), |
26 |
| - command: e, |
27 |
| - })); |
28 |
| - opts.unshift(copyOpt); |
29 |
| - return opts; |
30 |
| - } |
31 |
| -
|
32 |
| - $: hoverOpts = getHoverOption(port); |
33 | 11 | const dispatch = createEventDispatcher<{
|
34 | 12 | command: { command: PortCommand; port: GitpodPortObject };
|
35 | 13 | }>();
|
36 |
| - function onHoverCommand(command: string) { |
37 |
| - dispatch("command", { command: command as PortCommand, port }); |
38 |
| - } |
39 | 14 | function openAddr(e: Event) {
|
40 | 15 | e.preventDefault();
|
41 | 16 | if (port.status.exposed.url) {
|
|
44 | 19 | }
|
45 | 20 | </script>
|
46 | 21 |
|
47 |
| -<HoverOptions |
| 22 | +<PortHoverActions |
| 23 | + {port} |
48 | 24 | alwaysShow
|
49 |
| - options={hoverOpts} |
50 |
| - on:command={(e) => { |
51 |
| - onHoverCommand(e.detail); |
52 |
| - }} |
| 25 | + on:command={(e) => { console.log(e); dispatch("command", { command: e.detail, port}) }} |
53 | 26 | >
|
54 | 27 | <a on:click={(e) => { openAddr(e) }} href={port.status.exposed.url}>{port.status.exposed.url}</a>
|
55 |
| -</HoverOptions> |
| 28 | +</PortHoverActions> |
56 | 29 |
|
57 | 30 | <style>
|
58 | 31 | a {
|
59 | 32 | color: var(--vscode-foreground);
|
60 | 33 | overflow: hidden;
|
61 | 34 | text-overflow: ellipsis;
|
62 | 35 | white-space: nowrap;
|
63 |
| - display: inline-block; |
64 | 36 | }
|
65 | 37 | a:focus {
|
66 | 38 | outline: none;
|
|
0 commit comments