2025-01-16 19:57:51 +05:30
|
|
|
import { observer } from "mobx-react";
|
2025-01-07 20:30:42 +05:30
|
|
|
import { useParams } from "next/navigation";
|
|
|
|
|
import { Plus } from "lucide-react";
|
2025-01-16 19:57:51 +05:30
|
|
|
// hooks
|
2025-02-06 20:41:31 +05:30
|
|
|
import { useTranslation } from "@plane/i18n";
|
2025-01-07 20:30:42 +05:30
|
|
|
import { useSticky } from "@/hooks/use-stickies";
|
2025-01-16 19:57:51 +05:30
|
|
|
import { StickiesTruncated } from "./layout";
|
2025-01-07 20:30:42 +05:30
|
|
|
import { StickySearch } from "./modal/search";
|
|
|
|
|
import { useStickyOperations } from "./sticky/use-operations";
|
|
|
|
|
|
2025-01-16 19:57:51 +05:30
|
|
|
export const StickiesWidget: React.FC = observer(() => {
|
|
|
|
|
// params
|
2025-01-07 20:30:42 +05:30
|
|
|
const { workspaceSlug } = useParams();
|
2025-01-16 19:57:51 +05:30
|
|
|
// store hooks
|
2025-01-07 20:30:42 +05:30
|
|
|
const { creatingSticky, toggleShowNewSticky } = useSticky();
|
2025-02-06 20:41:31 +05:30
|
|
|
const { t } = useTranslation();
|
2025-01-16 19:57:51 +05:30
|
|
|
// sticky operations
|
|
|
|
|
const { stickyOperations } = useStickyOperations({
|
|
|
|
|
workspaceSlug: workspaceSlug?.toString() ?? "",
|
|
|
|
|
});
|
|
|
|
|
|
2025-01-07 20:30:42 +05:30
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div className="flex items-center justify-between mb-4">
|
2025-02-06 20:41:31 +05:30
|
|
|
<div className="text-base font-semibold text-custom-text-350">{t("stickies.title")}</div>
|
2025-01-07 20:30:42 +05:30
|
|
|
{/* actions */}
|
|
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<StickySearch />
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
toggleShowNewSticky(true);
|
2025-01-16 19:57:51 +05:30
|
|
|
stickyOperations.create();
|
2025-01-07 20:30:42 +05:30
|
|
|
}}
|
|
|
|
|
className="flex gap-1 text-sm font-medium text-custom-primary-100 my-auto"
|
|
|
|
|
disabled={creatingSticky}
|
|
|
|
|
>
|
2025-01-16 19:57:51 +05:30
|
|
|
<Plus className="size-4 my-auto" />
|
2025-02-06 20:41:31 +05:30
|
|
|
<span>{t("stickies.add")}</span>
|
2025-01-07 20:30:42 +05:30
|
|
|
{creatingSticky && (
|
2025-01-16 19:57:51 +05:30
|
|
|
<div
|
|
|
|
|
className="size-4 border-2 border-t-transparent border-custom-primary-100 rounded-full animate-spin"
|
|
|
|
|
role="status"
|
|
|
|
|
aria-label="loading"
|
|
|
|
|
/>
|
2025-01-07 20:30:42 +05:30
|
|
|
)}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="-mx-2">
|
2025-01-16 19:57:51 +05:30
|
|
|
<StickiesTruncated />
|
2025-01-07 20:30:42 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2025-01-16 19:57:51 +05:30
|
|
|
});
|