Skip to content

Commit 99ad0cd

Browse files
fix(clients): hide disconnected environments when adding projects
1 parent bd89c13 commit 99ad0cd

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

‎apps/mobile/src/features/projects/AddProjectScreen.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ function useEnvironmentOptions(): ReadonlyArray<EnvironmentOption> {
405405
supportsCloneTracking: config?.environment.capabilities.projectCloneTracking === true,
406406
};
407407
});
408-
return Arr.sort(options, environmentOptionOrder);
408+
return Arr.sort(
409+
options.filter((environment) => canCreateProjectInEnvironment(environment.connectionState)),
410+
environmentOptionOrder,
411+
);
409412
}, [connectedEnvironments, savedConnectionsById, serverConfigByEnvironmentId]);
410413
}
411414

‎apps/web/src/components/CommandPalette.tsx‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -963,21 +963,23 @@ function OpenCommandPaletteDialog(props: {
963963
);
964964

965965
const addProjectEnvironmentOptions = useMemo(() => {
966-
const options = environments.map((environment): AddProjectEnvironmentOption => {
967-
const isPrimary = environment.entry.target._tag === "PrimaryConnectionTarget";
968-
return {
969-
environmentId: environment.environmentId,
970-
label: resolveEnvironmentOptionLabel({
971-
isPrimary,
966+
const options = environments
967+
.filter((environment) => canCreateProjectInEnvironment(environment.connection.phase))
968+
.map((environment): AddProjectEnvironmentOption => {
969+
const isPrimary = environment.entry.target._tag === "PrimaryConnectionTarget";
970+
return {
972971
environmentId: environment.environmentId,
973-
runtimeLabel: environment.label,
974-
}),
975-
isPrimary,
976-
machine: resolveEnvironmentMachineKind(environment.serverConfig),
977-
isConnected: canCreateProjectInEnvironment(environment.connection.phase),
978-
status: connectionStatusText(environment.connection),
979-
};
980-
});
972+
label: resolveEnvironmentOptionLabel({
973+
isPrimary,
974+
environmentId: environment.environmentId,
975+
runtimeLabel: environment.label,
976+
}),
977+
isPrimary,
978+
machine: resolveEnvironmentMachineKind(environment.serverConfig),
979+
isConnected: canCreateProjectInEnvironment(environment.connection.phase),
980+
status: connectionStatusText(environment.connection),
981+
};
982+
});
981983

982984
options.sort((left, right) => {
983985
if (left.isPrimary !== right.isPrimary) {
@@ -1658,7 +1660,7 @@ function OpenCommandPaletteDialog(props: {
16581660
);
16591661

16601662
const openAddProjectFlow = useCallback(() => {
1661-
// With no environment at all there is nothing to browse, so the only
1663+
// With no connected environment there is nothing to browse, so the only
16621664
// useful next step is connecting one.
16631665
if (addProjectEnvironmentOptions.length === 0) {
16641666
setOpen(false);

0 commit comments

Comments
 (0)