-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
shell: Manifest validation upon import #21449
base: main
Are you sure you want to change the base?
Conversation
mvollmer
commented
Dec 18, 2024
•
edited
Loading
edited
- shell: Even more types #21425
This is quite WIPy still... |
function validation_error(msg: string): never { | ||
console.error(`JSON validation error for ${validation_path.join("")}: ${msg}`); | ||
throw new ValidationError(); |
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.
These 3 added lines are not executed by any test.
export function import_string(val: JsonValue): string { | ||
if (typeof val == "string") | ||
return val; | ||
validation_error(`Not a string: ${JSON.stringify(val)}`); |
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.
This added line is not executed by any test.
export function import_number(val: JsonValue): number { | ||
if (typeof val == "number") | ||
return val; | ||
validation_error(`Not a number: ${JSON.stringify(val)}`); |
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.
This added line is not executed by any test.
export function import_boolean(val: JsonValue): boolean { | ||
if (typeof val == "boolean") | ||
return val; | ||
validation_error(`Not a boolean: ${JSON.stringify(val)}`); |
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.
These 4 added lines are not executed by any test.
export function import_json_object(val: JsonValue): JsonObject { | ||
if (!!val && typeof val == "object" && val.length === undefined) | ||
return val as JsonObject; | ||
validation_error(`Not an object: ${JSON.stringify(val)}`); |
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.
This added line is not executed by any test.
} catch (e) { | ||
if (!(e instanceof ValidationError)) | ||
throw e; | ||
return fallback; |
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.
These 4 added lines are not executed by any test.
pkg/shell/nav.tsx
Outdated
if (begin < 0) | ||
begin = all.length - 1; | ||
all[begin].focus(); | ||
} else { | ||
let i = all.findIndex(item => item === cur); | ||
i += step; | ||
if (i < 0 || i >= all.length) | ||
document.querySelector("#" + sel + " .pf-v5-c-text-input-group__text-input").focus(); | ||
document.querySelector<HTMLElement>("#" + sel + " .pf-v5-c-text-input-group__text-input")?.focus(); |
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.
This added line is not executed by any test.
pkg/shell/nav.tsx
Outdated
if (g.action) | ||
this.props.jump(g.action.target); |
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.
These 2 added lines are not executed by any test.
@@ -140,8 +142,9 @@ export const LangModal = ({ dialogResult }) => { | |||
<MenuList> | |||
{ | |||
(() => { | |||
const filteredLocales = Object.keys(manifest.locales || {}) | |||
.filter(key => !searchInput || manifest.locales[key].toLowerCase().includes(searchInput.toString().toLowerCase())); | |||
const locales = state.config.manifest.locales || {}; |
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.
This added line is not executed by any test.
// global documentation for cockpit as a whole | ||
(cockpit.manifests.shell?.docs ?? []).forEach(doc => { | ||
(shell_manifest.docs ?? []).forEach(doc => { |
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.
This added line is not executed by any test.
This way, it is only validated once and not on every render.
c3fd607
to
e89ae83
Compare