Skip to content

Commit 5bffb97

Browse files
Merge pull request #79 from wavemaker/dev-ponnarasi/none-option
Added None option in basePath dropdown
2 parents 3411d7c + 11e840f commit 5bffb97

7 files changed

Lines changed: 35 additions & 12 deletions

File tree

dist/config-import-bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/config-import-bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rest-import-bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rest-import-bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wavemaker/rest-client-ui",
3-
"version": "0.0.23",
3+
"version": "0.0.24",
44
"private": false,
55
"main": "./dist/core/components/RestImport.js",
66
"release": {

src/core/components/RestImport.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ declare global {
157157
}
158158
}
159159

160+
interface BasePathOption {
161+
label: string;
162+
value: string;
163+
}
164+
165+
160166
export default function RestImport({ language, restImportConfig }: { language: string, restImportConfig: restImportConfigI }) {
161167
const theme = createTheme({
162168
typography: {
@@ -302,7 +308,7 @@ export default function RestImport({ language, restImportConfig }: { language: s
302308
var multiParamInfoList: any[] = []
303309
var oAuthRetry = true
304310
const [basePath, setBasePath] = useState<string>(restImportConfig?.urlBasePath)
305-
const [basePathList, setBasePathList] = useState<string[]>([]);
311+
const [basePathList, setBasePathList] = useState<BasePathOption[]>([]);
306312
const [basePathEnabled, setBasePathEnabled] = useState(!restImportConfig?.viewMode)
307313
const [settingsDetailsResponse, setSettingsDetailsResponse] = useState(restImportConfig?.settingsDetailsResponse || {})
308314

@@ -344,10 +350,23 @@ export default function RestImport({ language, restImportConfig }: { language: s
344350
return decodePart.includes("{") || decodePart.includes("}")
345351
});
346352
const filteredParts = firstValidIndex === -1 ? parts : parts.slice(0, firstValidIndex);
347-
348-
const basePathDetails = filteredParts.map((_, index) => decodeURIComponent("/" + filteredParts.slice(0, index + 1).join("/")));
353+
354+
const basePathDetails: BasePathOption[] = [
355+
{ label: "None", value: "/" }
356+
];
357+
358+
for (let i = 0; i < filteredParts.length; i++) {
359+
const segment = filteredParts.slice(0, i + 1).join("/");
360+
const decodedSegment = decodeURIComponent(segment);
361+
basePathDetails.push({
362+
label: `/${decodedSegment}`,
363+
value: `/${decodedSegment}`
364+
});
365+
}
366+
367+
349368
if(basePathDetails.length > 0){
350-
setBasePath(restImportConfig?.urlBasePath ? restImportConfig?.urlBasePath : basePathDetails[0]);
369+
setBasePath(restImportConfig?.urlBasePath ? restImportConfig?.urlBasePath : basePathDetails[1].value);
351370
}
352371
setBasePathList(basePathDetails)
353372
} catch (error) {
@@ -1307,7 +1326,11 @@ export default function RestImport({ language, restImportConfig }: { language: s
13071326
disabled={ basePathEnabled}
13081327
onChange={handleChangeBasePath}
13091328
>
1310-
{basePathList.map((basePath) => <MenuItem key={basePath} title={basePath} value={basePath}>{basePath}</MenuItem>)}
1329+
{basePathList.map((option) => (
1330+
<MenuItem key={option.label} title={option.label} value={option.value}>
1331+
{option.label}
1332+
</MenuItem>
1333+
))}
13111334
</Select>
13121335
</FormControl>
13131336
</Stack>

0 commit comments

Comments
 (0)