fix(site): hide "Show parent apps" when no running or starting devcontainers (#19200)

Fixes https://github.com/coder/coder/issues/19199

We now hide the "Show parent apps" button when there are no running or
starting devcontainers.
This commit is contained in:
Danielle Maywood
2025-08-06 18:24:38 +01:00
committed by GitHub
parent 3024bdebcb
commit 1c70d32ef3
2 changed files with 48 additions and 16 deletions
@@ -286,10 +286,43 @@ export const GroupApp: Story = {
};
export const Devcontainer: Story = {
beforeEach: () => {
spyOn(API, "getAgentContainers").mockResolvedValue({
devcontainers: [M.MockWorkspaceAgentDevcontainer],
containers: [M.MockWorkspaceAgentContainer],
});
parameters: {
queries: [
{
key: ["agents", M.MockWorkspaceAgent.id, "containers"],
data: {
devcontainers: [M.MockWorkspaceAgentDevcontainer],
containers: [M.MockWorkspaceAgentContainer],
},
},
],
webSocket: [],
},
};
export const FoundDevcontainer: Story = {
args: {
agent: {
...M.MockWorkspaceAgentReady,
},
},
parameters: {
queries: [
{
key: ["agents", M.MockWorkspaceAgentReady.id, "containers"],
data: {
devcontainers: [
{
...M.MockWorkspaceAgentDevcontainer,
status: "stopped",
container: undefined,
agent: undefined,
},
],
containers: [],
},
},
],
webSocket: [],
},
};
+10 -11
View File
@@ -137,17 +137,16 @@ export const AgentRow: FC<AgentRowProps> = ({
// This is used to show the parent apps of the devcontainer.
const [showParentApps, setShowParentApps] = useState(false);
let shouldDisplayAppsSection = shouldDisplayAgentApps;
if (
devcontainers &&
devcontainers.find(
// We only want to hide the parent apps by default when there are dev
// containers that are either starting or running. If they are all in
// the stopped state, it doesn't make sense to hide the parent apps.
const anyRunningOrStartingDevcontainers =
devcontainers?.find(
(dc) => dc.status === "running" || dc.status === "starting",
) !== undefined &&
!showParentApps
) {
) !== undefined;
// We only want to hide the parent apps by default when there are dev
// containers that are either starting or running. If they are all in
// the stopped state, it doesn't make sense to hide the parent apps.
let shouldDisplayAppsSection = shouldDisplayAgentApps;
if (anyRunningOrStartingDevcontainers && !showParentApps) {
shouldDisplayAppsSection = false;
}
@@ -187,7 +186,7 @@ export const AgentRow: FC<AgentRowProps> = ({
</div>
<div className="flex items-center gap-2">
{devcontainers && devcontainers.length > 0 && (
{anyRunningOrStartingDevcontainers && (
<Button
variant="outline"
size="sm"