diff --git a/packages/main/package.json b/packages/main/package.json
index 785b6051..5217713e 100644
--- a/packages/main/package.json
+++ b/packages/main/package.json
@@ -63,6 +63,7 @@
"slate-history": "^0.93.0",
"slate-react": "^0.105.0",
"tss-react": "^4.9.10",
+ "zod": "^3.23.8",
"zustand": "^4.5.2"
},
"devDependencies": {
diff --git a/packages/main/views/DataSources/components/DataSourcesFiller.tsx b/packages/main/views/DataSources/components/DataSourcesFiller.tsx
index e3bde655..36df7585 100644
--- a/packages/main/views/DataSources/components/DataSourcesFiller.tsx
+++ b/packages/main/views/DataSources/components/DataSourcesFiller.tsx
@@ -6,6 +6,7 @@ import setDataSources from "../store/setDataSources";
import { Button, Field } from "../ui";
import DOMPurify from "isomorphic-dompurify";
import useTheme from "@ui/theme/useTheme"
+import {z} from 'zod'
const InlineFlex = (theme: any) => css`
display: flex;
flex-direction: column;
@@ -50,12 +51,15 @@ const ForAllButton = css`
flex: 1;
`;
+export const urlSchema = z.string().url()
+
export const DataSourcesFiller = (props: any) => {
const [url, setUrl] = useState("");
const [user, setUser] = useState("");
const [password, setPassword] = useState("");
const [oneForAll, setOneForAll] = useState(false);
const [basicAuth, setBasicAuth] = useState(false);
+ const [urlValid, setUrlValid] = useState(false)
const dataSources = useSelector((store: any) => store.dataSources);
const dispatch: any = useDispatch();
const submitMessage = "Save";
@@ -63,8 +67,11 @@ export const DataSourcesFiller = (props: any) => {
const urlChange = (e: any) => {
const value = e?.target?.value || "";
- const strippedValue = value.replace(/\/$/, '');
- setUrl(() => strippedValue);
+ const message = urlSchema.safeParse(value)
+
+ setUrlValid(()=> message.success)
+
+ setUrl(() => value);
};
const userChange = (e: any) => {
setUser(() => e.target.value);
@@ -123,7 +130,7 @@ export const DataSourcesFiller = (props: any) => {
value={DOMPurify.sanitize(url)}
label={"url"}
onChange={urlChange}
- placeholder={"http://qryn.dev"}
+ placeholder={window.location.origin}
/>
{basicAuth && (
<>
@@ -154,10 +161,13 @@ export const DataSourcesFiller = (props: any) => {
+
)}
diff --git a/packages/main/views/DataSources/styles.ts b/packages/main/views/DataSources/styles.ts
index c2dd228a..49da7a20 100644
--- a/packages/main/views/DataSources/styles.ts
+++ b/packages/main/views/DataSources/styles.ts
@@ -78,7 +78,7 @@ export const PageContainer: any = styled.div`
cursor: pointer;
}
.ds-settings {
- background: ${({ theme }: any) => theme.background};
+ background: ${({ theme }: any) => theme.shadow};
}
}
.plugins-cont {
@@ -210,15 +210,16 @@ export const SettingsTitle: any = styled.div`
`;
export const DataSourceSettingsCont: any = styled.div`
- background: ${({ theme }: any) => theme.deep};
padding: 10px;
border-radius: 0px 0px 3px 3px;
border-top: 1px solid ${({ theme }: any) => theme.accentNeutral};
`;
export const DsButtonStyled: any = styled(BtnSmall)`
+
background: ${(props: any) =>
props.primary ? props.theme.primary : props.theme.neutral};
+
border: 1px solid ${({ theme }: any) => theme.accentNeutral};
color: ${(props: any) =>
props.primary ? props.theme.maxContrast : props.theme.contrast};
@@ -229,7 +230,7 @@ export const DsButtonStyled: any = styled(BtnSmall)`
height: 26px;
display: flex;
&:hover {
- background: ${({ theme }: any) => theme.primaryLight};
+ background: ${({ theme, disabled }: any) => disabled ? theme.neutral : theme.primaryLight};
color: ${(props: any) =>
props.primary ? props.theme.contrast : props.theme.maxContrast};
}
diff --git a/packages/main/views/DataSources/styles/Container.tsx b/packages/main/views/DataSources/styles/Container.tsx
index b3b8e57b..c2fb87b1 100644
--- a/packages/main/views/DataSources/styles/Container.tsx
+++ b/packages/main/views/DataSources/styles/Container.tsx
@@ -73,7 +73,7 @@ export const Container: any = styled.div<{theme:any}>`
cursor: pointer;
}
.ds-settings {
- background: ${({ theme }) => theme.background};
+ background: ${({ theme }) => theme.shadow};
}
}
`;
\ No newline at end of file
diff --git a/packages/main/views/DataSources/ui/Button.tsx b/packages/main/views/DataSources/ui/Button.tsx
index 04e7089f..3cd5b583 100644
--- a/packages/main/views/DataSources/ui/Button.tsx
+++ b/packages/main/views/DataSources/ui/Button.tsx
@@ -3,9 +3,9 @@ import { DsButtonStyled } from "../styles";
export const Button = (props: any) => {
- const { value, onClick, primary, title } = props;
+ const { value, onClick, primary, title, disabled } = props;
return (
-
+
{value}
);
diff --git a/packages/main/views/DataSources/views/Settings.tsx b/packages/main/views/DataSources/views/Settings.tsx
index f13cb4ce..3f552e9d 100644
--- a/packages/main/views/DataSources/views/Settings.tsx
+++ b/packages/main/views/DataSources/views/Settings.tsx
@@ -24,11 +24,8 @@ export const Settings = (props: any) => {
});
const onFieldChange = (prop: any, value: any) => {
let val = value;
- if (prop === "url") {
- const strippedValue = value.replace(/\/$/, "");
- val = strippedValue;
- }
const arrayClone = JSON.parse(JSON.stringify(state));
+
arrayClone.forEach((field: any) => {
if (field.id === id) {
field[prop] = val;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f5a3802f..3cd6bf4b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -195,6 +195,9 @@ importers:
tss-react:
specifier: ^4.9.10
version: 4.9.10(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@mui/material@5.15.20(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@emotion/styled@11.11.5(@emotion/react@11.11.4(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
+ zod:
+ specifier: ^3.23.8
+ version: 3.23.8
zustand:
specifier: ^4.5.2
version: 4.5.2(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1)
@@ -3120,6 +3123,9 @@ packages:
resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==}
engines: {node: '>=12.20'}
+ zod@3.23.8:
+ resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==}
+
zustand@4.5.2:
resolution: {integrity: sha512-2cN1tPkDVkwCy5ickKrI7vijSjPksFRfqS6237NzT0vqSsztTNnQdHw9mmN7uBdk3gceVXU0a+21jFzFzAc9+g==}
engines: {node: '>=12.7.0'}
@@ -6071,6 +6077,8 @@ snapshots:
yocto-queue@1.0.0: {}
+ zod@3.23.8: {}
+
zustand@4.5.2(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1):
dependencies:
use-sync-external-store: 1.2.0(react@18.3.1)