Skip to content

Commit ab5d6a5

Browse files
committed
Fix taxonomy deletion on skill wizard loading
Seems like skill page renders before deployment type is set and that results in loading SkillFormGithub, and that eventually calls the /api/github/tree api's. Once the deployment type value is set, it renders the SkillFormNative. Calling of /api/github/tree, overwrite the taxonomy if it sees that the remote sha is not same as local sha. This is expected because in case of the github mode local taxonomy is only read only, and it clones the latest taxonomy if remote sha is not equal to local sha. But in native mode, local taxonomy is used for caching the submitted contribution as well, so it doesn't have to pull any new changes upstream because call the taxonomy changes are in the scope of single user and that too present on the same machine. But in both the mode, local taxonomy is store at same directory location, so in case of native mode, if the api/github/tree api is called, it will see that the remote sha is not same as local sha and it will clone the latest from the upstream. This fix ensure that SkillFormGithub is not loaded in native mode. Signed-off-by: Anil Vishnoi <[email protected]>
1 parent 8d330fa commit ab5d6a5

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/app/contribute/skill/page.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,43 @@
33
import { AppLayout } from '@/components/AppLayout';
44
import { SkillFormGithub } from '@/components/Contribute/Skill/Github/index';
55
import { SkillFormNative } from '@/components/Contribute/Skill/Native/index';
6+
import { t_global_spacer_xl as XlSpacerSize } from '@patternfly/react-tokens';
7+
import { Flex, Spinner } from '@patternfly/react-core';
68
import { useEffect, useState } from 'react';
79

810
const SkillFormPage: React.FunctionComponent = () => {
911
const [deploymentType, setDeploymentType] = useState<string | undefined>();
12+
const [loaded, setLoaded] = useState<boolean>();
1013

1114
useEffect(() => {
15+
let canceled = false;
16+
1217
const getEnvVariables = async () => {
1318
const res = await fetch('/api/envConfig');
1419
const envConfig = await res.json();
15-
setDeploymentType(envConfig.DEPLOYMENT_TYPE);
20+
if (!canceled) {
21+
setDeploymentType(envConfig.DEPLOYMENT_TYPE);
22+
setLoaded(true);
23+
}
1624
};
25+
1726
getEnvVariables();
18-
}, []);
1927

20-
return <AppLayout className="contribute-page">{deploymentType === 'native' ? <SkillFormNative /> : <SkillFormGithub />}</AppLayout>;
28+
return () => {
29+
canceled = true;
30+
};
31+
}, []);
32+
return (
33+
<AppLayout className="contribute-page">
34+
{loaded ? (
35+
<>{deploymentType === 'native' ? <SkillFormNative /> : <SkillFormGithub />}</>
36+
) : (
37+
<Flex alignItems={{ default: 'alignItemsCenter' }} justifyContent={{ default: 'justifyContentCenter' }} style={{ padding: XlSpacerSize.var }}>
38+
<Spinner size="xl" />
39+
</Flex>
40+
)}
41+
</AppLayout>
42+
);
2143
};
2244

2345
export default SkillFormPage;

0 commit comments

Comments
 (0)