Skip to content

Commit 1c70d32

Browse files
fix(site): hide "Show parent apps" when no running or starting devcontainers (#19200)
Fixes #19199 We now hide the "Show parent apps" button when there are no running or starting devcontainers.
1 parent 3024bde commit 1c70d32

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
lines changed

site/src/modules/resources/AgentRow.stories.tsx

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,43 @@ export const GroupApp: Story = {
286286
};
287287

288288
export const Devcontainer: Story = {
289-
beforeEach: () => {
290-
spyOn(API, "getAgentContainers").mockResolvedValue({
291-
devcontainers: [M.MockWorkspaceAgentDevcontainer],
292-
containers: [M.MockWorkspaceAgentContainer],
293-
});
289+
parameters: {
290+
queries: [
291+
{
292+
key: ["agents", M.MockWorkspaceAgent.id, "containers"],
293+
data: {
294+
devcontainers: [M.MockWorkspaceAgentDevcontainer],
295+
containers: [M.MockWorkspaceAgentContainer],
296+
},
297+
},
298+
],
299+
webSocket: [],
300+
},
301+
};
302+
303+
export const FoundDevcontainer: Story = {
304+
args: {
305+
agent: {
306+
...M.MockWorkspaceAgentReady,
307+
},
308+
},
309+
parameters: {
310+
queries: [
311+
{
312+
key: ["agents", M.MockWorkspaceAgentReady.id, "containers"],
313+
data: {
314+
devcontainers: [
315+
{
316+
...M.MockWorkspaceAgentDevcontainer,
317+
status: "stopped",
318+
container: undefined,
319+
agent: undefined,
320+
},
321+
],
322+
containers: [],
323+
},
324+
},
325+
],
326+
webSocket: [],
294327
},
295328
};

site/src/modules/resources/AgentRow.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,16 @@ export const AgentRow: FC<AgentRowProps> = ({
137137
// This is used to show the parent apps of the devcontainer.
138138
const [showParentApps, setShowParentApps] = useState(false);
139139

140-
let shouldDisplayAppsSection = shouldDisplayAgentApps;
141-
if (
142-
devcontainers &&
143-
devcontainers.find(
144-
// We only want to hide the parent apps by default when there are dev
145-
// containers that are either starting or running. If they are all in
146-
// the stopped state, it doesn't make sense to hide the parent apps.
140+
const anyRunningOrStartingDevcontainers =
141+
devcontainers?.find(
147142
(dc) => dc.status === "running" || dc.status === "starting",
148-
) !== undefined &&
149-
!showParentApps
150-
) {
143+
) !== undefined;
144+
145+
// We only want to hide the parent apps by default when there are dev
146+
// containers that are either starting or running. If they are all in
147+
// the stopped state, it doesn't make sense to hide the parent apps.
148+
let shouldDisplayAppsSection = shouldDisplayAgentApps;
149+
if (anyRunningOrStartingDevcontainers && !showParentApps) {
151150
shouldDisplayAppsSection = false;
152151
}
153152

@@ -187,7 +186,7 @@ export const AgentRow: FC<AgentRowProps> = ({
187186
</div>
188187

189188
<div className="flex items-center gap-2">
190-
{devcontainers && devcontainers.length > 0 && (
189+
{anyRunningOrStartingDevcontainers && (
191190
<Button
192191
variant="outline"
193192
size="sm"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy