Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

menu cleanup #1: tagging in tags column, metas in name column #848

Merged
merged 2 commits into from
Jan 15, 2025
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
13 changes: 11 additions & 2 deletions hunts/src/EditPuzzleModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { FormEvent } from "react";
import { Button, Form, Modal } from "react-bootstrap";
import { useDispatch } from "react-redux";
import { updatePuzzle } from "./puzzlesSlice";
import { useDispatch, useSelector } from "react-redux";
import { selectPuzzleTags, updatePuzzle } from "./puzzlesSlice";
import { showModal, hideModal } from "./modalSlice";
import EditableTagList from "./EditableTagList";

import type { Dispatch } from "./store";
import type { HuntId, PuzzleId } from "./types";
Expand All @@ -29,6 +30,9 @@ function EditPuzzleModal({
const [newIsMeta, setNewIsMeta] = React.useState(isMeta);
const [createChannels, setCreateChannels] = React.useState(hasChannels);
const dispatch = useDispatch<Dispatch>();

const tags = useSelector(selectPuzzleTags);

const onSubmit = (e: FormEvent) => {
e.preventDefault();
dispatch(
Expand Down Expand Up @@ -80,6 +84,11 @@ function EditPuzzleModal({
checked={newIsMeta}
onChange={(e: ChangeEvent) => setNewIsMeta(e.target.checked)}
/>
<h5 style={{ textAlign: "center" }}>Parent Metas</h5>
<EditableTagList
puzzleId={puzzleId}
tags={tags.filter((tag) => tag.is_meta && tag.name != name)}
/>
<Form.Check
type="checkbox"
label="Create discord channels"
Expand Down
6 changes: 0 additions & 6 deletions hunts/src/EditPuzzleTagsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ function EditPuzzleTagsModal({
<Modal.Title>Edit Tags for {puzzleName}</Modal.Title>
</Modal.Header>
<Modal.Body>
<h5 style={{ textAlign: "center" }}>Metas</h5>
<EditableTagList
puzzleId={puzzleId}
tags={allTags.filter((tag) => tag.is_meta)}
/>
<br />
<h5 style={{ textAlign: "center" }}>Locations</h5>
<EditableTagList
puzzleId={puzzleId}
Expand Down
17 changes: 1 addition & 16 deletions hunts/src/NameCell.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Badge, Popover, OverlayTrigger } from "react-bootstrap";
import { useSelector, useDispatch } from "react-redux";
import { faWrench, faTag } from "@fortawesome/free-solid-svg-icons";
import { faWrench } from "@fortawesome/free-solid-svg-icons";
import { showModal } from "./modalSlice";
import ClickableIcon from "./ClickableIcon";
import { toggleCollapsed } from "./collapsedPuzzlesSlice";
Expand Down Expand Up @@ -170,21 +170,6 @@ export default function NameCell({
})
)
}
/>{" "}
<ClickableIcon
icon={faTag}
onClick={() =>
dispatch(
showModal({
type: "EDIT_TAGS",
props: {
huntId,
puzzleId: row.values.id,
puzzleName: row.values.name,
},
})
)
}
/>
</div>
</div>
Expand Down
30 changes: 25 additions & 5 deletions hunts/src/TagCell.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { showModal } from "./modalSlice";
import { faTag } from "@fortawesome/free-solid-svg-icons";
import { toggleFilterTag } from "./filterSlice";
import TagPill from "./TagPill";
import ClickableIcon from "./ClickableIcon";

import type { Puzzle, Row } from "./types";
import type { RootState } from "./store";
import type { Hunt, Puzzle, Row } from "./types";

function TagCell({ row }: { row: Row<Puzzle> }) {
const dispatch = useDispatch();
const { id: huntId } = useSelector<RootState, Hunt>((state) => state.hunt);
const puzzleId = row.original.id;

const shouldShowMetaTags =
Expand All @@ -20,12 +24,28 @@ function TagCell({ row }: { row: Row<Puzzle> }) {
<>
{tagsToShow.map(({ name, color, id }) => (
<TagPill
name={name}
color={color}
key={name}
onClick={() => dispatch(toggleFilterTag({ name, color, id }))}
name={name}
color={color}
key={name}
onClick={() => dispatch(toggleFilterTag({ name, color, id }))}
/>
))}{" "}

<ClickableIcon
icon={faTag}
onClick={() =>
dispatch(
showModal({
type: "EDIT_TAGS",
props: {
huntId,
puzzleId: row.values.id,
puzzleName: row.values.name,
},
})
)
}
/>{" "}
</>
);
}
Expand Down
Loading