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

refactor: settings dialog #4265

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
76088cc
add settings constants
Schwehn42 Jun 23, 2024
b4cd75e
add render function
Schwehn42 Jun 24, 2024
1348e3e
render menu items (except profile)
Schwehn42 Jun 24, 2024
fce7530
forgot to add export board item
Schwehn42 Jun 24, 2024
2d23263
make seed prop optional and add safety guard
Schwehn42 Jun 24, 2024
57ad812
add profile to menu items
Schwehn42 Jun 24, 2024
059f038
render profile using new function
Schwehn42 Jun 24, 2024
6935c06
useLocation to highlight active menu item
Schwehn42 Jun 24, 2024
daca4bc
add comments
Schwehn42 Jun 24, 2024
33800f7
move functions around
Schwehn42 Jun 24, 2024
52d950e
use keys
Schwehn42 Jun 24, 2024
6cd99eb
render only if enabled
Schwehn42 Jun 25, 2024
60caa91
add shorthand to enable all menu items
Schwehn42 Jun 25, 2024
9a3bbeb
add prop to router with feedback state
Schwehn42 Jun 25, 2024
bbcd7ab
readd and fix logic
Schwehn42 Jun 25, 2024
65cbeda
allow blank args
Schwehn42 Jun 25, 2024
f2b64db
fix key name
Schwehn42 Jun 26, 2024
8be188b
simplify
Schwehn42 Jun 26, 2024
dadd12d
move logic
Schwehn42 Jun 26, 2024
dd3a9b1
fix mobile breakpoint edge case
Schwehn42 Jun 26, 2024
bbc6502
comment
Schwehn42 Jun 26, 2024
1b32adc
function to determine first valid menu item
Schwehn42 Jun 26, 2024
c04a117
move inside useEffect
Schwehn42 Jun 26, 2024
ad71b9e
remove default value to allow reload
Schwehn42 Jun 26, 2024
dceea23
fix test
Schwehn42 Jun 26, 2024
00cf840
add tests
Schwehn42 Jun 26, 2024
f8b8114
fix import path
Schwehn42 Jun 26, 2024
48edcbe
fix unrelated linting warnings
Schwehn42 Jun 26, 2024
e8c743c
Merge branch 'refs/heads/main' into js/refactor-settings-dialog
Schwehn42 Jul 11, 2024
554693c
settings constant new color name
Schwehn42 Jul 11, 2024
938cbf1
snapshot
Schwehn42 Jul 11, 2024
a039b6b
Merge branch 'refs/heads/main' into js/refactor-settings-dialog
Schwehn42 Jul 16, 2024
8c3086a
use scrumlr logo component
Schwehn42 Jul 16, 2024
c357e29
rename activeMenuItem -> activeMenuKey
Schwehn42 Jul 16, 2024
ad7db97
menu type
Schwehn42 Jul 17, 2024
739ba12
refactor to MenuEntry
Schwehn42 Jul 17, 2024
f0d8fe8
new logic
Schwehn42 Jul 17, 2024
f884d84
directly use MENU_ENTRIES
Schwehn42 Jul 17, 2024
895d26a
merge useEffects
Schwehn42 Jul 17, 2024
061709b
working version: use entry value directly
Schwehn42 Jul 17, 2024
69d5711
simplify and comment
Schwehn42 Jul 17, 2024
42df10b
rename functions
Schwehn42 Jul 17, 2024
15b8201
inline function
Schwehn42 Jul 17, 2024
2afa89a
clarify comment
Schwehn42 Jul 17, 2024
fd1cb92
state setter function typo
Schwehn42 Jul 17, 2024
85936c2
use outlet context for accent color
Schwehn42 Jul 17, 2024
f37d5b0
make context value optional
Schwehn42 Jul 17, 2024
48051c6
update snapshots
Schwehn42 Jul 17, 2024
f21f66c
use correct colors
Schwehn42 Jul 17, 2024
93a98d3
update snapshot again
Schwehn42 Jul 17, 2024
a16da02
Merge branch 'main' into js/refactor-settings-dialog
Schwehn42 Jul 17, 2024
6c75c54
Merge branch 'refs/heads/main' into js/refactor-settings-dialog
Schwehn42 Jul 22, 2024
4a45b59
fix feedback color
Schwehn42 Jul 22, 2024
02aa94e
Merge branch 'refs/heads/main' into js/refactor-settings-dialog
Schwehn42 Jul 24, 2024
f08c197
Merge branch 'refs/heads/main' into js/refactor-settings-dialog
Schwehn42 Jul 24, 2024
47e8012
snapshot
Schwehn42 Jul 24, 2024
db1e11c
Merge branch 'main' into js/refactor-settings-dialog
Schwehn42 Sep 11, 2024
024a149
revert eslint rule
Schwehn42 Sep 11, 2024
41f7e17
readd className to BoardOptionButton
Schwehn42 Sep 11, 2024
31fda31
rename types/constants
Schwehn42 Sep 11, 2024
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
5 changes: 4 additions & 1 deletion src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {AvataaarProps} from "types/avatar";
import {getColorClassName, getColorForIndex} from "../../constants/colors";

export type AvatarProps = {
seed: string;
seed?: string;
className?: string;
avatar?: AvataaarProps;
};
Expand Down Expand Up @@ -77,6 +77,9 @@ export const generateRandomProps = (seed: string) => {
*/
export const Avatar = React.memo(
({className, seed, avatar}: AvatarProps) => {
if (!seed) {
return null;
}
if (!avatar) {
const {accentColorClass, ...avatarProps} = generateRandomProps(seed);
return <Avataar className={classNames("avatar", className, accentColorClass)} avatarStyle="Circle" {...avatarProps} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const BoardOptionButton: FC<PropsWithChildren<BoardOptionButtonProps>> =
const Icon = icon!;

return (
<button className={classNames("board-option-button", {"board-option-button--expandable": isExpandable})} onClick={onClick} {...other}>
<button className={classNames(className, "board-option-button", {"board-option-button--expandable": isExpandable})} onClick={onClick} {...other}>
{icon && <Icon className="board-option-button__icon" />}
{children}
<span className="board-option-button__label">{label}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const NoteDialogNoteContent: FC<NoteDialogNoteContentProps> = ({noteId, a

const isImage = useImageChecker(text);

const {value, ...emoji} = useEmojiAutocomplete<HTMLDivElement>({
const {...emoji} = useEmojiAutocomplete<HTMLDivElement>({
initialValue: text,
suggestionsHidden: isStackedNote,
});
Expand Down
8 changes: 6 additions & 2 deletions src/components/SettingsDialog/Appearance/Appearance.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import classNames from "classnames";
import {useTranslation} from "react-i18next";
import {getColorClassName} from "constants/colors";
import {MenuItemConfig} from "constants/settings";
import {useOutletContext} from "react-router";
import {LanguageSettingsDropdown} from "../Components/LanguageSettingsDropdown";
import "../SettingsDialog.scss";
import "./Appearance.scss";
import {ThemeSettings} from "../Components/ThemeSettings";
import {NotificationSettings} from "../Components/NotificationSettings";
import {BoardReactionsSettings} from "../Components/BoardReactionsSettings";
import {SkinToneSelector} from "../Components/SkinToneSelector";
import "./Appearance.scss";

export const Appearance = () => {
const {t} = useTranslation();
const activeMenuItem: MenuItemConfig = useOutletContext();

return (
<div className={classNames("settings-dialog__container", "accent-color__lean-lilac")}>
<div className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
Comment on lines -15 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the accent color of the appearance tab the same, no matter if it's used within a board or for the template page?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question for all of the other tabs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, since the color of the menu items is determined by the menu item config, it makes sense for the actual settings dialogs to use the same color instead of using hard-coded values.

<header className="settings-dialog__header">
<h2 className="settings-dialog__header-text">{t("SettingsDialog.Appearance")}</h2>
</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Appearance should render all Settings correctly 1`] = `
<div
class="settings-dialog__container accent-color__lean-lilac"
class="settings-dialog__container accent-color__backlog-blue"
>
<header
class="settings-dialog__header"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ import {generateRandomString} from "utils/random";
import {Toggle} from "components/Toggle";
import {ConfirmationDialog} from "components/ConfirmationDialog";
import {isEqual} from "underscore";
import {MenuItemConfig} from "constants/settings";
import {getColorClassName} from "constants/colors";
import {useOutletContext} from "react-router";
import {SettingsButton} from "../Components/SettingsButton";
import {SettingsInput} from "../Components/SettingsInput";
import "./BoardSettings.scss";

export const BoardSettings = () => {
const {t} = useTranslation();
const activeMenuItem: MenuItemConfig = useOutletContext();

const state = useAppSelector(
(applicationState) => ({
Expand Down Expand Up @@ -106,7 +110,7 @@ export const BoardSettings = () => {
};

return (
<div className={classNames("settings-dialog__container", "accent-color__backlog-blue")}>
<div className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
<header className="settings-dialog__header">
<h2 className="settings-dialog__header-text"> {t("SettingsDialog.BoardSettings")}</h2>
</header>
Expand Down
14 changes: 9 additions & 5 deletions src/components/SettingsDialog/ExportBoard/ExportBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@ import {useAppSelector} from "store";
import {exportAsJSON, exportAsCSV, getMarkdownExport} from "utils/export";
import {Toast} from "utils/Toast";
import {TOAST_TIMER_SHORT} from "constants/misc";
import {MenuItemConfig} from "constants/settings";
import {useOutletContext} from "react-router";
import {getColorClassName} from "constants/colors";
import ExportHintHiddenContent from "./ExportHintHiddenContent/ExportHintHiddenContent";
import {SettingsButton} from "../Components/SettingsButton";
import "./ExportBoard.scss";
import "../SettingsDialog.scss";
import ExportHintHiddenContent from "./ExportHintHiddenContent/ExportHintHiddenContent";
import "./ExportBoard.scss";

export const ExportBoard = () => {
const {t} = useTranslation();
const activeMenuItem: MenuItemConfig = useOutletContext();

const boardId = useAppSelector((state) => state.board.data!.id);
const boardName = useAppSelector((state) => state.board.data!.name);

return (
<div data-testid="export" className="settings-dialog__container">
<div data-testid="export" className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
<div className="settings-dialog__header">
<h2 className={classNames("settings-dialog__header-text", "accent-color__backlog-blue")}> {t("ExportBoardOption.title")}</h2>
<h2 className="settings-dialog__header-text"> {t("ExportBoardOption.title")}</h2>
</div>

<div className={classNames("settings-dialog__group", "accent-color__backlog-blue")}>
<div className="settings-dialog__group">
<SettingsButton
label={t("ExportBoardOption.exportAsJson")}
icon={FileJson}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ Object {
"baseElement": <body>
<div>
<div
class="settings-dialog__container"
class="settings-dialog__container accent-color__backlog-blue"
data-testid="export"
>
<div
class="settings-dialog__header"
>
<h2
class="settings-dialog__header-text accent-color__backlog-blue"
class="settings-dialog__header-text"
>

Export board
</h2>
</div>
<div
class="settings-dialog__group accent-color__backlog-blue"
class="settings-dialog__group"
>
<button
aria-label="Export as JSON"
Expand Down Expand Up @@ -104,21 +104,21 @@ Object {
</body>,
"container": <div>
<div
class="settings-dialog__container"
class="settings-dialog__container accent-color__backlog-blue"
data-testid="export"
>
<div
class="settings-dialog__header"
>
<h2
class="settings-dialog__header-text accent-color__backlog-blue"
class="settings-dialog__header-text"
>

Export board
</h2>
</div>
<div
class="settings-dialog__group accent-color__backlog-blue"
class="settings-dialog__group"
>
<button
aria-label="Export as JSON"
Expand Down
9 changes: 7 additions & 2 deletions src/components/SettingsDialog/Feedback/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ import {SettingsButton} from "components/SettingsDialog/Components/SettingsButto
import {FeedbackAPI} from "api/feedback";
import {useAppSelector} from "store";
import {TemplateGallery, Praise, Bug} from "components/Icon";
import {useOutletContext} from "react-router";
import {MenuItemConfig} from "constants/settings";
import {getColorClassName} from "constants/colors";
import "./Feedback.scss";

export const Feedback: React.FC = () => {
const {t} = useTranslation();
const activeMenuItem: MenuItemConfig = useOutletContext();

const [errorMessage, setErrorMessage] = useState<string>();
const [feedbackTypeInput, setFeedbackTypeInput] = useState("PRAISE");
const [feedbackInputLabel, setFeedbackInputLabel] = useState<string>(t("Feedback.PraiseInputLabel"));
Expand Down Expand Up @@ -106,9 +111,9 @@ export const Feedback: React.FC = () => {
);

return (
<div className="settings-dialog__container accent-color__value-violet">
<div className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
<div className="settings-dialog__header">
<h2 className={classNames("settings-dialog__header-text", "accent-color__value-violet")}>Feedback</h2>
<h2 className="settings-dialog__header-text">Feedback</h2>
</div>
{feedbackEnabled && (
<form className="settings-dialog__feedback-form" onSubmit={onSubmitFeedback}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

exports[`Feedback should match snapshot 1`] = `
<div
class="settings-dialog__container accent-color__value-violet"
class="settings-dialog__container accent-color__backlog-blue"
>
<div
class="settings-dialog__header"
>
<h2
class="settings-dialog__header-text accent-color__value-violet"
class="settings-dialog__header-text"
>
Feedback
</h2>
Expand Down
8 changes: 7 additions & 1 deletion src/components/SettingsDialog/Participants/Participants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import {Join, Kick, Search, Wifi, MarkAsDone} from "components/Icon";
import classNames from "classnames";
import {UserAvatar} from "components/BoardUsers";
import {ConfirmationDialog} from "components/ConfirmationDialog";
import {useOutletContext} from "react-router";
import {MenuItemConfig} from "constants/settings";
import {getColorClassName} from "constants/colors";
import {useEffect, useRef, useState} from "react";
import {useTranslation} from "react-i18next";
import {useDispatch} from "react-redux";
Expand All @@ -15,6 +18,9 @@ import "./Participants.scss";
export const Participants = () => {
const {t} = useTranslation();
const dispatch = useDispatch();

const activeMenuItem: MenuItemConfig = useOutletContext();

const [queryString, setQueryString] = useState<string>("");
const debouncedQueryString = useDebounce(queryString);
const [permissionFilter, setPermissionFilter] = useState<"ALL" | "OWNER" | "MODERATOR" | "PARTICIPANT">("ALL");
Expand Down Expand Up @@ -60,7 +66,7 @@ export const Participants = () => {
};

return (
<section className="settings-dialog__container accent-color__value-violet">
<section className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
<header className="settings-dialog__header">
<h2 className="settings-dialog__header-text">{t("Participants.Title")}</h2>
</header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`Participants should render filter and participants correctly 1`] = `
<section
class="settings-dialog__container accent-color__value-violet"
class="settings-dialog__container accent-color__backlog-blue"
>
<header
class="settings-dialog__header"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import {useTranslation} from "react-i18next";
import {useState} from "react";
import store, {useAppSelector} from "store";
import {Actions} from "store/action";
import "./ProfileSettings.scss";
import {useDispatch} from "react-redux";
import {Info} from "components/Icon";
import {Toggle} from "components/Toggle";
import {isEqual} from "underscore";
import {useOutletContext} from "react-router";
import {MenuItemConfig} from "constants/settings";
import {getColorClassName} from "constants/colors";
import {AvatarSettings} from "../Components/AvatarSettings";
import {SettingsInput} from "../Components/SettingsInput";
import {SettingsButton} from "../Components/SettingsButton";
import "./ProfileSettings.scss";

export const ProfileSettings = () => {
const {t} = useTranslation();
const dispatch = useDispatch();

const activeMenuItem: MenuItemConfig = useOutletContext();

const state = useAppSelector(
(applicationState) => ({
participant: applicationState.participants!.self,
Expand All @@ -28,7 +33,7 @@ export const ProfileSettings = () => {
const [id] = useState<string | undefined>(state.participant?.user.id);

return (
<div className={classNames("settings-dialog__container", "accent-color__lean-lilac")}>
<div className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
<header className="settings-dialog__header">
<h2 className="settings-dialog__header-text">{t("ProfileSettings.Profile")}</h2>
</header>
Expand Down
6 changes: 0 additions & 6 deletions src/components/SettingsDialog/SettingsDialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ $settings-dialog-container--bottom: 62px;
height: 40px;
margin: $spacing--xl;
}
[theme="light"] .settings-dialog__scrumlr-logo--dark {
display: none;
}
[theme="dark"] .settings-dialog__scrumlr-logo--light {
display: none;
}

.settings-dialog__navigation {
display: flex;
Expand Down
Loading
Loading