Skip to content
TypeScript

fix(clients): hide disconnected environments when adding projects (#14490)

Julius Marminge7c67876983ad
diff --git a/apps/mobile/src/features/projects/AddProjectScreen.tsx b/apps/mobile/src/features/projects/AddProjectScreen.tsx
index 84a2938785d..5b38cfa7bdd 100644
--- a/apps/mobile/src/features/projects/AddProjectScreen.tsx
+++ b/apps/mobile/src/features/projects/AddProjectScreen.tsx
@@ -405,7 +405,10 @@ function useEnvironmentOptions(): ReadonlyArray<EnvironmentOption> {
supportsCloneTracking: config?.environment.capabilities.projectCloneTracking === true,
};
});
- return Arr.sort(options, environmentOptionOrder);
+ return Arr.sort(
+ options.filter((environment) => canCreateProjectInEnvironment(environment.connectionState)),
+ environmentOptionOrder,
+ );
}, [connectedEnvironments, savedConnectionsById, serverConfigByEnvironmentId]);
}
diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx
index 0825c5cb92c..1c3fe81ac63 100644
--- a/apps/web/src/components/CommandPalette.tsx
+++ b/apps/web/src/components/CommandPalette.tsx
@@ -963,21 +963,23 @@ function OpenCommandPaletteDialog(props: {
);
const addProjectEnvironmentOptions = useMemo(() => {
- const options = environments.map((environment): AddProjectEnvironmentOption => {
- const isPrimary = environment.entry.target._tag === "PrimaryConnectionTarget";
- return {
- environmentId: environment.environmentId,
- label: resolveEnvironmentOptionLabel({
- isPrimary,
+ const options = environments
+ .filter((environment) => canCreateProjectInEnvironment(environment.connection.phase))
+ .map((environment): AddProjectEnvironmentOption => {
+ const isPrimary = environment.entry.target._tag === "PrimaryConnectionTarget";
+ return {
environmentId: environment.environmentId,
- runtimeLabel: environment.label,
- }),
- isPrimary,
- machine: resolveEnvironmentMachineKind(environment.serverConfig),
- isConnected: canCreateProjectInEnvironment(environment.connection.phase),
- status: connectionStatusText(environment.connection),
- };
- });
+ label: resolveEnvironmentOptionLabel({
+ isPrimary,
+ environmentId: environment.environmentId,
+ runtimeLabel: environment.label,
+ }),
+ isPrimary,
+ machine: resolveEnvironmentMachineKind(environment.serverConfig),
+ isConnected: canCreateProjectInEnvironment(environment.connection.phase),
+ status: connectionStatusText(environment.connection),
+ };
+ });
options.sort((left, right) => {
if (left.isPrimary !== right.isPrimary) {
@@ -1658,7 +1660,7 @@ function OpenCommandPaletteDialog(props: {
);
const openAddProjectFlow = useCallback(() => {
- // With no environment at all there is nothing to browse, so the only
+ // With no connected environment there is nothing to browse, so the only
// useful next step is connecting one.
if (addProjectEnvironmentOptions.length === 0) {
setOpen(false);