Skip to content

Commit 5688612

Browse files
committed
Remove unused code and fix variable config form type
1 parent 423e45a commit 5688612

File tree

2 files changed

+7
-49
lines changed

2 files changed

+7
-49
lines changed

src/App.js

-48
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,6 @@ import GroupWithAccordion, {
2222

2323
const App = () => {
2424

25-
const fetchDocumentation = (configType) => {
26-
if (configType === 'metadata') {
27-
return;
28-
}
29-
let docs = 'https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/configuration/';
30-
if (configType === 'indicator') {
31-
docs = 'https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/indicator-configuration/';
32-
}
33-
fetch(docs)
34-
.then(response => {
35-
return response.json()
36-
})
37-
.then(data => {
38-
setDocumentation(data);
39-
});
40-
}
41-
42-
const setDocumentation = (data) => {
43-
const el = document.createElement('html');
44-
el.innerHTML = '<html><head><title>titleTest</title></head><body>' + data.content + '</body></html>';
45-
const section = el.querySelector('.section');
46-
let currentId = null;
47-
const settings = {};
48-
for (const child of section.children) {
49-
if (child.id) {
50-
currentId = child.id;
51-
}
52-
if (currentId) {
53-
if (!settings[currentId]) {
54-
settings[currentId] = '';
55-
}
56-
settings[currentId] += child.outerHTML;
57-
}
58-
}
59-
for (const documentationKey of Object.keys(settings)) {
60-
const accordionEl = document.getElementById(documentationKey + '-documentation');
61-
if (accordionEl) {
62-
accordionEl.innerHTML = settings[documentationKey];
63-
const links = accordionEl.getElementsByTagName('a');
64-
for (const link of links) {
65-
link.target = '_blank';
66-
}
67-
}
68-
}
69-
}
70-
7125
const theme = createTheme({
7226
components: {
7327
MuiTabs: {
@@ -129,14 +83,12 @@ const App = () => {
12983
githubOwner,
13084
repoUrl,
13185
repositoryLink,
132-
configType,
13386
} = opensdg.configForm;
13487
const [formData, setFormData] = useState(initialData);
13588
const [formErrors, setFormErrors] = useState(null);
13689
const jsonformsConfig = {
13790
showUnfocusedDescription: true,
13891
};
139-
setTimeout(fetchDocumentation.bind(null, configType), 2000);
14092
return (
14193
<>
14294
<SearchBar

src/hooks.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ const parseDocumentation = (data) => {
2323

2424
export const useFetchDocumentation = () => {
2525
const cache = useRef({});
26-
const url = 'https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/configuration/';
26+
if (opensdg.configForm.configType === 'metadata') {
27+
return;
28+
}
29+
let url = 'https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/configuration/';
30+
if (opensdg.configForm.configType === 'indicator') {
31+
url = 'https://readthedocs.org/api/v3/embed/?format=json&url=https://open-sdg.readthedocs.io/en/latest/indicator-configuration/';
32+
}
2733

2834
const initialState = {
2935
status: 'idle',

0 commit comments

Comments
 (0)