Skip to content

Commit

Permalink
feat: update api
Browse files Browse the repository at this point in the history
- removed dynamic imports to access schemas
- removed events (for now, let's see if we like the business logic in the component)
  • Loading branch information
NilsJacobsen committed Mar 21, 2024
1 parent c2732cf commit 5552dc5
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 171 deletions.
106 changes: 101 additions & 5 deletions inlang/source-code/settings-component/src/mock/project.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export let mockSettings = {
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 @@ -42,32 +47,123 @@ export const mockProject = {
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: "message-lint-rule-empty-pattern",
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: "message-lint-rule-identical-pattern",
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: "message-lint-rule-missing-translation",
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: "message-lint-rule-without-source",
id: "messageLintRule.inlang.messageWithoutSource",
displayName: "Without Source",
description: "Without Source",
module:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,5 @@ const meta: Meta = {
export default meta

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

0 comments on commit 5552dc5

Please sign in to comment.