You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

11 months ago
11 months ago
  1. import { useRef } from "react";
  2. import Admin from "@/models/admin";
  3. import paths from "@/utils/paths";
  4. import { LinkSimple, Trash } from "@phosphor-icons/react";
  5. export default function WorkspaceRow({ workspace, users }) {
  6. const rowRef = useRef(null);
  7. const handleDelete = async () => {
  8. if (
  9. !window.confirm(
  10. `您确定要删除吗 ${workspace.name}?\nAfter you do this it will be unavailable in this instance of AnythingLLM.\n\nThis action is irreversible.`
  11. )
  12. )
  13. return false;
  14. rowRef?.current?.remove();
  15. await Admin.deleteWorkspace(workspace.id);
  16. };
  17. return (
  18. <>
  19. <tr
  20. ref={rowRef}
  21. className="bg-transparent text-white text-opacity-80 text-sm font-medium"
  22. >
  23. <th scope="row" className="px-6 py-4 whitespace-nowrap">
  24. {workspace.name}
  25. </th>
  26. <td className="px-6 py-4 flex items-center">
  27. <a
  28. href={paths.workspace.chat(workspace.slug)}
  29. target="_blank"
  30. rel="noreferrer"
  31. className="text-white flex items-center hover:underline"
  32. >
  33. <LinkSimple className="mr-2 w-5 h-5" /> {workspace.slug}
  34. </a>
  35. </td>
  36. <td className="px-6 py-4">
  37. <a
  38. href={paths.workspace.settings.members(workspace.slug)}
  39. className="text-white flex items-center underline"
  40. >
  41. {workspace.userIds?.length}
  42. </a>
  43. </td>
  44. <td className="px-6 py-4">{workspace.createdAt}</td>
  45. <td className="px-6 py-4 flex items-center gap-x-6">
  46. <button
  47. onClick={handleDelete}
  48. className="border-none font-medium px-2 py-1 rounded-lg text-theme-text-primary hover:text-red-500"
  49. >
  50. <Trash className="h-5 w-5" />
  51. </button>
  52. </td>
  53. </tr>
  54. </>
  55. );
  56. }