MCPcopy Index your code
hub / github.com/coder/coder / TaskSidebarMenuItem

Function TaskSidebarMenuItem

site/src/modules/tasks/TasksSidebar/TasksSidebar.tsx:181–319  ·  view source on GitHub ↗
({ task })

Source from the content-addressed store, hash-verified

179};
180
181const TaskSidebarMenuItem: FC<TaskSidebarMenuItemProps> = ({ task }) => {
182 const { taskId } = useParams<{ taskId: string }>();
183 const isActive = task.id === taskId;
184 const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
185 const navigate = useNavigate();
186 const queryClient = useQueryClient();
187 const pauseMutation = useMutation({
188 ...pauseTask(task, queryClient),
189 onError: (error: unknown) => {
190 toast.error(
191 getErrorMessage(error, `Failed to pause task "${task.name}".`),
192 {
193 description: getErrorDetail(error),
194 },
195 );
196 },
197 });
198 const resumeMutation = useMutation({
199 ...resumeTask(task, queryClient),
200 onError: (error: unknown) => {
201 toast.error(
202 getErrorMessage(error, `Failed to resume task "${task.name}".`),
203 {
204 description: getErrorDetail(error),
205 },
206 );
207 },
208 });
209
210 const showPause = canPauseTask(task.status) && task.workspace_id;
211 const pauseDisabled = isPauseDisabled(task.status);
212 const showResume = canResumeTask(task.status) && task.workspace_id;
213
214 return (
215 <>
216 <Button
217 asChild
218 size="sm"
219 variant="subtle"
220 className={cn(
221 "overflow-visible group w-full justify-start text-content-secondary",
222 "transition-none hover:bg-surface-tertiary gap-2 has-[[data-state=open]]:bg-surface-tertiary",
223 {
224 "text-content-primary bg-surface-quaternary hover:bg-surface-quaternary has-[[data-state=open]]:bg-surface-quaternary":
225 isActive,
226 },
227 )}
228 >
229 <Link
230 to={{
231 pathname: `/tasks/${task.owner_name}/${task.id}`,
232 search: location.search,
233 }}
234 >
235 <TaskSidebarMenuItemStatus task={task} />
236 <span className="block max-w-[220px] truncate">
237 {task.display_name}
238 </span>

Callers

nothing calls this directly

Calls 8

pauseTaskFunction · 0.90
getErrorMessageFunction · 0.90
getErrorDetailFunction · 0.90
resumeTaskFunction · 0.90
canPauseTaskFunction · 0.90
isPauseDisabledFunction · 0.90
canResumeTaskFunction · 0.90
cnFunction · 0.90

Tested by

no test coverage detected