Skip to content

Commit

Permalink
Merge branch 'lix-integration' into samuel/fix-old-neu
Browse files Browse the repository at this point in the history
  • Loading branch information
janfjohannes committed Aug 13, 2024
2 parents 5e1e6a6 + 1a9b96b commit 476fd8e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const VariantHistoryList = (props: {
setLoading(undefined);
props.setHistoryModalOpen(false);
props.setSelectedVariantId(null);
}, 2000);
}, 1000);
}
};

Expand All @@ -51,7 +51,7 @@ const VariantHistoryList = (props: {
getChanges();
const interval = setInterval(async () => {
await getChanges();
}, 2000);
}, 1000);
return () => clearInterval(interval);
}, [project]);

Expand Down
20 changes: 11 additions & 9 deletions inlang/source-code/fink2/src/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useAtom } from "jotai";
import { selectedProjectPathAtom, withPollingAtom } from "./state.ts";
import { projectAtom, selectedProjectPathAtom, withPollingAtom } from "./state.ts";
import { useEffect, useMemo, useState } from "react";
import SlDialog from "@shoelace-style/shoelace/dist/react/dialog/index.js";
import { newProject } from "@inlang/sdk2";
Expand All @@ -19,7 +19,7 @@ export default function Layout(props: { children: React.ReactNode }) {
useEffect(() => {
const interval = setInterval(() => {
setWithPolling(Date.now());
}, 2000);
}, 1000);
return () => clearInterval(interval);
});

Expand All @@ -42,7 +42,6 @@ const MenuBar = () => {

<div>
<CreateNewProject size="small" />
<ImportComponent />
<SettingsButton />
</div>
</div>
Expand Down Expand Up @@ -71,7 +70,7 @@ const SelectProject = () => {
return (
<>
<SlSelect
//disabled={existingProjects.length === 0}
disabled={selectedProjectPath === undefined}
size="small"
placeholder={
selectedProjectPath ? selectedProjectPath : "Select project"
Expand Down Expand Up @@ -160,10 +159,10 @@ export const CreateNewProject = (props: { size: "small" | "large" }) => {
>
<SlInput
label="Filename"
helpText="The file name must end with .inlang"
placeholder="happy-elephant.inlang"
helpText={fileName ? `Create project file ${fileName}` : "Enter the name of your inlang file"}
placeholder="my-website"
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onInput={(e: any) => setFileName(e.target.value)}
onInput={(e: any) => setFileName(e.target.value ? e.target.value + ".inlang" : "")}
></SlInput>
<SlButton
loading={loading}
Expand All @@ -180,11 +179,14 @@ export const CreateNewProject = (props: { size: "small" | "large" }) => {
};

const SettingsButton = () => {
// check if window.location.pathname === "/settings"
const [project] = useAtom(projectAtom);

return (
<Link to="/settings">
<SlButton slot="trigger" size="small" variant="default">
<SlButton
disabled={project === undefined}
slot="trigger" size="small" variant="default"
>
Settings
</SlButton>
</Link>
Expand Down
11 changes: 9 additions & 2 deletions inlang/source-code/fink2/src/routes/changes/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "../../state.ts";
import { atom, useAtom } from "jotai";
import Layout from "../../layout.tsx";
import { useState } from "react";
import { useEffect, useState } from "react";
import {
SlButton,
SlDialog,
Expand Down Expand Up @@ -44,9 +44,15 @@ export default function App() {
userId: commitAuthor,
description: commitDescription,
});
setShowDialog(false);
};

useEffect(() => {
// close dialog after commit
if (pendingChanges.length === 0) {
setShowDialog(false);
}
})

const getScopedChangesByBundle = (bundle: BundleNested) => {
const pendingChangesForBundle = pendingChanges.filter((change) => {
const variantId = change.value?.id;
Expand All @@ -72,6 +78,7 @@ export default function App() {
<SlButton
size="small"
variant="primary"
disabled={pendingChanges.length === 0}
onClick={() => {
setShowDialog(true);
}}
Expand Down
2 changes: 1 addition & 1 deletion inlang/source-code/fink2/src/routes/settings/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function App() {
// TODO not working why?
setSettings(settings);
}
}, 3000);
}, 2000);
}, [project]);

return (
Expand Down
2 changes: 1 addition & 1 deletion inlang/source-code/fink2/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const projectAtom = atom(async (get) => {
const file = await project.toBlob();
await writable.write(file);
await writable.close();
}, 2000);
}, 1000);
return project;
} catch (e) {
console.error(e);
Expand Down

0 comments on commit 476fd8e

Please sign in to comment.