forked from superset-sh/superset
-
Notifications
You must be signed in to change notification settings - Fork 1
Add v1 split previews for sidebar file drags #336
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export { | ||
| getFileDragBehavior, | ||
| useFileDragBehavior, | ||
| } from "./useFileDragBehavior"; |
17 changes: 17 additions & 0 deletions
17
apps/desktop/src/renderer/hooks/useFileDragBehavior/useFileDragBehavior.ts
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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { FileDragBehavior } from "@superset/local-db"; | ||
| import { electronTrpc } from "renderer/lib/electron-trpc"; | ||
| import { DEFAULT_FILE_DRAG_BEHAVIOR } from "shared/constants"; | ||
|
|
||
| let cachedFileDragBehavior: FileDragBehavior = DEFAULT_FILE_DRAG_BEHAVIOR; | ||
|
|
||
| /** Non-React getter, kept in sync by useFileDragBehavior(). */ | ||
| export function getFileDragBehavior(): FileDragBehavior { | ||
| return cachedFileDragBehavior; | ||
| } | ||
|
|
||
| export function useFileDragBehavior(): FileDragBehavior { | ||
| const { data } = electronTrpc.settings.getFileDragBehavior.useQuery(); | ||
| const behavior = data ?? DEFAULT_FILE_DRAG_BEHAVIOR; | ||
| cachedFileDragBehavior = behavior; | ||
| return behavior; | ||
| } | ||
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
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
31 changes: 31 additions & 0 deletions
31
.../components/BasePaneWindow/components/InternalFileDropOverlay/InternalFileDropOverlay.tsx
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import type { CSSProperties } from "react"; | ||
| import type { MosaicDropPosition } from "renderer/stores/tabs/types"; | ||
|
|
||
| interface InternalFileDropOverlayProps { | ||
| position: MosaicDropPosition | null; | ||
| } | ||
|
|
||
| const ZONE_STYLES: Record<MosaicDropPosition, CSSProperties> = { | ||
| top: { top: 0, left: 0, width: "100%", height: "50%" }, | ||
| bottom: { top: "50%", left: 0, width: "100%", height: "50%" }, | ||
| left: { top: 0, left: 0, width: "50%", height: "100%" }, | ||
| right: { top: 0, left: "50%", width: "50%", height: "100%" }, | ||
| }; | ||
|
|
||
| export function InternalFileDropOverlay({ | ||
| position, | ||
| }: InternalFileDropOverlayProps) { | ||
| if (!position) return null; | ||
|
|
||
| return ( | ||
| <div className="pointer-events-none absolute inset-0 z-10"> | ||
| <div | ||
| className="absolute rounded-sm border-2 border-primary/70 bg-primary/10" | ||
| style={{ | ||
| ...ZONE_STYLES[position], | ||
| transition: "all 150ms ease", | ||
| }} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
1 change: 1 addition & 0 deletions
1
...TabsContent/TabView/components/BasePaneWindow/components/InternalFileDropOverlay/index.ts
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { InternalFileDropOverlay } from "./InternalFileDropOverlay"; |
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.
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.
Uh oh!
There was an error while loading. Please reload this 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.
🧩 Analysis chain
🏁 Script executed:
Repository: MocA-Love/superset
Length of output: 136
🏁 Script executed:
# Read the complete file to see the context cat -n apps/desktop/src/renderer/hooks/useFileDragBehavior/useFileDragBehavior.tsRepository: MocA-Love/superset
Length of output: 836
🏁 Script executed:
Repository: MocA-Love/superset
Length of output: 429
🏁 Script executed:
Repository: MocA-Love/superset
Length of output: 128
🏁 Script executed:
Repository: MocA-Love/superset
Length of output: 424
🏁 Script executed:
# Check the useFileOpenMode pattern to see if it has a similar pattern cat -n apps/desktop/src/renderer/hooks/useFileOpenMode/useFileOpenMode.tsRepository: MocA-Love/superset
Length of output: 768
🏁 Script executed:
Repository: MocA-Love/superset
Length of output: 89
🏁 Script executed:
Repository: MocA-Love/superset
Length of output: 6093
レンダー中のモジュールキャッシュ更新を避けてください。
Line 15 でレンダー実行中に外部可変状態
cachedFileDragBehaviorを書き換えると、React の未コミットレンダー値がgetFileDragBehavior()に漏れる可能性があります。useEffect で同期することで、コミット後の状態のみを反映できます。修正案
🤖 Prompt for AI Agents
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.
この件は今回は見送ります。理由は 2 点で、まず
getFileDragBehavior()は現状どこからも使われておらず、未コミット値が外へ漏れる実害がありません。加えてuseFileOpenMode()とuseRightSidebarOpenViewWidth()も同じモジュールキャッシュ更新パターンを使っているため、この hook だけuseEffect化すると設定 getter 群の振る舞いが不揃いになります。もし直すなら 3 つまとめて揃える follow-up の方が筋だと判断しました。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.
@MocA-Love、ご説明ありがとうございます。理解しました。getFileDragBehavior()が未使用である点と、useFileOpenMode()/useRightSidebarOpenViewWidth()と設計を揃えるという判断は筋が通っています。3 つまとめて修正する follow-up の方が一貫性の観点からも適切ですね。今後の follow-up 用に学習として記録しておきます。follow-up issue を作成しましょうか?
✏️ Learnings added
🧠 Learnings used