-
Notifications
You must be signed in to change notification settings - Fork 52
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
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
for participants, appearance, and profile
This comment has been minimized.
This comment has been minimized.
# Conflicts: # src/components/SettingsDialog/ShareSession/ShareSession.tsx
🐙 OctomindTest Report: 14/14 successful.
commit sha: 0e85826 |
.eslintrc.json
Outdated
@@ -57,7 +57,8 @@ | |||
"jsx-a11y/no-noninteractive-element-interactions": "off", | |||
"no-plusplus": "off", | |||
"no-param-reassign": "off", | |||
"jsx-a11y/anchor-is-valid": "off" | |||
"jsx-a11y/anchor-is-valid": "off", | |||
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, this was required for something but not anymore.
src/components/Avatar/Avatar.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having an issue wrapping my head around that component right now, but not necessarily because of your changes.
You've made the seed property optional. When the component gets rendered with an undefined seed, you return null. That signals to me that the seed property is necessary in any case to render the component. But there's one case where the seed isn't necessary, isn't it? If the avatar property is defined, we don't need to have the seed to render an avatar. So as I understand it, null should only be returned if the seed and the avatar are undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change stems from the fact that the seed which is used is the user's id, which can be undefined.
So you could either do a non-null assertion or allow undefined values. I know it's not optimal, maybe it would be a good change overall to change ParticipantsState.me
to always be defined?
export const BoardOptionButton: FC<PropsWithChildren<BoardOptionButtonProps>> = ({label, icon, onClick, isExpandable = false, className, children, ...other}) => { | ||
export const BoardOptionButton: FC<PropsWithChildren<BoardOptionButtonProps>> = ({label, icon, onClick, isExpandable = false, children, ...other}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you've removed the className here because it wasn't used anyways. But having className within the {...other}
props make it unusable. If in the future, someone would add a classname to the <BoardOptionButton />
component, it wouldn't be applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah true, I've readded the prop and also apply it to the div now, which wasn't the case before.
<div className={classNames("settings-dialog__container", "accent-color__lean-lilac")}> | ||
<div className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
<Route path="feedback" element={<Feedback />} /> | ||
<Route path="profile" element={<ProfileSettings />} /> | ||
const Router = () => { | ||
const feedbackEnabled = useAppSelector((state) => state.view.feedbackEnabled); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like something that belongs in the state (since it won't change), but rather as an imported const with the value of an environment variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the value comes from the backend, that's why it's in the store.
import {GeneralSettings, Participants, SettingsAppearance, SettingsFeedback, Share, FileDefault} from "components/Icon"; | ||
import {Color} from "./colors"; | ||
|
||
export const MOBILE_BREAKPOINT = 920; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the magic value coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that magic value has been in the code since the very first version of the setting component added in 2022 (1f88c5e), I just decided to outsource it and clarify its use in the code.
src/constants/settings.ts
Outdated
export type MenuKey = "board" | "participants" | "appearance" | "share" | "export" | "feedback" | "profile"; | ||
|
||
type LocalizationKey = "BoardSettings" | "Participants" | "Appearance" | "ShareSession" | "ExportBoard" | "Feedback" | "Profile"; | ||
|
||
export type MenuItem = { | ||
localizationKey: LocalizationKey; | ||
location: string; | ||
isModeratorOnly: boolean; | ||
color: Color; | ||
icon: ComponentType<SVGProps<SVGSVGElement>> | "profile"; // profile: special case | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer the following naming: MenuItemKey
, MenuItemConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed 👍
src/constants/settings.ts
Outdated
export const ENABLE_ALL: Record<MenuKey, boolean> = { | ||
board: true, | ||
participants: true, | ||
appearance: true, | ||
share: true, | ||
export: true, | ||
feedback: true, | ||
profile: true, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add a feedbackEnabled
const in this file, get the value from an environment variable and use the value of it inside the ENABLE_ALL
record.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, maybe a different name like enabledFeedbackItems
would fit better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feedbackEnabled
comes from the store which in turn retrieves it from the ServerInfo
.
The idea of the const ENABLE_ALL
was to be able to use it as a shorthand to avoid having to enable all menu items manually, while still retaining the option to overwrite it.
<SettingsDialog enabledMenuItems={{...ENABLE_ALL, feedback: feedbackEnabled}} />
Remember, the reason this refactor was required in the first place is to be able to dynamically change which menu items are available, and which aren't.
also actually apply it
`MenuKey` -> `MenuItemKey` `MenuItem` -> `MenuItemConfig` `MENU_ENTRY_CONFIG` -> `MENU_ITEM_CONFIG`
The deployment to the dev cluster was successful. You can find the deployment here: https://4265.development.scrumlr.fra.ics.inovex.io Deployed Images
|
Description
Refactors the settings dialog. The reason for this is the fact the settings will be required at other locations (like templates/sessions, #4254), and while the current state was great, it had some issues:
The new solution provides solutions for all of these:
/settings
, automatically redirect to the first allowed optionChangelog
constants/settings.ts
incuding nessecary types and list of all menu itemsChecklist