Skip to content

Commit

Permalink
SimpleView: only show service message when there is a port (#9)
Browse files Browse the repository at this point in the history
Do not show an error message when a user has not yet typed in a port.

---------

Signed-off-by: Tyler Smalley <tyler@tailscale.com>
Co-authored-by: Tyler Smalley <tyler@tailscale.com>
  • Loading branch information
marwan-at-work and tylersmalley committed Jun 7, 2023
1 parent 4a14fbe commit ddbe013
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/webviews/serve-panel/simple-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,28 @@ export const SimpleView = () => {
</Tooltip>
)}
</div>
<div className="pt-4">
{data?.Services[port] ? (
<div className="italic">
Port {port} is currently started by "{data?.Services[port]}"
</div>
) : (
<div className="text-errorForeground">
It seems there's no service currently utilizing port {port}. Please ensure you start a
local service that is bound to port {port}.
</div>
)}
</div>
<div className="pt-4">{persistedPort && port === persistedPort ? renderService() : ''}</div>
</form>
);
}

function renderService(): JSX.Element {
if (data?.Services[persistedPort]) {
return (
<div className="italic">
Port {persistedPort} is currently started by "{data?.Services[persistedPort]}"
</div>
);
}

return (
<div className="text-errorForeground">
It seems there's no service currently utilizing port {persistedPort}. Please ensure you
start a local service that is bound to port {persistedPort}.
</div>
);
}

async function handleReset(e) {
e.preventDefault();
e.stopPropagation();
Expand Down

0 comments on commit ddbe013

Please sign in to comment.