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

add documentation and root hash change handling #2798

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nervous-nails-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inlang/plugin-i18next": minor
---

increase batching to 50 for i18n plugin
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,7 @@ inlang/source-code/paraglide/paraglide-solidstart/example/.solid
*.h.ts.mjs
**/vite.config.ts.timestamp-*
**/vite.config.js.timestamp-*


# gitea test instance data
lix/packages/gitea
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ export default function Page() {
* is required to use the useEditorState hook.
*/
function TheActualPage() {
const { repo, currentBranch, project, projectList, routeParams, tourStep, lixErrors, languageTags } =
useEditorState()
const {
repo,
currentBranch,
project,
projectList,
routeParams,
tourStep,
lixErrors,
languageTags,
} = useEditorState()
const [localStorage, setLocalStorage] = useLocalStorage()

onMount(() => {
Expand Down Expand Up @@ -165,12 +173,16 @@ function TheActualPage() {
currentId="textfield"
position="bottom-left"
offset={{ x: 110, y: 144 }}
isVisible={tourStep() === "textfield" && messageCount() !== 0 && languageTags().length > 1}
><></></TourHintWrapper>
<For each={project()!.query.messages.includedMessageIds()}>
{(id) => {
return <Message id={id} />
}}
isVisible={
tourStep() === "textfield" && messageCount() !== 0 && languageTags().length > 1
}
>
<></>
</TourHintWrapper>
<For each={project()!.query.messages.includedMessageIds()}>
{(id) => {
return <Message id={id} />
}}
</For>
</Show>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ function Breadcrumbs() {
* The menu to select the branch.
*/
function BranchMenu() {
const { activeBranch, setActiveBranch, branchNames, currentBranch } = useEditorState()
const { activeBranch, setActiveBranch, setBranchListEnabled, branchList, currentBranch } =
useEditorState()
return (
<sl-tooltip
prop:content="Select branch"
Expand All @@ -476,12 +477,15 @@ function BranchMenu() {
class="small"
style={{ "--show-delay": "1s" }}
>
<sl-dropdown prop:distance={8}>
<sl-dropdown prop:distance={8} on:sl-show={() => setBranchListEnabled(true)}>
<sl-button
slot="trigger"
prop:caret={true}
prop:size="small"
prop:loading={currentBranch() !== activeBranch() && activeBranch() !== undefined}
prop:loading={
(currentBranch() !== activeBranch() && activeBranch() !== undefined) ||
(branchList.loading && !branchList())
}
>
<div slot="prefix">
{/* branch icon from github */}
Expand All @@ -497,15 +501,25 @@ function BranchMenu() {
</sl-button>

<sl-menu class="w-48 min-w-fit">
<For each={branchNames()}>
{(branch) => (
<div onClick={() => setActiveBranch(branch)}>
<sl-menu-item prop:type="checkbox" prop:checked={currentBranch() === branch}>
{branch}
</sl-menu-item>
</div>
)}
</For>
<Show
when={branchList()}
fallback={<sl-menu-item prop:disabled={true}>Loading...</sl-menu-item>}
>
<For each={branchList()}>
{(branch) => (
<div
onClick={() => {
setActiveBranch(branch)
setBranchListEnabled(false) // prevent refetching after selecting branch
}}
>
<sl-menu-item prop:type="checkbox" prop:checked={currentBranch() === branch}>
{branch}
</sl-menu-item>
</div>
)}
</For>
</Show>
</sl-menu>
</sl-dropdown>
</sl-tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type EditorStateSchema = {
* Fork status of the repository.
*/

forkStatus: () => { ahead: number; behind: number; conflicts: boolean }
forkStatus: () => { ahead: number; behind: number; conflicts: Record<string, any> | undefined }
/**
* Refetch the fork status.
*/
Expand All @@ -75,7 +75,11 @@ type EditorStateSchema = {
/**
* The branch names of current repo.
*/
branchNames: Resource<string[] | undefined>
setBranchListEnabled: Setter<boolean>
/**
* Trigger the branch list to be fetched.
*/
branchList: Resource<string[] | undefined>
/**
* Additional information about a repository provided by GitHub.
*/
Expand Down Expand Up @@ -503,13 +507,19 @@ export function EditorStateProvider(props: { children: JSXElement }) {
} else {
setTimeout(() => {
const element = document.getElementById("missingTranslation-summary")
element !== null && !filteredMessageLintRules().includes("messageLintRule.inlang.missingTranslation") ? setTourStep("missing-translation-rule") : setTourStep("textfield")
element !== null &&
!filteredMessageLintRules().includes("messageLintRule.inlang.missingTranslation")
? setTourStep("missing-translation-rule")
: setTourStep("textfield")
}, 100)
}
} else if (tourStep() === "missing-translation-rule" && project()) {
setTimeout(() => {
const element = document.getElementById("missingTranslation-summary")
element !== null && !filteredMessageLintRules().includes("messageLintRule.inlang.missingTranslation") ? setTourStep("missing-translation-rule") : setTourStep("textfield")
element !== null &&
!filteredMessageLintRules().includes("messageLintRule.inlang.missingTranslation")
? setTourStep("missing-translation-rule")
: setTourStep("textfield")
}, 100)
}
})
Expand Down Expand Up @@ -541,9 +551,9 @@ export function EditorStateProvider(props: { children: JSXElement }) {
)

/**
* createResource is not reacting to changes like: "false","Null", or "undefined".
* Hence, a string needs to be passed to the fetch of the resource.
*/
* createResource is not reacting to changes like: "false","Null", or "undefined".
* Hence, a string needs to be passed to the fetch of the resource.
*/
const [userIsCollaborator] = createResource(
() => {
// do not fetch if no owner or repository is given
Expand Down Expand Up @@ -596,16 +606,22 @@ export function EditorStateProvider(props: { children: JSXElement }) {
}
},
async (args) => {
await new Promise((resolve) => setTimeout(resolve, 10000))
// wait for the browser to be idle
await new Promise((resolve) => requestIdleCallback(resolve))

console.info("fetching forkStatus")

const value = await args.repo!.forkStatus()
if ("error" in value) {
// Silently ignore errors:
// The branch might only exist in the fork and not in the upstream repository.
return { ahead: 0, behind: 0, conflicts: false }
return { ahead: 0, behind: 0, conflicts: undefined }
} else {
return value
}
},
{ initialValue: { ahead: 0, behind: 0, conflicts: false } }
{ initialValue: { ahead: 0, behind: 0, conflicts: undefined } }
)

const [previousLoginStatus, setPreviousLoginStatus] = createSignal(localStorage?.user?.isLoggedIn)
Expand Down Expand Up @@ -641,16 +657,24 @@ export function EditorStateProvider(props: { children: JSXElement }) {
}
)

const [branchNames] = createResource(
const [branchListEnabled, setBranchListEnabled] = createSignal(false)
const [branchList] = createResource(
() => {
if (
repo() === undefined ||
githubRepositoryInformation() === undefined ||
!branchListEnabled()
) {
return false
}
return { repo: repo() }
},
async (args) => {
console.info("fetching branchList")
return await args.repo?.getBranches()
}
)


return (
<EditorStateContext.Provider
value={
Expand All @@ -664,7 +688,8 @@ export function EditorStateProvider(props: { children: JSXElement }) {
mergeUpstream,
createFork,
currentBranch,
branchNames,
setBranchListEnabled,
branchList,
githubRepositoryInformation,
routeParams,
searchParams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@
const from = new URL(get(page).url)
const original_to = new URL(href, new URL(from))

if (
isExternal(original_to, from, absoluteBase) ||
i18n.config.exclude(original_to.pathname)
) return href
if (isExternal(original_to, from, absoluteBase) || i18n.config.exclude(original_to.pathname))
return href

const language = hreflang ?? lang

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ it("should apply on a component that matches the translation", () => {
],
})
).toBe(true)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const rewrite = ({
? attrubuteValuesToJSValue(
langAttribute.value,
originalCode
)
)
: "undefined"
}
)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ElementNode<Name extends stirng> = {
? {
name: "svelte:element"
tag: string | Expression
}
}
: { name: Name })

type Expression = {
Expand Down
2 changes: 1 addition & 1 deletion inlang/source-code/sdk/src/createNodeishFsWithWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const createNodeishFsWithWatcher = (args: {
ac.abort()
}
// release references
abortControllers = [];
abortControllers = []
}

const makeWatcher = (path: string) => {
Expand Down
1 change: 1 addition & 0 deletions lix/packages/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
docker-compose.yaml
gitea
2 changes: 1 addition & 1 deletion lix/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"async-lock": "^1.4.1",
"clean-git-ref": "^2.0.1",
"crc-32": "^1.2.2",
"diff3": "^0.0.4",
"diff3": "./vendored/diff3",
"ignore": "^5.3.1",
"octokit": "3.1.2",
"pako": "^1.0.11",
Expand Down