Skip to content

Commit

Permalink
Merge pull request #2411 from opral/nilsjacobsen/inlmc-22-results-aft…
Browse files Browse the repository at this point in the history
…er-call

update component api
  • Loading branch information
NilsJacobsen committed Mar 21, 2024
2 parents 2dc0561 + 5552dc5 commit d80d9e8
Show file tree
Hide file tree
Showing 10 changed files with 1,904 additions and 1,820 deletions.
5 changes: 1 addition & 4 deletions inlang/source-code/settings-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
"esbuild": "^0.20.0"
},
"dependencies": {
"@inlang/project-settings": "workspace:^",
"@inlang/module": "workspace:^",
"@inlang/message-lint-rule": "workspace:^",
"@inlang/plugin": "workspace:^",
"@inlang/sdk": "workspace:^",
"@lit/task": "^1.0.0",
"@shoelace-style/shoelace": "2.14.0"
}
Expand Down
145 changes: 144 additions & 1 deletion inlang/source-code/settings-component/src/mock/project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export const mockProject = {
import type { InlangProject } from "@inlang/sdk"

export let mockSettings: ReturnType<InlangProject["settings"]> = {
$schema: "https://inlang.com/schema/project-settings",
sourceLanguageTag: "en",
languageTags: ["en", "es", "fr", "pt-br", "ru", "zh-cn"],
messageLintRuleLevels: {
"messageLintRule.inlang.identicalPattern": "error",
},
modules: [
"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@4/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
Expand Down Expand Up @@ -32,3 +37,141 @@ export const mockProject = {
},
},
}

export const mockProject = {
id: "mock-project",
installed: {
plugins: () => [
{
id: "plugin.inlang.i18next",
displayName: "i18next",
description: "i18next",
module: "https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@4/dist/index.js",
settingsSchema: {
type: "object",
properties: {
pathPattern: {
anyOf: [
{
pattern: "^(\\./|\\../|/)[^*]*\\{languageTag\\}[^*]*\\.json",
description: "The pathPattern must contain `{languageTag}` and end with `.json`.",
examples: [
"./{languageTag}/file.json",
"../folder/{languageTag}/file.json",
"./{languageTag}.json",
],
type: "string",
},
{
type: "object",
patternProperties: {
"^[^.]+$": {
pattern: "^(\\./|\\../|/)[^*]*\\{languageTag\\}[^*]*\\.json",
description:
"The pathPattern must contain `{languageTag}` and end with `.json`.",
examples: [
"./{languageTag}/file.json",
"../folder/{languageTag}/file.json",
"./{languageTag}.json",
],
type: "string",
},
},
},
],
},
variableReferencePattern: {
type: "array",
items: {
type: "string",
},
},
sourceLanguageFilePath: {
anyOf: [
{
pattern: "^(\\./|\\../|/)[^*]*\\{languageTag\\}[^*]*\\.json",
description: "The pathPattern must contain `{languageTag}` and end with `.json`.",
examples: [
"./{languageTag}/file.json",
"../folder/{languageTag}/file.json",
"./{languageTag}.json",
],
type: "string",
},
{
type: "object",
patternProperties: {
"^[^.]+$": {
pattern: "^(\\./|\\../|/)[^*]*\\{languageTag\\}[^*]*\\.json",
description:
"The pathPattern must contain `{languageTag}` and end with `.json`.",
examples: [
"./{languageTag}/file.json",
"../folder/{languageTag}/file.json",
"./{languageTag}.json",
],
type: "string",
},
},
},
],
},
ignore: {
type: "array",
items: {
type: "string",
},
},
},
required: ["pathPattern"],
},
},
],
messageLintRules: () => [
{
id: "messageLintRule.inlang.emptyPattern",
displayName: "Empty Pattern",
description: "Empty Pattern",
module:
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
},
{
id: "messageLintRule.inlang.identicalPattern",
displayName: "Identical Pattern",
description: "Identical Pattern",
module:
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@latest/dist/index.js",
settingsSchema: {
type: "object",
properties: {
ignore: {
type: "array",
items: {
pattern: "[^*]",
description: "All items in the array need quotaion marks at the end and beginning",
type: "string",
},
},
},
},
},
{
id: "messageLintRule.inlang.missingTranslation",
displayName: "Missing Translation",
description: "Missing Translation",
module:
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
},
{
id: "messageLintRule.inlang.messageWithoutSource",
displayName: "Without Source",
description: "Without Source",
module:
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
},
],
},
errors: () => [],
settings: () => mockSettings,
setSettings: (settings: any) => (mockSettings = settings),
}
10 changes: 0 additions & 10 deletions inlang/source-code/settings-component/src/stories/Configure.mdx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,5 @@ const meta: Meta = {
export default meta

export const Default: StoryObj = {
render: () =>
html`
<inlang-settings
.settings=${mockProject}
@onSetSettings=${(settings: any) => console.info("save", settings)}
></inlang-settings>
`,
}

export const HTML: StoryObj = {
render: () =>
`
<script>
document.querySelector('inlang-settings').addEventListener('onSetSettings', (settings) => {
console.info("save", settings);
});
</script>
<inlang-settings
id="my-element"
settings=${JSON.stringify(mockProject)}
></inlang-settings>
`,
render: () => html` <inlang-settings .project=${mockProject}></inlang-settings> `,
}
Loading

0 comments on commit d80d9e8

Please sign in to comment.