Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/page/pages/_sites/[site]/roadmap/[roadmap_slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ export default function RoadmapPage({
handleVote(item.id);
}}
disabled={votingItems.has(item.id)}
className={`flex items-center text-xs px-2 py-1 rounded transition-colors ${
className={`flex items-center text-xs px-2 py-1 rounded border transition-colors ${
votes[item.id]?.voted
? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"
: "text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600"
? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-700"
: "text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600 border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500"
} ${
votingItems.has(item.id)
? "opacity-50 cursor-not-allowed"
Expand Down Expand Up @@ -420,10 +420,10 @@ export default function RoadmapPage({
disabled={
!selectedItem || votingItems.has(selectedItem.id)
}
className={`flex items-center text-sm px-3 py-1.5 rounded-lg transition-colors ${
className={`flex items-center text-sm px-3 py-1.5 rounded-lg border transition-colors ${
selectedItem && votes[selectedItem.id]?.voted
? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"
: "text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600"
? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 border-blue-300 dark:border-blue-700"
: "text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600 border-gray-200 dark:border-gray-600 hover:border-gray-300 dark:hover:border-gray-500"
} ${
!selectedItem || votingItems.has(selectedItem.id)
? "opacity-50 cursor-not-allowed"
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/roadmap/RoadmapItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function RoadmapItem({
</span>
)}
</div>
<div className="flex items-center text-xs text-gray-500 dark:text-gray-400">
<div className="flex items-center text-xs text-gray-500 dark:text-gray-400 border border-gray-200 dark:border-gray-600 rounded-md px-2 py-1 hover:border-gray-300 dark:hover:border-gray-500 transition-colors">
<svg className="mr-1 h-4 w-4" fill="currentColor" viewBox="0 0 20 20">
<path
fillRule="evenodd"
Expand Down
66 changes: 61 additions & 5 deletions apps/web/pages/pages/[page_id]/roadmap/[board_id]/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { PencilIcon, PlusIcon, TrashIcon } from "@heroicons/react/solid";
import { InferGetServerSidePropsType } from "next";
import { useRouter } from "next/router";
import { useEffect, useMemo, useState, type JSX } from "react";
import ConfirmDeleteDialog from "../../../../../components/dialogs/confirm-delete-dialog.component";
import SwitchComponent from "../../../../../components/forms/switch.component";
import AuthLayout from "../../../../../components/layout/auth-layout.component";
import Page from "../../../../../components/layout/page.component";
Expand Down Expand Up @@ -153,6 +154,10 @@ export default function BoardSettings({
const [draggedColumn, setDraggedColumn] = useState(null);
const [dragOverIndex, setDragOverIndex] = useState(null);

// Delete board state
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
const [isDeletingBoard, setIsDeletingBoard] = useState(false);

const tabs = [
{
name: "Settings",
Expand Down Expand Up @@ -303,7 +308,7 @@ export default function BoardSettings({
}
};

const handleUpdateCategory = async (categoryId) => {
const handleUpdateCategory = async (categoryId: string) => {
if (!categoryToEdit.trim() || !isPageOwner) return;

try {
Expand Down Expand Up @@ -355,7 +360,7 @@ export default function BoardSettings({
}
};

const handleDeleteCategory = async (categoryId) => {
const handleDeleteCategory = async (categoryId: string) => {
// Check if category has items
try {
const { data: itemsWithCategory, error: checkError } = await supabase
Expand Down Expand Up @@ -438,7 +443,7 @@ export default function BoardSettings({
}
};

const handleUpdateColumn = async (columnId) => {
const handleUpdateColumn = async (columnId: string) => {
if (!columnToEdit.trim() || !isPageOwner) return;

try {
Expand Down Expand Up @@ -478,7 +483,7 @@ export default function BoardSettings({
}
};

const handleDeleteColumn = async (columnId) => {
const handleDeleteColumn = async (columnId: string) => {
// Check if stage has items
try {
const { data: itemsInColumn, error: checkError } = await supabase
Expand Down Expand Up @@ -607,6 +612,38 @@ export default function BoardSettings({
setDragOverIndex(null);
};

// Delete board function
const handleDeleteBoard = async () => {
if (!isPageOwner) return;

setIsDeletingBoard(true);
try {
const { error } = await supabase
.from("roadmap_boards")
.delete()
.eq("id", board.id)
.eq("page_id", page_id);

if (error) throw error;

// Create audit log for board deletion
await createAuditLog(supabase, {
page_id: page_id,
actor_id: user.id,
action: `Deleted Roadmap Board: ${board.title}`,
changes: { board: board },
});

// Redirect to roadmap list
router.push(`/pages/${page_id}/roadmap`);
} catch (error) {
console.error("Error deleting board:", error);
alert("Failed to delete board");
setIsDeletingBoard(false);
}
setShowDeleteDialog(false);
};

if (!page_id || !board || !isPageOwner) {
return <div>Access denied</div>;
}
Expand Down Expand Up @@ -767,7 +804,15 @@ export default function BoardSettings({
/>
</div>

<div className="flex justify-end">
<div className="flex justify-between items-center">
<button
type="button"
onClick={() => setShowDeleteDialog(true)}
className="inline-flex items-center justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
>
<TrashIcon className="h-4 w-4 mr-2" />
Delete Board
</button>
<button
type="submit"
disabled={isSavingBoard}
Expand Down Expand Up @@ -1044,6 +1089,17 @@ export default function BoardSettings({
</div>
)}
</div>

{/* Delete Board Confirmation Dialog */}
<ConfirmDeleteDialog
itemName={board.title}
open={showDeleteDialog}
setOpen={setShowDeleteDialog}
highRiskAction={true}
riskVerificationText={board.title}
deleteCallback={handleDeleteBoard}
processing={isDeletingBoard}
/>
</Page>
);
}
Expand Down
26 changes: 0 additions & 26 deletions packages/supabase/migrations/18_roadmap.sql
Original file line number Diff line number Diff line change
Expand Up @@ -111,32 +111,6 @@ alter table roadmap_votes add constraint unique_item_visitor unique (item_id, vi

alter table roadmap_votes enable row level security;

-- Function to get vote count for roadmap items
CREATE OR REPLACE FUNCTION roadmap_item_votes_count(itemid uuid)
RETURNS bigint
AS $$
BEGIN
RETURN (
SELECT COUNT(*)
FROM roadmap_votes
WHERE item_id = itemid
);
END;
$$ LANGUAGE 'plpgsql';

-- Function to check if a visitor has voted for an item
CREATE OR REPLACE FUNCTION roadmap_item_has_voted(itemid uuid, visitorid uuid)
RETURNS boolean
AS $$
BEGIN
RETURN EXISTS (
SELECT 1
FROM roadmap_votes
WHERE item_id = itemid AND visitor_id = visitorid
);
END;
$$ LANGUAGE 'plpgsql';

-- Function to initialize default columns for a roadmap board
CREATE OR REPLACE FUNCTION initialize_roadmap_columns(board_id uuid)
RETURNS void
Expand Down