fix(clients): hide disconnected environments when adding projects (#14490)
This commit is contained in:
1 parent
bd89c13020
commit
7c67876983
2 files changed
+21
-16
No files matched your search
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user