-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Use Monaco editor in ConfigMap details #6830
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8cf12da
Use monaco in config map details
aleksfront 46732de
Add ability to set monaco initial height regarding to text lines
aleksfront 66a2874
Refactor get initialHeightClassName()
aleksfront 60920a4
Rename injectable to getEditorHeightFromLinesCountInjectable
aleksfront 879402e
Lint fixes
aleksfront 3dfb6b9
Better monaco editor view for the light theme
aleksfront cff598e
Merge branch 'master' into use-monaco-in-configmap-details
aleksfront 161e9d5
Merge branch 'master' into use-monaco-in-configmap-details
aleksfront dbc04a7
Set initial height refactoring
aleksfront 9aa3a4b
Linter fixes
aleksfront 44ae3d6
Merge branch 'master' into use-monaco-in-configmap-details
aleksfront eb3f49d
Clean up
aleksfront 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 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
30 changes: 30 additions & 0 deletions
30
src/renderer/components/monaco-editor/get-editor-height-from-lines-number.injectable.ts
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,30 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
|
||
import { getInjectable } from "@ogre-tools/injectable"; | ||
|
||
const getEditorHeightFromLinesCountInjectable = getInjectable({ | ||
id: "get-editor-height-from-lines-number", | ||
|
||
instantiate: () => { | ||
return (linesCount: number) => { | ||
if (typeof linesCount !== "number") { | ||
throw new Error("linesNumber must be a number"); | ||
} | ||
|
||
if (linesCount < 10) { | ||
return 90; | ||
} | ||
|
||
if (linesCount < 20) { | ||
return 180; | ||
} | ||
|
||
return 360; | ||
}; | ||
}, | ||
}); | ||
|
||
export default getEditorHeightFromLinesCountInjectable; |
47 changes: 47 additions & 0 deletions
47
src/renderer/components/monaco-editor/get-editor-height-from-lines-number.test.ts
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,47 @@ | ||
/** | ||
* Copyright (c) OpenLens Authors. All rights reserved. | ||
* Licensed under MIT License. See LICENSE in root directory for more information. | ||
*/ | ||
|
||
import { getDiForUnitTesting } from "../../getDiForUnitTesting"; | ||
import getEditorHeightFromLinesCountInjectable from "./get-editor-height-from-lines-number.injectable"; | ||
|
||
describe("get-editor-height-from-lines-number", () => { | ||
let getEditorHeightFromLinesNumber: (linesCount: number) => number; | ||
|
||
beforeEach(() => { | ||
const di = getDiForUnitTesting({ doGeneralOverrides: false }); | ||
|
||
getEditorHeightFromLinesNumber = di.inject(getEditorHeightFromLinesCountInjectable); | ||
}); | ||
|
||
it("given linesCount is less than 10, when called, returns small number", () => { | ||
const actual = getEditorHeightFromLinesNumber(9); | ||
|
||
expect(actual).toBe(90); | ||
}); | ||
|
||
it("given linesCount is equal to 10, when called, returns medium number", () => { | ||
const actual = getEditorHeightFromLinesNumber(10); | ||
|
||
expect(actual).toBe(180); | ||
}); | ||
|
||
it("given linesCount is greater than 10 and less than 20, when called, returns medium number", () => { | ||
const actual = getEditorHeightFromLinesNumber(19); | ||
|
||
expect(actual).toBe(180); | ||
}); | ||
|
||
it("given linesCount is equal to 20, when called, returns large number", () => { | ||
const actual = getEditorHeightFromLinesNumber(20); | ||
|
||
expect(actual).toBe(360); | ||
}); | ||
|
||
it("given linesCount is greater than 20, when called, returns large number", () => { | ||
const actual = getEditorHeightFromLinesNumber(21); | ||
|
||
expect(actual).toBe(360); | ||
}); | ||
}); |
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
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.
So why in general do we need this function/feature to be
*.injectable.ts
?Any useful examples of how it would be utilized later in other envs? Or what's purpose in other words?
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.
It is implemented as injectable to follow de-facto standard and being able to inject it as dependency into
MonacoEditor
:Without
injectable
format it would be used from the shared state (eg. imported module) which is considered as bad practice.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.
Alright, but why you've decided to control only height from MonacoEditor and this is why it's moved to
injectable.ts
?You still didn't answer my question: if you able to control height of the editor, when/where would be reused?
Some examples? Maybe builds for
lens-ide
orlens-some-build
with different initial heights for the editor? This would make sense?