2026-01-27 13:54:22 +05:30
|
|
|
/**
|
|
|
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
* See the LICENSE file for details.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-11-26 23:57:41 +05:30
|
|
|
import { observer } from "mobx-react";
|
2025-12-26 17:19:15 +05:30
|
|
|
|
2024-12-20 20:44:46 +05:30
|
|
|
// plane internal packages
|
|
|
|
|
import { WEB_BASE_URL } from "@plane/constants";
|
2025-12-26 17:19:15 +05:30
|
|
|
import { NewTabIcon } from "@plane/propel/icons";
|
2025-09-02 18:19:56 +05:30
|
|
|
import { Tooltip } from "@plane/propel/tooltip";
|
2024-12-20 20:44:46 +05:30
|
|
|
import { getFileURL } from "@plane/utils";
|
2024-11-26 23:57:41 +05:30
|
|
|
// hooks
|
|
|
|
|
import { useWorkspace } from "@/hooks/store";
|
|
|
|
|
|
|
|
|
|
type TWorkspaceListItemProps = {
|
|
|
|
|
workspaceId: string;
|
|
|
|
|
};
|
|
|
|
|
|
2025-11-20 19:09:40 +07:00
|
|
|
export const WorkspaceListItem = observer(function WorkspaceListItem({ workspaceId }: TWorkspaceListItemProps) {
|
2024-11-26 23:57:41 +05:30
|
|
|
// store hooks
|
|
|
|
|
const { getWorkspaceById } = useWorkspace();
|
|
|
|
|
// derived values
|
|
|
|
|
const workspace = getWorkspaceById(workspaceId);
|
|
|
|
|
|
|
|
|
|
if (!workspace) return null;
|
|
|
|
|
return (
|
2024-11-29 19:02:13 +05:30
|
|
|
<a
|
2024-11-26 23:57:41 +05:30
|
|
|
key={workspaceId}
|
2024-11-29 14:53:30 +05:30
|
|
|
href={`${WEB_BASE_URL}/${encodeURIComponent(workspace.slug)}`}
|
2024-11-26 23:57:41 +05:30
|
|
|
target="_blank"
|
2026-03-02 20:40:50 +05:30
|
|
|
className="group flex items-center justify-between gap-2.5 truncate rounded-lg border border-subtle bg-layer-1 p-3 hover:border-subtle-1 hover:bg-layer-1-hover hover:shadow-raised-100"
|
2025-12-08 23:56:50 +07:00
|
|
|
rel="noreferrer"
|
2024-11-26 23:57:41 +05:30
|
|
|
>
|
|
|
|
|
<div className="flex items-start gap-4">
|
|
|
|
|
<span
|
2026-03-02 20:40:50 +05:30
|
|
|
className={`relative mt-1 flex h-8 w-8 flex-shrink-0 items-center justify-center p-2 text-11 uppercase ${
|
2025-12-24 16:31:52 +05:30
|
|
|
!workspace?.logo_url && "rounded-lg bg-accent-primary text-on-color"
|
2024-11-26 23:57:41 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{workspace?.logo_url && workspace.logo_url !== "" ? (
|
|
|
|
|
<img
|
|
|
|
|
src={getFileURL(workspace.logo_url)}
|
2026-03-02 20:40:50 +05:30
|
|
|
className="absolute top-0 left-0 h-full w-full rounded-sm object-cover"
|
2024-11-26 23:57:41 +05:30
|
|
|
alt="Workspace Logo"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
(workspace?.name?.[0] ?? "...")
|
|
|
|
|
)}
|
|
|
|
|
</span>
|
|
|
|
|
<div className="flex flex-col items-start gap-1">
|
2026-03-02 20:40:50 +05:30
|
|
|
<div className="flex w-full flex-wrap items-center gap-2.5">
|
2025-12-12 20:50:14 +05:30
|
|
|
<h3 className={`text-14 font-medium capitalize`}>{workspace.name}</h3>/
|
2024-11-26 23:57:41 +05:30
|
|
|
<Tooltip tooltipContent="The unique URL of your workspace">
|
2025-12-12 20:50:14 +05:30
|
|
|
<h4 className="text-13 text-tertiary">[{workspace.slug}]</h4>
|
2024-11-26 23:57:41 +05:30
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
{workspace.owner.email && (
|
2025-12-12 20:50:14 +05:30
|
|
|
<div className="flex items-center gap-1 text-11">
|
2026-03-02 20:40:50 +05:30
|
|
|
<h3 className="font-medium text-secondary">Owned by:</h3>
|
2025-12-12 20:50:14 +05:30
|
|
|
<h4 className="text-tertiary">{workspace.owner.email}</h4>
|
2024-11-26 23:57:41 +05:30
|
|
|
</div>
|
|
|
|
|
)}
|
2025-12-12 20:50:14 +05:30
|
|
|
<div className="flex items-center gap-2.5 text-11">
|
2024-11-26 23:57:41 +05:30
|
|
|
{workspace.total_projects !== null && (
|
|
|
|
|
<span className="flex items-center gap-1">
|
2026-03-02 20:40:50 +05:30
|
|
|
<h3 className="font-medium text-secondary">Total projects:</h3>
|
2025-12-12 20:50:14 +05:30
|
|
|
<h4 className="text-tertiary">{workspace.total_projects}</h4>
|
2024-11-26 23:57:41 +05:30
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
{workspace.total_members !== null && (
|
|
|
|
|
<>
|
|
|
|
|
•
|
|
|
|
|
<span className="flex items-center gap-1">
|
2026-03-02 20:40:50 +05:30
|
|
|
<h3 className="font-medium text-secondary">Total members:</h3>
|
2025-12-12 20:50:14 +05:30
|
|
|
<h4 className="text-tertiary">{workspace.total_members}</h4>
|
2024-11-26 23:57:41 +05:30
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex-shrink-0">
|
2025-12-26 17:19:15 +05:30
|
|
|
<NewTabIcon width={14} height={16} className="text-placeholder group-hover:text-secondary" />
|
2024-11-26 23:57:41 +05:30
|
|
|
</div>
|
2024-11-29 19:02:13 +05:30
|
|
|
</a>
|
2024-11-26 23:57:41 +05:30
|
|
|
);
|
|
|
|
|
});
|