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

update component api #2411

Merged
merged 5 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading