You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by mi...@apache.org on 2023/10/26 08:00:58 UTC
[incubator-devlake] 05/05: fix(config-ui): disabled scope config save btn when has error
This is an automated email from the ASF dual-hosted git repository.
mintsweet pushed a commit to branch fix-bugs
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 0290bc9dfb83955eada543254b9f621a69718e72
Author: mintsweet <0x...@gmail.com>
AuthorDate: Thu Oct 26 21:00:42 2023 +1300
fix(config-ui): disabled scope config save btn when has error
---
config-ui/src/plugins/components/scope-config-form/index.tsx | 11 ++++++++++-
config-ui/src/plugins/register/github/transformation.tsx | 7 ++++++-
config-ui/src/plugins/register/gitlab/transformation.tsx | 7 ++++++-
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/config-ui/src/plugins/components/scope-config-form/index.tsx b/config-ui/src/plugins/components/scope-config-form/index.tsx
index a8aa0a028..757d3eac0 100644
--- a/config-ui/src/plugins/components/scope-config-form/index.tsx
+++ b/config-ui/src/plugins/components/scope-config-form/index.tsx
@@ -62,6 +62,7 @@ export const ScopeConfigForm = ({
const [entities, setEntities] = useState<string[]>([]);
const [transformation, setTransformation] = useState<any>({});
const [hasRefDiff, setHasRefDiff] = useState(false);
+ const [hasError, setHasError] = useState(false);
const [operating, setOperating] = useState(false);
const config = useMemo(() => getPluginConfig(plugin), []);
@@ -187,6 +188,7 @@ export const ScopeConfigForm = ({
entities={entities}
transformation={transformation}
setTransformation={setTransformation}
+ setHasError={setHasError}
/>
)}
@@ -204,6 +206,7 @@ export const ScopeConfigForm = ({
entities={entities}
transformation={transformation}
setTransformation={setTransformation}
+ setHasError={setHasError}
/>
)}
@@ -253,7 +256,13 @@ export const ScopeConfigForm = ({
</Card>
<Buttons position="bottom" align="right">
<Button outlined intent={Intent.PRIMARY} text="Prev" onClick={handlePrevStep} />
- <Button loading={operating} intent={Intent.PRIMARY} text="Save" onClick={handleSubmit} />
+ <Button
+ loading={operating}
+ disabled={hasError}
+ intent={Intent.PRIMARY}
+ text="Save"
+ onClick={handleSubmit}
+ />
</Buttons>
</>
)}
diff --git a/config-ui/src/plugins/register/github/transformation.tsx b/config-ui/src/plugins/register/github/transformation.tsx
index 93a184fd1..da0279c65 100644
--- a/config-ui/src/plugins/register/github/transformation.tsx
+++ b/config-ui/src/plugins/register/github/transformation.tsx
@@ -28,9 +28,10 @@ interface Props {
entities: string[];
transformation: any;
setTransformation: React.Dispatch<React.SetStateAction<any>>;
+ setHasError: React.Dispatch<React.SetStateAction<boolean>>;
}
-export const GitHubTransformation = ({ entities, transformation, setTransformation }: Props) => {
+export const GitHubTransformation = ({ entities, transformation, setTransformation, setHasError }: Props) => {
const [useCustom, setUseCustom] = useState(false);
useEffect(() => {
@@ -41,6 +42,10 @@ export const GitHubTransformation = ({ entities, transformation, setTransformati
}
}, [transformation]);
+ useEffect(() => {
+ setHasError(useCustom && !transformation.deploymentPattern);
+ }, [useCustom, transformation]);
+
const handleChangeUseCustom = (e: React.FormEvent<HTMLInputElement>) => {
const checked = (e.target as HTMLInputElement).checked;
diff --git a/config-ui/src/plugins/register/gitlab/transformation.tsx b/config-ui/src/plugins/register/gitlab/transformation.tsx
index e2505030e..217d1853d 100644
--- a/config-ui/src/plugins/register/gitlab/transformation.tsx
+++ b/config-ui/src/plugins/register/gitlab/transformation.tsx
@@ -28,9 +28,10 @@ interface Props {
entities: string[];
transformation: any;
setTransformation: React.Dispatch<React.SetStateAction<any>>;
+ setHasError: React.Dispatch<React.SetStateAction<boolean>>;
}
-export const GitLabTransformation = ({ entities, transformation, setTransformation }: Props) => {
+export const GitLabTransformation = ({ entities, transformation, setTransformation, setHasError }: Props) => {
const [useCustom, setUseCustom] = useState(false);
useEffect(() => {
@@ -41,6 +42,10 @@ export const GitLabTransformation = ({ entities, transformation, setTransformati
}
}, [transformation]);
+ useEffect(() => {
+ setHasError(useCustom && !transformation.deploymentPattern);
+ }, [useCustom, transformation]);
+
const handleChangeUseCustom = (e: React.FormEvent<HTMLInputElement>) => {
const checked = (e.target as HTMLInputElement).checked;