Skip to content

Commit

Permalink
Set tree label from optional server label
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Dec 5, 2024
1 parent 97c6da1 commit 721db72
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/providers/ServerConnectionPanelTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ export class ServerConnectionPanelTreeProvider extends TreeDataProviderBase<Serv
return getPanelVariableTreeItem(connectionOrVariable);
}

const serverLabel = this.serverManager.getServer(
connectionOrVariable.serverUrl,
false
)?.label;

return getPanelConnectionTreeItem(
connectionOrVariable,
getFirstSupportedConsoleType,
'demo.deephaven.io'
serverLabel
);
};

Expand Down
7 changes: 6 additions & 1 deletion src/providers/ServerConnectionTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ export class ServerConnectionTreeProvider extends TreeDataProviderBase<ServerCon
}

const hasUris = this.serverManager.hasConnectionUris(connectionOrUri);
const serverLabel = 'demo.deephaven.io';

const serverLabel = this.serverManager.getServer(
connectionOrUri.serverUrl,
false
)?.label;

const label =
serverLabel == null
? connectionOrUri.serverUrl.host
Expand Down
16 changes: 14 additions & 2 deletions src/services/ServerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,22 @@ export class ServerManager implements IServerManager {
/**
* Get the server state for the given URL.
* @param serverUrl The URL of the server to get.
* @param matchPort If `true`, include the port when matching the server URL. Defaults to `true`.
* @returns The server state, or `undefined` if no server with the given URL exists.
*/
getServer = (serverUrl: URL): ServerState | undefined => {
return this._serverMap.get(serverUrl);
getServer = (
serverUrl: URL,
matchPort: boolean = true
): ServerState | undefined => {
if (matchPort) {
return this._serverMap.get(serverUrl);
}

for (const server of this._serverMap.values()) {
if (server.url.hostname === serverUrl.hostname) {
return server;
}
}
};

getServers = ({
Expand Down
2 changes: 1 addition & 1 deletion src/types/serviceTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export interface IServerManager extends Disposable {
dhService: ConnectionState
) => Promise<void>;

getServer: (serverUrl: URL) => ServerState | undefined;
getServer: (serverUrl: URL, matchPort?: boolean) => ServerState | undefined;
getServers: (filter?: {
isRunning?: boolean;
hasConnections?: boolean;
Expand Down

0 comments on commit 721db72

Please sign in to comment.