-
Notifications
You must be signed in to change notification settings - Fork 3
[add] Render Debugger page for Lark Cloud documents #15
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
+2,936
−2,856
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
393a4d9
Initial plan
Copilot a46515e
Initial plan: add MobX-Lark document debugger page
Copilot 75fba2e
feat: add MobX-Lark cloud document debugger page at /wiki/[node_token…
Copilot 4403117
feat: add MobX-Lark cloud document debugger page + build resilience f…
Copilot 41707dd
fix: address review feedback - SSR for debugger, revert error swallowing
Copilot a31357e
[add] Git Diff View component for Lark JSON diff
TechQuery b57188a
[optimize] upgrade to amondnet/vercel-action 42
TechQuery 49f6cbc
[fix] 2 detail bugs
TechQuery 46ca460
[optimize] i18n & a11y details of Wiki debugger
TechQuery 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,154 @@ | ||
| import '@git-diff-view/react/styles/diff-view.css'; | ||
|
|
||
| import { generateDiffFile } from '@git-diff-view/file'; | ||
| import { DiffModeEnum, DiffView } from '@git-diff-view/react'; | ||
| import { computed, observable } from 'mobx'; | ||
| import { observer } from 'mobx-react'; | ||
| import { ObservedComponent } from 'mobx-react-helper'; | ||
| import { Alert, Button, ButtonGroup, Form } from 'react-bootstrap'; | ||
|
|
||
| export interface TextFileData { | ||
| fileName: string; | ||
| content: string; | ||
| language?: string; | ||
| } | ||
|
|
||
| export type GitDiffViewProps = Record<'oldFile' | 'newFile', TextFileData>; | ||
|
|
||
| @observer | ||
| export class GitDiffView extends ObservedComponent<GitDiffViewProps> { | ||
| @observable | ||
| accessor diffViewMode = DiffModeEnum.Split; | ||
|
|
||
| @observable | ||
| accessor diffViewWrap = false; | ||
|
|
||
| @observable | ||
| accessor diffViewHighlight = true; | ||
|
|
||
| @observable | ||
| accessor expandAll = false; | ||
|
|
||
| @computed | ||
| get hasNoDiff() { | ||
| const { oldFile, newFile } = this.observedProps; | ||
|
|
||
| return oldFile.content === newFile.content; | ||
| } | ||
|
|
||
| @computed | ||
| get diffFile() { | ||
| const { oldFile, newFile } = this.observedProps; | ||
| const { diffViewMode, expandAll } = this; | ||
|
|
||
| const file = generateDiffFile( | ||
| oldFile.fileName, | ||
| oldFile.content, | ||
| newFile.fileName, | ||
| newFile.content, | ||
| oldFile.language || 'text', | ||
| newFile.language || 'text', | ||
| ); | ||
|
|
||
| file.init(); | ||
|
|
||
| if (diffViewMode & DiffModeEnum.Split) { | ||
| file.buildSplitDiffLines(); | ||
| } else { | ||
| file.buildUnifiedDiffLines(); | ||
| } | ||
|
|
||
| if (expandAll) | ||
| file.onAllExpand(diffViewMode & DiffModeEnum.Split ? 'split' : 'unified'); | ||
|
|
||
| return file; | ||
| } | ||
|
|
||
| renderDiff() { | ||
| const { | ||
| diffViewMode, | ||
| diffViewWrap, | ||
| diffViewHighlight, | ||
| expandAll, | ||
| diffFile, | ||
| } = this; | ||
|
TechQuery marked this conversation as resolved.
|
||
|
|
||
| return ( | ||
| <> | ||
| <div className="d-flex flex-wrap align-items-center gap-2 mb-3"> | ||
| <ButtonGroup size="sm" aria-label="Diff mode"> | ||
| <Button | ||
| variant={ | ||
| diffViewMode & DiffModeEnum.Split | ||
| ? 'primary' | ||
| : 'outline-primary' | ||
| } | ||
| onClick={() => (this.diffViewMode = DiffModeEnum.Split)} | ||
| > | ||
| Split | ||
| </Button> | ||
| <Button | ||
| variant={ | ||
| diffViewMode & DiffModeEnum.Split | ||
| ? 'outline-primary' | ||
| : 'primary' | ||
| } | ||
| onClick={() => (this.diffViewMode = DiffModeEnum.Unified)} | ||
| > | ||
| Unified | ||
| </Button> | ||
| </ButtonGroup> | ||
|
|
||
| <Form.Check | ||
| type="switch" | ||
| id="text-file-diff-wrap" | ||
| label="Wrap" | ||
| checked={diffViewWrap} | ||
| onChange={({ currentTarget }) => | ||
| (this.diffViewWrap = currentTarget.checked) | ||
| } | ||
| /> | ||
| <Form.Check | ||
| type="switch" | ||
| id="text-file-diff-highlight" | ||
| label="Highlight" | ||
| checked={diffViewHighlight} | ||
| onChange={({ currentTarget }) => | ||
| (this.diffViewHighlight = currentTarget.checked) | ||
| } | ||
| /> | ||
| <Form.Check | ||
| type="switch" | ||
| id="text-file-diff-expand-all" | ||
| label="Expand all" | ||
| checked={expandAll} | ||
| onChange={({ currentTarget }) => | ||
| (this.expandAll = currentTarget.checked) | ||
| } | ||
| /> | ||
| </div> | ||
|
|
||
| <DiffView | ||
| diffFile={diffFile} | ||
| diffViewMode={diffViewMode} | ||
| diffViewWrap={diffViewWrap} | ||
| diffViewHighlight={diffViewHighlight} | ||
| /> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| render() { | ||
| const { hasNoDiff } = this; | ||
|
|
||
| return hasNoDiff ? ( | ||
| <> | ||
| <Alert variant="danger">No diff found between the two files.</Alert> | ||
|
|
||
| <pre>{this.props.oldFile.content}</pre> | ||
| </> | ||
| ) : ( | ||
| this.renderDiff() | ||
| ); | ||
| } | ||
| } | ||
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
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.