({
entryAtom,
onDeleteWorkspace,
}: {
entryAtom: PrimitiveAtom<WorkspaceListEntry>;
onDeleteWorkspace: (workspaceId: string) => void;
})
| 155 | }); |
| 156 | |
| 157 | const WorkspaceSwitcherItem = ({ |
| 158 | entryAtom, |
| 159 | onDeleteWorkspace, |
| 160 | }: { |
| 161 | entryAtom: PrimitiveAtom<WorkspaceListEntry>; |
| 162 | onDeleteWorkspace: (workspaceId: string) => void; |
| 163 | }) => { |
| 164 | const env = useWaveEnv<WorkspaceSwitcherEnv>(); |
| 165 | const activeWorkspace = useAtomValueSafe(env.atoms.workspace); |
| 166 | const [workspaceEntry, setWorkspaceEntry] = useAtom(entryAtom); |
| 167 | const [editingWorkspace, setEditingWorkspace] = useAtom(editingWorkspaceAtom); |
| 168 | |
| 169 | const workspace = workspaceEntry.workspace; |
| 170 | const isCurrentWorkspace = activeWorkspace.oid === workspace.oid; |
| 171 | |
| 172 | const setWorkspace = useCallback((newWorkspace: Workspace) => { |
| 173 | setWorkspaceEntry({ ...workspaceEntry, workspace: newWorkspace }); |
| 174 | if (newWorkspace.name != "") { |
| 175 | fireAndForget(() => |
| 176 | env.services.workspace.UpdateWorkspace( |
| 177 | workspace.oid, |
| 178 | newWorkspace.name, |
| 179 | newWorkspace.icon, |
| 180 | newWorkspace.color, |
| 181 | false |
| 182 | ) |
| 183 | ); |
| 184 | } |
| 185 | }, []); |
| 186 | |
| 187 | const isActive = !!workspaceEntry.windowId; |
| 188 | const editIconDecl: IconButtonDecl = { |
| 189 | elemtype: "iconbutton", |
| 190 | className: "edit", |
| 191 | icon: "pencil", |
| 192 | title: "Edit workspace", |
| 193 | click: (e) => { |
| 194 | e.stopPropagation(); |
| 195 | if (editingWorkspace === workspace.oid) { |
| 196 | setEditingWorkspace(null); |
| 197 | } else { |
| 198 | setEditingWorkspace(workspace.oid); |
| 199 | } |
| 200 | }, |
| 201 | }; |
| 202 | const windowIconDecl: IconButtonDecl = { |
| 203 | elemtype: "iconbutton", |
| 204 | className: "window", |
| 205 | noAction: true, |
| 206 | icon: isCurrentWorkspace ? "check" : "window", |
| 207 | title: isCurrentWorkspace ? "This is your current workspace" : "This workspace is open", |
| 208 | }; |
| 209 | |
| 210 | const isEditing = editingWorkspace === workspace.oid; |
| 211 | |
| 212 | return ( |
| 213 | <ExpandableMenuItemGroup |
| 214 | key={workspace.oid} |
nothing calls this directly
no test coverage detected