-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1225: Discourse node migration simple settings #696
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
Open
sid597
wants to merge
6
commits into
eng-1273-migrate-all-small-personal-settings
Choose a base branch
from
eng-1225-discourse-node-migrate-settings-prod
base: eng-1273-migrate-all-small-personal-settings
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b933056
ENG-1225: Discourse node migration
sid597 988dd6e
Migrate personal settings text inputs
sid597 ad0ba6b
remove unnecessary checks zod takes care
sid597 5ef67ad
restack and fix unnecessary changes
sid597 62b37a6
fix, bug fixes, updates
sid597 ee13988
remove unused
sid597 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,12 @@ import { | |
| Tooltip, | ||
| Icon, | ||
| ControlGroup, | ||
| Checkbox, | ||
| } from "@blueprintjs/core"; | ||
| import React, { useState, useMemo } from "react"; | ||
| import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid"; | ||
| import getSettingValueFromTree from "roamjs-components/util/getSettingValueFromTree"; | ||
| import setInputSetting from "roamjs-components/util/setInputSetting"; | ||
| import { DiscourseNodeFlagPanel } from "./components/BlockPropSettingPanels"; | ||
|
|
||
| export const formatHexColor = (color: string) => { | ||
| if (!color) return ""; | ||
|
|
@@ -25,7 +25,7 @@ export const formatHexColor = (color: string) => { | |
| return ""; | ||
| }; | ||
|
|
||
| const DiscourseNodeCanvasSettings = ({ uid }: { uid: string }) => { | ||
| const DiscourseNodeCanvasSettings = ({ nodeType, uid }: { nodeType: string; uid: string }) => { | ||
| const tree = useMemo(() => getBasicTreeByParentUid(uid), [uid]); | ||
| const [color, setColor] = useState<string>(() => { | ||
| const color = getSettingValueFromTree({ tree, key: "color" }); | ||
|
|
@@ -43,6 +43,7 @@ const DiscourseNodeCanvasSettings = ({ uid }: { uid: string }) => { | |
| const [keyImageOption, setKeyImageOption] = useState(() => | ||
| getSettingValueFromTree({ tree, key: "key-image-option" }), | ||
| ); | ||
|
|
||
| return ( | ||
| <div> | ||
| <div className="mb-4"> | ||
|
|
@@ -91,49 +92,33 @@ const DiscourseNodeCanvasSettings = ({ uid }: { uid: string }) => { | |
| }} | ||
| /> | ||
| </Label> | ||
| <Checkbox | ||
| style={{ width: 240, lineHeight: "normal" }} | ||
| checked={isKeyImage} | ||
| onChange={(e) => { | ||
| const target = e.target as HTMLInputElement; | ||
| setIsKeyImage(target.checked); | ||
| if (target.checked) { | ||
| if (!keyImageOption) setKeyImageOption("first-image"); | ||
| setInputSetting({ | ||
| blockUid: uid, | ||
| key: "key-image", | ||
| value: "true", | ||
| }); | ||
| } else { | ||
| setInputSetting({ | ||
| blockUid: uid, | ||
| key: "key-image", | ||
| value: "false", | ||
| }); | ||
| } | ||
| <DiscourseNodeFlagPanel | ||
| nodeType={nodeType} | ||
| title="Key Image" | ||
| description="Add an image to the discourse node" | ||
| settingKeys={["canvasSettings", "key-image"]} | ||
| defaultValue={isKeyImage} | ||
| onChange={(checked) => { | ||
| setIsKeyImage(checked); | ||
| if (checked && !keyImageOption) setKeyImageOption("first-image"); | ||
| setInputSetting({ | ||
| blockUid: uid, | ||
| key: "key-image", | ||
| value: checked ? "true" : "false", | ||
| }); | ||
| }} | ||
| > | ||
| Key image | ||
| <Tooltip content={"Add an image to the discourse node"}> | ||
| <Icon | ||
| icon={"info-sign"} | ||
| iconSize={12} | ||
| className={"ml-2 align-middle opacity-80"} | ||
| /> | ||
| </Tooltip> | ||
| </Checkbox> | ||
| {/* </Tooltip> */} | ||
| /> | ||
| <RadioGroup | ||
| disabled={!isKeyImage} | ||
| selectedValue={!!keyImageOption ? keyImageOption : "first-image"} | ||
| selectedValue={keyImageOption || "first-image"} | ||
| label="Key image location" | ||
| onChange={(e) => { | ||
| const target = e.target as HTMLInputElement; | ||
| setKeyImageOption(target.value); | ||
| const value = (e.target as HTMLInputElement).value; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the purpose of this change? |
||
| setKeyImageOption(value); | ||
| setInputSetting({ | ||
| blockUid: uid, | ||
| key: "key-image-option", | ||
| value: target.value, | ||
| value, | ||
| }); | ||
| }} | ||
| > | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the
voidoperator.eslint@typescript-eslint/no-floating-promises