Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1de952b

Browse files
authored
fix(site): allow updating workspace in TaskPage (#21316)
Relates to#20925 This PR modifies TaskPage to update an outdated workspace instead ofstarting it. Before, starting an outdated workspace where the templaterequired the active version would fail with the error "cannot usenon-active version: rbac: forbidden".For the case of a dormant workspace, I deemed it safe enough to simplyunset dormancy on an attempted start (ref:#21306). However, automaticallyupdating a workspace is a more risky option, so I instead elected togive the user the option of updating their workspace using the existingtooltip.**Note:** I made a change to the `WorkspaceOutdatedTooltip` componentsto allow it to have children so that the tooltip could trigger over awider element instead of just the info icon.```<🤖 AI Disclaimer>I got some help from Gemini 3 Flash in "Ask" mode.</🤖 AI Disclaimer>```
1 parent73253df commit1de952b

File tree

3 files changed

+79
-10
lines changed

3 files changed

+79
-10
lines changed

‎site/src/modules/workspaces/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip.tsx‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import {
1313
HelpTooltipLinksGroup,
1414
HelpTooltipText,
1515
HelpTooltipTitle,
16+
HelpTooltipTrigger,
1617
}from"components/HelpTooltip/HelpTooltip";
1718
import{InfoIcon,RotateCcwIcon}from"lucide-react";
1819
import{linkToTemplate,useLinks}from"modules/navigation";
19-
import{typeFC,useState}from"react";
20+
import{typeFC,typeReactNode,useState}from"react";
2021
import{useQuery}from"react-query";
2122
import{
2223
useWorkspaceUpdate,
@@ -25,20 +26,31 @@ import {
2526

2627
interfaceWorkspaceOutdatedTooltipProps{
2728
workspace:Workspace;
29+
children?:ReactNode;
2830
}
2931

30-
exportconstWorkspaceOutdatedTooltip:FC<WorkspaceOutdatedTooltipProps>=(
31-
props,
32-
)=>{
32+
exportconstWorkspaceOutdatedTooltip:FC<WorkspaceOutdatedTooltipProps>=({
33+
workspace,
34+
children,
35+
})=>{
3336
const[isOpen,setIsOpen]=useState(false);
3437

3538
return(
3639
<HelpTooltipopen={isOpen}onOpenChange={setIsOpen}>
37-
<HelpTooltipIconTriggersize="small"hoverEffect={false}>
38-
<InfoIconcss={styles.icon}/>
39-
<spanclassName="sr-only">Outdated info</span>
40-
</HelpTooltipIconTrigger>
41-
<WorkspaceOutdatedTooltipContentisOpen={isOpen}{...props}/>
40+
{children ?(
41+
<HelpTooltipTriggerasChild>
42+
<spanclassName="flex items-center gap-1.5 cursor-help">
43+
<InfoIconcss={styles.icon}size={14}/>
44+
<span>{children}</span>
45+
</span>
46+
</HelpTooltipTrigger>
47+
) :(
48+
<HelpTooltipIconTriggersize="small"hoverEffect={false}>
49+
<InfoIconcss={styles.icon}/>
50+
<spanclassName="sr-only">Outdated info</span>
51+
</HelpTooltipIconTrigger>
52+
)}
53+
<WorkspaceOutdatedTooltipContentisOpen={isOpen}workspace={workspace}/>
4254
</HelpTooltip>
4355
);
4456
};

‎site/src/pages/TaskPage/TaskPage.stories.tsx‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
}from"testHelpers/entities";
2020
import{
2121
withAuthProvider,
22+
withDashboardProvider,
2223
withGlobalSnackbar,
2324
withProxyProvider,
2425
withWebSocket,
@@ -65,7 +66,7 @@ const MockVSCodeApp: WorkspaceApp = {
6566
constmeta:Meta<typeofTaskPage>={
6667
title:"pages/TaskPage",
6768
component:TaskPage,
68-
decorators:[withProxyProvider(),withAuthProvider],
69+
decorators:[withProxyProvider(),withAuthProvider,withDashboardProvider],
6970
beforeEach:()=>{
7071
spyOn(API,"getTasks").mockResolvedValue(MockTasks);
7172
},
@@ -402,6 +403,50 @@ export const MainAppHealthy: Story = mainAppHealthStory("healthy");
402403
exportconstMainAppInitializing:Story=mainAppHealthStory("initializing");
403404
exportconstMainAppUnhealthy:Story=mainAppHealthStory("unhealthy");
404405

406+
exportconstOutdatedWorkspace:Story={
407+
// Given: an 'outdated' workspace (that is, the latest build does not use template's active version)
408+
parameters:{
409+
queries:[
410+
{
411+
key:["tasks",{owner:MockTask.owner_name}],
412+
data:[MockTask],
413+
},
414+
{
415+
key:["tasks",MockTask.owner_name,MockTask.id],
416+
data:MockTask,
417+
},
418+
{
419+
key:[
420+
"workspace",
421+
MockTask.owner_name,
422+
MockTask.workspace_name,
423+
"settings",
424+
],
425+
data:{
426+
...MockStoppedWorkspace,
427+
outdated:true,
428+
},
429+
},
430+
{
431+
key:[
432+
"workspaceBuilds",
433+
MockStoppedWorkspace.latest_build.id,
434+
"parameters",
435+
],
436+
data:[],
437+
},
438+
],
439+
},
440+
// Then: a tooltip should be displayed prompting the user to update the workspace.
441+
play:async({ canvasElement})=>{
442+
constcanvas=within(canvasElement);
443+
constoutdatedTooltip=awaitcanvas.findByTestId(
444+
"workspace-outdated-tooltip",
445+
);
446+
expect(outdatedTooltip).toBeVisible();
447+
},
448+
};
449+
405450
exportconstActive:Story={
406451
decorators:[withProxyProvider()],
407452
beforeEach:()=>{

‎site/src/pages/TaskPage/TaskPage.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { getAllAppsWithAgent } from "modules/tasks/apps";
2626
import{TasksSidebar}from"modules/tasks/TasksSidebar/TasksSidebar";
2727
import{WorkspaceErrorDialog}from"modules/workspaces/ErrorDialog/WorkspaceErrorDialog";
2828
import{WorkspaceBuildLogs}from"modules/workspaces/WorkspaceBuildLogs/WorkspaceBuildLogs";
29+
import{WorkspaceOutdatedTooltip}from"modules/workspaces/WorkspaceOutdatedTooltip/WorkspaceOutdatedTooltip";
2930
import{
3031
typeFC,
3132
typePropsWithChildren,
@@ -275,9 +276,20 @@ const WorkspaceNotRunning: FC<WorkspaceNotRunningProps> = ({
275276
<spanclassName="text-content-secondary text-sm">
276277
Apps and previous statuses are not available
277278
</span>
279+
{workspace.outdated&&(
280+
<div
281+
data-testid="workspace-outdated-tooltip"
282+
className="flex items-center gap-1.5 mt-1 text-content-secondary text-sm"
283+
>
284+
<WorkspaceOutdatedTooltipworkspace={workspace}>
285+
You can update your task workspace to a newer version
286+
</WorkspaceOutdatedTooltip>
287+
</div>
288+
)}
278289
<divclassName="flex flex-row mt-4 gap-4">
279290
<Button
280291
size="sm"
292+
data-testid="task-start-workspace"
281293
disabled={isWaitingForStart}
282294
onClick={()=>{
283295
mutateStartWorkspace.mutate({

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp