forked from y-scope/yscope-log-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # new-log-viewer/src/services/LogFileManager.ts # new-log-viewer/src/typings/decoders.ts
- Loading branch information
Showing
19 changed files
with
420 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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,44 @@ | ||
name: "lint" | ||
|
||
on: | ||
pull_request: | ||
types: ["opened", "reopened"] | ||
push: | ||
schedule: | ||
# Run at midnight UTC every day with 15 minutes delay added to avoid high load periods | ||
- cron: "15 0 * * *" | ||
workflow_dispatch: | ||
|
||
permissions: | ||
# So the workflow can cancel in-progress jobs | ||
actions: "write" | ||
|
||
concurrency: | ||
group: "${{github.workflow}}-${{github.ref}}" | ||
# Cancel in-progress jobs for efficiency | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint-check: | ||
runs-on: "ubuntu-latest" | ||
permissions: | ||
# So `eslint-annotate-action` can create / update status checks | ||
checks: "write" | ||
# So `eslint-annotate-action` can get pull request files | ||
contents: "read" | ||
steps: | ||
- uses: "actions/checkout@v4" | ||
with: | ||
submodules: "recursive" | ||
- uses: "actions/setup-node@v4" | ||
with: | ||
node-version: 22 | ||
- run: "npm --prefix new-log-viewer/ clean-install" | ||
- run: "npm --prefix new-log-viewer/ run lint:ci" | ||
continue-on-error: true | ||
- uses: "ataylorme/eslint-annotate-action@v3" | ||
with: | ||
fail-on-error: true | ||
fail-on-warning: true | ||
only-pr-files: true | ||
report-json: "./new-log-viewer/eslint-report.json" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 @@ | ||
.drop-file-container { | ||
width: 100%; | ||
height: 100%; | ||
position: relative; | ||
} | ||
|
||
.drop-file-children { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.hover-mask { | ||
position: absolute; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(2, 88, 168, 0.2); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
z-index: var(--ylv-drop-file-container-hover-mask-z-index); | ||
} | ||
|
||
.hover-message { | ||
padding: 8px; | ||
color: #616161; | ||
font-size: 0.875rem; | ||
font-family: var(--ylv-ui-font-family), sans-serif; | ||
background-color: #f3f3f3; | ||
z-index: var(--ylv-drop-file-container-hover-message-z-index); | ||
} |
This file contains 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,96 @@ | ||
import React, { | ||
useContext, | ||
useState, | ||
} from "react"; | ||
|
||
import {StateContext} from "../../contexts/StateContextProvider"; | ||
import {CURSOR_CODE} from "../../typings/worker"; | ||
|
||
import "./index.css"; | ||
|
||
|
||
interface DropFileContextProviderProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
/** | ||
* A container element to add drag & drop functionality to the child elements. | ||
* | ||
* @param props | ||
* @param props.children | ||
* @return | ||
*/ | ||
const DropFileContainer = ({children}: DropFileContextProviderProps) => { | ||
const {loadFile} = useContext(StateContext); | ||
const [isFileHovering, setIsFileHovering] = useState(false); | ||
|
||
const handleDrag = (ev: React.DragEvent<HTMLDivElement>) => { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
|
||
if ("dragenter" === ev.type) { | ||
setIsFileHovering(true); | ||
} else if ("dragleave" === ev.type) { | ||
// Only stop the hover effect if the pointer leaves the bounding rectangle of the | ||
// DropFileContainer. | ||
// | ||
// NOTE: "dragleave" could get fired when the wrapped `children` receive focus. Setting | ||
// `pointer-events: none` on the children is viable but could cause the children to be | ||
// unresponsive. So instead, we use the solution below. | ||
const {bottom, left, right, top} = ev.currentTarget.getBoundingClientRect(); | ||
if (ev.clientX >= left && ev.clientX <= right && | ||
ev.clientY >= top && ev.clientY <= bottom) { | ||
return; | ||
} | ||
|
||
setIsFileHovering(false); | ||
} | ||
}; | ||
|
||
const handleDrop = (ev: React.DragEvent<HTMLDivElement>) => { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
|
||
setIsFileHovering(false); | ||
|
||
const [file] = ev.dataTransfer.files; | ||
if ("undefined" === typeof file) { | ||
console.warn("No file dropped."); | ||
|
||
return; | ||
} | ||
loadFile(file, {code: CURSOR_CODE.LAST_EVENT, args: null}); | ||
}; | ||
|
||
return ( | ||
<div | ||
className={"drop-file-container"} | ||
onDragEnter={handleDrag} | ||
onDragLeave={handleDrag} | ||
onDragOver={handleDrag} | ||
onDrop={handleDrop} | ||
> | ||
<div | ||
className={"drop-file-children"} | ||
onDrop={handleDrop} | ||
> | ||
{children} | ||
{isFileHovering && ( | ||
<div | ||
className={"hover-mask"} | ||
onDrop={handleDrop} | ||
> | ||
<div | ||
className={"hover-message"} | ||
onDrop={handleDrop} | ||
> | ||
Drop file to view | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DropFileContainer; |
This file contains 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 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.