Archived
fix: avoid showing local projects for remote machines
This commit is contained in:
@@ -21,12 +21,12 @@ export class MachineList extends LitElement {
|
||||
<div
|
||||
class=${`action-row ${this.selected?.id === machine.id ? "selected" : ""}`}
|
||||
tabindex="0"
|
||||
title=${machine.baseUrl ?? machine.name}
|
||||
title=${machine.kind === "remote" ? "Remote project browsing is not available yet" : machine.baseUrl ?? machine.name}
|
||||
@click=${(event: MouseEvent) => { activateSelectableRow(event, () => this.onSelect?.(machine)); }}
|
||||
@keydown=${(event: KeyboardEvent) => { activateSelectableRowFromKeyboard(event, () => this.onSelect?.(machine)); }}
|
||||
>
|
||||
<div class="action-main">
|
||||
<span class="action-name">${machine.name}</span><small>${machine.kind === "local" ? "Local Pi Web" : machine.baseUrl}</small>
|
||||
<span class="action-name">${machine.name}</span><small>${machine.kind === "local" ? "Local Pi Web" : `${machine.baseUrl ?? "Remote Pi Web"} · projects coming soon`}</small>
|
||||
</div>
|
||||
</div>
|
||||
`)}
|
||||
|
||||
@@ -315,6 +315,7 @@ export class PiWebApp extends LitElement {
|
||||
|
||||
private async restoreRoute(updateUrl: boolean) {
|
||||
const route = readRoute();
|
||||
await this.restoreRouteMachine(route, updateUrl);
|
||||
const selectedFilePath = readNamespacedString(queryNamespace("core:workspace.files"), "file");
|
||||
const selectedDiffPath = readNamespacedString(queryNamespace("core:workspace.git"), "diff");
|
||||
const selectedTerminalId = readNamespacedString(TERMINAL_ROUTE_NAMESPACE, "terminal");
|
||||
@@ -342,8 +343,17 @@ export class PiWebApp extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
private async restoreRouteMachine(route: AppRoute, updateUrl: boolean): Promise<void> {
|
||||
const routeMachineId = route.machineId ?? "local";
|
||||
if (this.state.selectedMachine?.id === routeMachineId) return;
|
||||
const machine = this.state.machines.find((candidate) => candidate.id === routeMachineId);
|
||||
if (machine === undefined) return;
|
||||
await this.machines.selectMachine(machine, { updateUrl });
|
||||
}
|
||||
|
||||
private routeMatchesCurrentSelection(route: AppRoute): boolean {
|
||||
return route.workspaceId !== undefined
|
||||
return (route.machineId ?? "local") === (this.state.selectedMachine?.id ?? "local")
|
||||
&& route.workspaceId !== undefined
|
||||
&& route.workspaceId !== ""
|
||||
&& this.state.selectedProject?.id === route.projectId
|
||||
&& this.state.selectedWorkspace?.id === route.workspaceId
|
||||
|
||||
@@ -19,7 +19,7 @@ export class MachineController {
|
||||
}
|
||||
}
|
||||
|
||||
async selectMachine(machine: Machine): Promise<void> {
|
||||
async selectMachine(machine: Machine, options: { updateUrl?: boolean | undefined } = {}): Promise<void> {
|
||||
if (this.getState().selectedMachine?.id === machine.id) return;
|
||||
this.setState({
|
||||
selectedMachine: machine,
|
||||
@@ -35,7 +35,7 @@ export class MachineController {
|
||||
activity: undefined,
|
||||
...resetWorkspaceScopedState(),
|
||||
});
|
||||
this.updateUrl();
|
||||
if (options.updateUrl !== false) this.updateUrl();
|
||||
await this.projects.loadProjects();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,11 @@ export class ProjectController {
|
||||
constructor(private readonly getState: GetState, private readonly setState: SetState, private readonly workspaces: WorkspaceController) {}
|
||||
|
||||
async loadProjects() {
|
||||
const machine = this.getState().selectedMachine;
|
||||
if (machine?.kind === "remote") {
|
||||
this.setState({ projects: [], workspacesByProjectId: {}, error: "Remote project browsing is not available yet." });
|
||||
return;
|
||||
}
|
||||
this.setState({ error: "", isLoadingProjects: true });
|
||||
try {
|
||||
const projects = await api.projects();
|
||||
@@ -20,6 +25,10 @@ export class ProjectController {
|
||||
}
|
||||
|
||||
async addProject(path: string, create?: boolean) {
|
||||
if (this.getState().selectedMachine?.kind === "remote") {
|
||||
this.setState({ error: "Adding projects to remote machines is not available yet." });
|
||||
return;
|
||||
}
|
||||
if (path.trim() === "") return;
|
||||
try {
|
||||
const project = await api.addProject(path.trim(), undefined, create);
|
||||
|
||||
Reference in New Issue
Block a user