chore: modified functionality and placement for live button (#6400)
This commit is contained in:
parent
369d927321
commit
79fff4744a
3 changed files with 35 additions and 18 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import React, { useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
// types
|
||||
import { IProjectView } from "@plane/types";
|
||||
// ui
|
||||
|
|
@ -22,6 +22,7 @@ export const DeleteProjectViewModal: React.FC<Props> = observer((props) => {
|
|||
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
|
||||
// router
|
||||
const { workspaceSlug, projectId } = useParams();
|
||||
const router = useRouter();
|
||||
// store hooks
|
||||
const { deleteView } = useProjectView();
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ export const DeleteProjectViewModal: React.FC<Props> = observer((props) => {
|
|||
await deleteView(workspaceSlug.toString(), projectId.toString(), data.id)
|
||||
.then(() => {
|
||||
handleClose();
|
||||
|
||||
router.push(`/${workspaceSlug}/projects/${projectId}/views`);
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: "Success!",
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ import { DeleteProjectViewModal, CreateUpdateProjectViewModal, ViewQuickActions
|
|||
import { EViewAccess } from "@/constants/views";
|
||||
// helpers
|
||||
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
||||
import { getPublishViewLink } from "@/helpers/project-views.helpers";
|
||||
// hooks
|
||||
import { useMember, useProjectView, useUserPermissions } from "@/hooks/store";
|
||||
import { PublishViewModal } from "@/plane-web/components/views/publish";
|
||||
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
|
||||
import { ButtonAvatars } from "../dropdowns/member/avatar";
|
||||
|
||||
|
|
@ -27,6 +29,7 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||
// states
|
||||
const [createUpdateViewModal, setCreateUpdateViewModal] = useState(false);
|
||||
const [deleteViewModal, setDeleteViewModal] = useState(false);
|
||||
const [isPublishModalOpen, setPublishModalOpen] = useState<boolean>(false);
|
||||
// router
|
||||
const { workspaceSlug, projectId } = useParams();
|
||||
// store
|
||||
|
|
@ -45,6 +48,8 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||
|
||||
const access = view.access;
|
||||
|
||||
const publishLink = getPublishViewLink(view?.anchor);
|
||||
|
||||
// handlers
|
||||
const handleAddToFavorites = () => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
|
|
@ -62,6 +67,7 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||
|
||||
return (
|
||||
<>
|
||||
<PublishViewModal isOpen={isPublishModalOpen} onClose={() => setPublishModalOpen(false)} view={view} />
|
||||
{workspaceSlug && projectId && view && (
|
||||
<CreateUpdateProjectViewModal
|
||||
isOpen={createUpdateViewModal}
|
||||
|
|
@ -82,6 +88,18 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||
</Tooltip>
|
||||
</div>
|
||||
|
||||
{view?.anchor && publishLink ? (
|
||||
<div
|
||||
className="px-3 py-1.5 bg-green-500/20 text-green-500 rounded text-xs font-medium flex items-center gap-1.5 cursor-pointer"
|
||||
onClick={() => setPublishModalOpen(true)}
|
||||
>
|
||||
<span className="flex-shrink-0 rounded-full size-1.5 bg-green-500" />
|
||||
Live
|
||||
</div>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
|
||||
{/* created by */}
|
||||
{<ButtonAvatars showTooltip={false} userIds={ownedByDetails?.id ?? []} />}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue