Skip to content

Commit 82dc6ed

Browse files
Publish fixes and moving to Es6 from common js
1 parent ab3999d commit 82dc6ed

38 files changed

+562
-454
lines changed

.fdk/configs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"request":{"timeout":15000}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('Sample test', () => {
2+
it('should test that true === true', () => {
3+
expect(true).toBe(true)
4+
})
5+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { describe, expect, it } from '@jest/globals';
2+
3+
describe('Sample test', () => {
4+
it('should test that true === true', () => {
5+
expect(true).toBe(true)
6+
})
7+
});

client/.eslintrc.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ module.exports = {
1414
'warn',
1515
{ allowConstantExport: true },
1616
],
17+
'react-hooks/exhaustive-deps': 'off',
18+
'react-refresh/only-export-components': 'off',
1719
},
1820
}

client/src/App.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { nopalmGitHubPath } from './helpers/constants';
3535
import Select from 'antd/es/select';
3636

3737
import { fetchAndSetProjectDetails, setCurrentProjectDirectoryPath } from './store/slices/project';
38+
3839
import { fetchAndSetInstalledPackages, setPackagesLoading } from './store/slices/packages';
3940

4041
const { Header, Content, Sider } = Layout;
@@ -80,17 +81,8 @@ const App: React.FC = () => {
8081

8182
const allProjectDirectoryPaths = useSelector((state: RootState) => state.project.allProjectDirectoryPaths);
8283

83-
function routeChangeHandler() {
84-
const currentPath = window.location.pathname.slice(1);
85-
86-
const pathToSet = currentPath === '' ? 'project_details' : currentPath;
87-
88-
dispatch(setCurrentActiveRoute(pathToSet));
89-
}
90-
9184
async function directoryPathChangeHandler(inp: string) {
9285
await dispatch(setCurrentProjectDirectoryPath(inp));
93-
debugger;
9486
// Retrieve and update project details always when directory path changes
9587
await dispatch(fetchAndSetProjectDetails());
9688

@@ -114,6 +106,13 @@ const App: React.FC = () => {
114106
}
115107

116108
useEffect(() => {
109+
const routeChangeHandler = () => {
110+
const currentPath = window.location.pathname.slice(1);
111+
112+
const pathToSet = currentPath === '' ? 'project_details' : currentPath;
113+
114+
dispatch(setCurrentActiveRoute(pathToSet));
115+
}
117116
routeChangeHandler();
118117
}, []);
119118

client/src/api/Dataservice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ async function getInstalledPackages(dir: string): Promise<InstalledPackageProps[
2222
return packages;
2323
}
2424

25-
async function searchPackages(q: string) {
25+
async function searchPackages(q: string, dir: string) {
2626
const urlPath = 'packages/search';
2727

28-
const result = await fetch(`${API_BASE_URL}/${urlPath}?q=${q}`);
28+
const result = await fetch(`${API_BASE_URL}/${urlPath}?q=${q}&dir=${dir}`);
2929

3030
const { packages } = await result.json();
3131

client/src/components/NewProjectTour.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import React, { useState, useEffect } from 'react';
22

33
import { useSelector, useDispatch } from 'react-redux';
44

5-
import Question from '../components/Question';
5+
import { FormInstance, Steps } from 'antd';
66

77
import { newProjectQuestions } from '../helpers/constants';
88

9-
import { FormInstance, Steps } from 'antd';
10-
119
import { NewProjectQuestion, QuestionObject } from '../helpers/types';
1210

11+
/** Components imports */
12+
import Question from './Question';
13+
1314
import ProjectDetailsForm from './ProjectDetailsForm';
1415

1516
import ProjectNotFoundOrInvalid from './ProjectNotFoundOrInvalid';
@@ -36,7 +37,7 @@ const NewProjectTour: React.FC<{ setFormInstances: (formInstances: FormInstance[
3637

3738
const [questionsToBeRendered, setQuestionsToBeRendered] = useState<NewProjectQuestion[]>(['type_of_app']);
3839

39-
const modifyProjectDetails = (value: string, _options: any, questionName: string) => {
40+
const modifyProjectDetails = (value: string | boolean, questionName: NewProjectQuestion) => {
4041
const questionIndex = questionsToBeRendered.findIndex(qName => qName === questionName);
4142

4243
if (questionIndex === 0 || (questionIndex === 1 && newProjectDetails['type_of_app'] === 'web_app')) {
@@ -52,11 +53,13 @@ const NewProjectTour: React.FC<{ setFormInstances: (formInstances: FormInstance[
5253
};
5354

5455
const getQuestionsToAdd = (currentQuestionName: NewProjectQuestion, selectedOptionValue: string) => {
55-
const findQuestion = (question: QuestionObject): string[] | undefined => {
56+
const findQuestion = (question: QuestionObject): NewProjectQuestion[] | undefined => {
5657
if (question.question_name === currentQuestionName) {
5758
const selectedOption = question.options.find((option) => option.value === selectedOptionValue);
5859
if (selectedOption && selectedOption.questions && selectedOption.questions.length > 0) {
59-
return selectedOption.questions.map(({ question_name }) => question_name);
60+
const result = selectedOption.questions.map(({ question_name }) => question_name);
61+
62+
return result;
6063
}
6164
} else {
6265
for (const option of question.options) {
@@ -132,8 +135,8 @@ const NewProjectTour: React.FC<{ setFormInstances: (formInstances: FormInstance[
132135
useEffect(() => {
133136
const poppedQuestion = questionsToBeRendered[questionsToBeRendered.length - 1];
134137

135-
if (newProjectDetails[poppedQuestion]) {
136-
const questionsToAdd = getQuestionsToAdd(poppedQuestion, newProjectDetails[poppedQuestion]);
138+
if (typeof newProjectDetails[poppedQuestion] === 'string') {
139+
const questionsToAdd = getQuestionsToAdd(poppedQuestion, newProjectDetails[poppedQuestion] as string);
137140

138141
if (questionsToAdd !== undefined) {
139142
setQuestionsToBeRendered(

client/src/components/PackageExplorer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, forwardRef, useImperativeHandle } from 'react';
22

3-
import { Space, Input, notification } from 'antd'
3+
import { Space, Input } from 'antd'
44

55
import './PackageExplorer.scss';
66

@@ -43,8 +43,8 @@ const PackageExplorer: React.FC<PackageExplorerProps> = forwardRef((props: Packa
4343

4444
const listOfNewPackagesToInstall = useSelector((state: RootState) => state.package.listOfNewPackagesToInstall);
4545

46-
async function callAndSetSearchResults(q: string) {
47-
const result = await Dataservice.searchPackages(q);
46+
async function callAndSetSearchResults(q: string, dir: string) {
47+
const result = await Dataservice.searchPackages(q, dir);
4848

4949
setEmptySearchResult(result.length === 0);
5050

@@ -56,7 +56,7 @@ const PackageExplorer: React.FC<PackageExplorerProps> = forwardRef((props: Packa
5656
setSearchClicked(true);
5757
setSearchResultsLoading(true);
5858

59-
await callAndSetSearchResults(value);
59+
await callAndSetSearchResults(value, currentProjectDirectoryPath);
6060

6161
setSearchResultsLoading(false);
6262
};

client/src/components/ProjectDetailsForm.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import './ProjectDetailsForm.scss'
66

77
import { FormFieldProps } from '../helpers/types';
88

9-
import { Form, Collapse, Input, Select, Switch, Tooltip, Checkbox, GetProp, FormInstance } from 'antd';
9+
import { Form, Collapse, Input, Select, Switch, Tooltip, Checkbox, FormInstance } from 'antd';
1010

1111
import { InfoCircleOutlined } from '@ant-design/icons';
1212

@@ -15,6 +15,7 @@ import { formFields } from '../helpers/constants';
1515
import { AppDispatch, RootState } from '../store/store';
1616

1717
import { setNewProjectDetails, setProjectDetails } from '../store/slices/project';
18+
import { CheckboxChangeEvent } from 'antd/es/checkbox';
1819

1920
const { TextArea } = Input;
2021

@@ -29,16 +30,8 @@ const ProjectDetailsForm = (props: { setFormInstances: (formInstances: FormInsta
2930

3031
const [collapseAll, setCollapseAll] = useState(false);
3132

32-
function setFieldChangeInStorage(formField: FormFieldProps, val: any) {
33-
let valueToSet = ['switch'].includes(formField.type) ? val : val.target.value;
34-
35-
if (formField.type === 'select') {
36-
const allSelectedItems = Array.from(val.currentTarget.querySelectorAll('.ant-select-selection-item')).map(item => item.textContent);
37-
38-
valueToSet = formField.tags === true ? allSelectedItems : allSelectedItems[0]
39-
;
40-
}
41-
33+
34+
function setFieldChangeInStorage(formField: FormFieldProps, valueToSet: string | boolean | string[]) {
4235
const handler = isNewProject ? setNewProjectDetails : setProjectDetails;
4336

4437
return dispatch(handler({
@@ -50,12 +43,22 @@ const ProjectDetailsForm = (props: { setFormInstances: (formInstances: FormInsta
5043
const renderFormField = (formField: FormFieldProps) => {
5144
switch (formField.type) {
5245
case 'input':
53-
return <Input onBlur={(val) => setFieldChangeInStorage(formField, val)} addonBefore={formField.addon_before || ''} maxLength={formField.max_length} placeholder={formField.placeholder} />;
46+
return <Input onBlur={(val) => setFieldChangeInStorage(formField, val.target.value)} addonBefore={formField.addon_before || ''} maxLength={formField.max_length} placeholder={formField.placeholder} />;
5447
case 'textarea':
55-
return <TextArea onBlur={(val) => setFieldChangeInStorage(formField, val)} placeholder={formField.placeholder} rows={4} />;
48+
return <TextArea onBlur={(val) => setFieldChangeInStorage(formField, val.target.value)} placeholder={formField.placeholder} rows={4} />;
5649
case 'select':
5750
return <Select placeholder={formField.placeholder}
58-
onBlur={(val) => setFieldChangeInStorage(formField, val)}
51+
onBlur={
52+
(val) => {
53+
const allSelectedItems = Array.from(
54+
val.currentTarget.querySelectorAll('.ant-select-selection-item')
55+
).map(item => item.textContent || '');
56+
57+
const valueToSet = formField.tags === true ? allSelectedItems : allSelectedItems[0];
58+
59+
setFieldChangeInStorage(formField, valueToSet)
60+
}
61+
}
5962
mode={formField.tags ? 'tags' : (formField.multiple ? 'multiple' : undefined)}
6063
options={formField.options}
6164
/>;
@@ -137,7 +140,7 @@ const ProjectDetailsForm = (props: { setFormInstances: (formInstances: FormInsta
137140
}
138141
];
139142

140-
const onCollapseCheckChange: GetProp<typeof Checkbox.Group, 'onChange'> = (checkedValues) => {
143+
const onCollapseCheckChange = (checkedValues: CheckboxChangeEvent) => {
141144
setCollapseAll(checkedValues.target.checked);
142145
};
143146

client/src/components/Question.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ const Question: React.FC<QuestionProps> = ({ questionObj, answer, answerHandler
1616
style={{ width: 150 }}
1717
value={answer}
1818
options={questionObj.options}
19-
onSelect={(...args) => answerHandler(...args, questionObj.question_name)}
19+
onSelect={(selectedValue) => answerHandler(selectedValue, questionObj.question_name)}
2020
/>
2121
case 'switch':
2222
return <Switch
2323
checkedChildren={questionObj.options[1].label} unCheckedChildren={questionObj.options[0].label}
24-
onChange={(checked) => answerHandler(questionObj.options[checked ? 1 : 0].value, undefined, questionObj.question_name)}
24+
onChange={(checked) => answerHandler(questionObj.options[checked ? 1 : 0].value, questionObj.question_name)}
2525
checked={answer === questionObj.options[1].value} />
2626
default:
2727
return '';

0 commit comments

Comments
 (0)