Skip to content
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

new-log-viewer: Implement MenuBar and StatusBar with JoyUI components; add JoyUI custom app theme. #59

Merged
merged 68 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5075c35
add vscode theme for editor
Henry8192 Aug 23, 2024
3820b35
remove unnecessary configs for monacoTheme
Henry8192 Aug 26, 2024
938b7e3
apply monacoTheme to buttons
Henry8192 Aug 26, 2024
0b255da
add missing dependencies to package.json
Henry8192 Aug 29, 2024
c43b9fd
Switch to JoyUI Input boxes and apply monacoTheme
Henry8192 Aug 29, 2024
634d669
Add Menu bar Icons; First page, prev page, next page and last page bu…
Henry8192 Aug 29, 2024
a7f456a
Add Modal for Settings button
Henry8192 Aug 29, 2024
65df263
Add status bar
Henry8192 Aug 30, 2024
bb5fcb7
Support theme toggling
Henry8192 Aug 31, 2024
d1d1f23
Avoid hard coding for permalink copying
Henry8192 Aug 31, 2024
9b0b034
clean up code about changing theme
Henry8192 Aug 31, 2024
ebb7116
Merge branch 'refs/heads/main' into editorTheme
junhaoliao Sep 3, 2024
43aa4e2
Run `npm i` to update package-lock.json.
junhaoliao Sep 3, 2024
1eda7ac
Refactor navigation and settings in <Layout/>.
junhaoliao Sep 3, 2024
c934ee0
Update initial state of settingsModelOpen to false.
junhaoliao Sep 3, 2024
6a82d80
Move ConfigForm & theme to new separate files; Create SmallIconNavBut…
Henry8192 Sep 5, 2024
8efba31
Avoid tree shaking
Henry8192 Sep 5, 2024
a5014ee
Update comments on deleting theme handling in getConfig & setConfig
Henry8192 Sep 5, 2024
3fae92e
Update new-log-viewer/src/components/Layout.tsx
Henry8192 Sep 5, 2024
36fd775
Update new-log-viewer/src/components/Layout.tsx
Henry8192 Sep 5, 2024
dba8b82
Move Layout style props to Layout.css
Henry8192 Sep 5, 2024
3d17738
Apply suggestions from code review
Henry8192 Sep 6, 2024
b5fd64a
Update comments for not handling CONFIG_KEY.THEME
Henry8192 Sep 6, 2024
8481ade
Move CssVarsProvider from App.tsx to Layout.tsx; ConfigForm.tsx now u…
Henry8192 Sep 6, 2024
d27c65c
Extract MenuBar & StatusBar out of Layout
Henry8192 Sep 6, 2024
7f3add4
move inline styling to Layout.css
Henry8192 Sep 9, 2024
860f91a
Apply suggestions from code review
Henry8192 Sep 9, 2024
6511129
pull config handle functions out of ConfigForm(); add CONFIG_KEY.THEM…
Henry8192 Sep 9, 2024
291c3e8
Move submit & reset button out of ConfigForm; Rename ConfigForm to Co…
Henry8192 Sep 9, 2024
1c9bbec
Add helperText to each form fields
Henry8192 Sep 9, 2024
3741da9
Fix modal spacing issue, add description to config form fields
Henry8192 Sep 9, 2024
5d1f4d9
Move SettingsModal from MenuBar to SettingsModal folder
Henry8192 Sep 10, 2024
5b61320
Apply suggestions from code review
Henry8192 Sep 10, 2024
00fa9d8
Extract MenuBar & StatusBar to their corresponding component folders
Henry8192 Sep 11, 2024
51cfed3
Rearrange the layout to have CssVarsProvider as the outer element wra…
junhaoliao Sep 11, 2024
3d50ea4
Upgrade dependencies.
junhaoliao Sep 11, 2024
fb5a05d
Merge branch 'main' into editorTheme
junhaoliao Sep 11, 2024
afc12bf
Rename StatusBar.tsx to index.tsx; Brute-force fixing file icon not a…
Henry8192 Sep 11, 2024
b410ae3
Fix brute-force overriding menubar alignment issue
Henry8192 Sep 11, 2024
4ddcdb4
Change minWidth from large to mid
Henry8192 Sep 11, 2024
01f179d
Remove redundant props passing by using context directly in StatusBar…
junhaoliao Sep 11, 2024
2b1ace3
Update MenuBar to wrap the ConfigModal in a React fragment.
junhaoliao Sep 11, 2024
ae66796
Remove unused Tip button from MenuBar.
junhaoliao Sep 11, 2024
b03cb9a
Add vertical dividers to MenuBar.
junhaoliao Sep 11, 2024
f3166a6
Add page navigation feature to MenuBar.
junhaoliao Sep 11, 2024
4e8f002
Add docs for handleAction.
junhaoliao Sep 11, 2024
74dbb6b
Move inline CSS for removing spin buttons to an external CSS file.
junhaoliao Sep 11, 2024
5ef2efc
Pull out handlers for setting isSettingsModalOpen.
junhaoliao Sep 11, 2024
199b010
Add newline to EOF.
junhaoliao Sep 11, 2024
4696112
Add dedicated CSS file for Editor component.
junhaoliao Sep 11, 2024
023fe23
Rename ConfigDialog to SettingsDialog; fix settings modal open condit…
junhaoliao Sep 11, 2024
e24e70e
Remove unused CSS classes in Layout; Remove height specification of D…
junhaoliao Sep 11, 2024
c90caf0
Add const PAGE_NUM_INPUT_FIT_EXTRA_WIDTH.
junhaoliao Sep 11, 2024
f63f60e
Improve appearance of numPages.
junhaoliao Sep 11, 2024
ff171c8
Lint PageNumInput.css
junhaoliao Sep 11, 2024
35ee1c3
Remove redundant line in SmallIconButton.tsx
junhaoliao Sep 11, 2024
0ffbdba
Update MenuBar component documentation.
junhaoliao Sep 11, 2024
993370e
Add left padding to status-message class.
junhaoliao Sep 11, 2024
c328ec2
Remove ineffective `.status-button` class.
junhaoliao Sep 11, 2024
341dd42
Revise the log event display text to use a more concise format.
junhaoliao Sep 12, 2024
b86efe7
Rename icons and remove redundant parameter descriptions.
junhaoliao Sep 12, 2024
7cf494c
Move CSS-in-JS to dedicated spreadsheet; rename .settings-modal -> .s…
junhaoliao Sep 12, 2024
0dd682d
Rename ConfigModal to SettingsModal.
junhaoliao Sep 12, 2024
ff2e087
Rename monacoTheme to APP_THEME.
junhaoliao Sep 12, 2024
78333e8
Supress ESLint `max-lines-per-function` in StateContextProvider.
junhaoliao Sep 12, 2024
4bb836f
Remove unused export from index.tsx
junhaoliao Sep 12, 2024
93f87a9
Replace comments and error prompt with throwable instead for CONFIG_K…
junhaoliao Sep 12, 2024
7b0ad1c
Remove redundant comments.
junhaoliao Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,906 changes: 1,625 additions & 1,281 deletions new-log-viewer/package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions new-log-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
},
"homepage": "https://github.com/y-scope/yscope-log-viewer#readme",
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^6.1.0",
"@mui/joy": "^5.0.0-beta.48",
"axios": "^1.7.2",
"clp-ffi-js": "^0.1.0",
"dayjs": "^1.11.11",
Expand Down
12 changes: 5 additions & 7 deletions new-log-viewer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import UrlContextProvider from "./contexts/UrlContextProvider";
*/
const App = () => {
return (
<>
<UrlContextProvider>
<StateContextProvider>
<Layout/>
</StateContextProvider>
</UrlContextProvider>
</>
<UrlContextProvider>
<StateContextProvider>
<Layout/>
</StateContextProvider>
</UrlContextProvider>
);
};

Expand Down
2 changes: 0 additions & 2 deletions new-log-viewer/src/components/DropFileContainer/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.drop-file-container {
width: 100%;
height: 100%;
position: relative;
}

Expand Down
3 changes: 3 additions & 0 deletions new-log-viewer/src/components/Editor/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.editor {
height: calc(100vh - var(--ylv-menu-bar-height) - var(--ylv-status-bar-height));
}
82 changes: 63 additions & 19 deletions new-log-viewer/src/components/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import {
import {Nullable} from "../../typings/common";
import {CONFIG_KEY} from "../../typings/config";
import {BeginLineNumToLogEventNumMap} from "../../typings/worker";
import {EDITOR_ACTIONS} from "../../utils/actions";
import {
ACTION_NAME,
EDITOR_ACTIONS,
handleAction,
} from "../../utils/actions";
import {
CONFIG_DEFAULT,
getConfig,
Expand All @@ -27,22 +31,18 @@ import {
getMapValueWithNearestLessThanOrEqualKey,
} from "../../utils/data";
import MonacoInstance from "./MonacoInstance";
import {CustomActionCallback} from "./MonacoInstance/typings";
import {goToPositionAndCenter} from "./MonacoInstance/utils";

import "./index.css";

interface EditorProps {
onCustomAction: CustomActionCallback,
}

/**
* Renders a read-only editor for viewing logs.
*
* @param props
* @param props.onCustomAction
* @return
*/
const Editor = ({onCustomAction}: EditorProps) => {
const {logData, beginLineNumToLogEventNum} = useContext(StateContext);
const Editor = () => {
const {beginLineNumToLogEventNum, logData, numEvents} = useContext(StateContext);
const {logEventNum} = useContext(UrlContext);

const [lineNum, setLineNum] = useState<number>(1);
Expand All @@ -51,8 +51,40 @@ const Editor = ({onCustomAction}: EditorProps) => {
);
const editorRef = useRef<Nullable<monaco.editor.IStandaloneCodeEditor>>(null);
const isMouseDownRef = useRef<boolean>(false);
const logEventNumRef = useRef<Nullable<number>>(logEventNum);
const numEventsRef = useRef<Nullable<number>>(numEvents);
const pageSizeRef = useRef(getConfig(CONFIG_KEY.PAGE_SIZE));

const handleEditorCustomAction = useCallback((
editor: monaco.editor.IStandaloneCodeEditor,
actionName: ACTION_NAME
) => {
if (null === logEventNumRef.current || null === numEventsRef.current) {
return;
}
switch (actionName) {
case ACTION_NAME.FIRST_PAGE:
case ACTION_NAME.PREV_PAGE:
case ACTION_NAME.NEXT_PAGE:
case ACTION_NAME.LAST_PAGE:
handleAction(actionName, logEventNumRef.current, numEventsRef.current);
break;
case ACTION_NAME.PAGE_TOP:
goToPositionAndCenter(editor, {lineNumber: 1, column: 1});
break;
case ACTION_NAME.PAGE_BOTTOM: {
const lineCount = editor.getModel()?.getLineCount();
if ("undefined" === typeof lineCount) {
break;
}
goToPositionAndCenter(editor, {lineNumber: lineCount, column: 1});
break;
}
default:
break;
}
}, []);

/**
* Sets `editorRef` and configures callbacks for mouse down detection.
*/
Expand Down Expand Up @@ -123,9 +155,19 @@ const Editor = ({onCustomAction}: EditorProps) => {
beginLineNumToLogEventNumRef.current = beginLineNumToLogEventNum;
}, [beginLineNumToLogEventNum]);

// Synchronize `logEventNumRef` with `logEventNum`.
useEffect(() => {
logEventNumRef.current = logEventNum;
}, [logEventNum]);

// Synchronize `numEventsRef` with `numEvents`.
useEffect(() => {
numEventsRef.current = numEvents;
}, [numEvents]);

// On `logEventNum` update, update line number in the editor.
useEffect(() => {
if (null === editorRef.current || true === isMouseDownRef.current) {
if (null === editorRef.current || isMouseDownRef.current) {
// Don't update the line number if the user is actively selecting text.
return;
}
Expand All @@ -144,15 +186,17 @@ const Editor = ({onCustomAction}: EditorProps) => {
]);

return (
<MonacoInstance
actions={EDITOR_ACTIONS}
beforeTextUpdate={resetCachedPageSize}
lineNum={lineNum}
text={logData}
onCursorExplicitPosChange={handleCursorExplicitPosChange}
onCustomAction={onCustomAction}
onMount={handleMount}
onTextUpdate={restoreCachedPageSize}/>
<div className={"editor"}>
<MonacoInstance
actions={EDITOR_ACTIONS}
beforeTextUpdate={resetCachedPageSize}
lineNum={lineNum}
text={logData}
onCursorExplicitPosChange={handleCursorExplicitPosChange}
onCustomAction={handleEditorCustomAction}
onMount={handleMount}
onTextUpdate={restoreCachedPageSize}/>
</div>
);
};

Expand Down
Loading
Loading