Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/config-import-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/config-import-bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rest-import-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rest-import-bundle.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wavemaker/rest-client-ui",
"version": "0.0.23",
"version": "0.0.24",
"private": false,
"main": "./dist/core/components/RestImport.js",
"release": {
Expand Down
33 changes: 28 additions & 5 deletions src/core/components/RestImport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ declare global {
}
}

interface BasePathOption {
label: string;
value: string;
}


export default function RestImport({ language, restImportConfig }: { language: string, restImportConfig: restImportConfigI }) {
const theme = createTheme({
typography: {
Expand Down Expand Up @@ -302,7 +308,7 @@ export default function RestImport({ language, restImportConfig }: { language: s
var multiParamInfoList: any[] = []
var oAuthRetry = true
const [basePath, setBasePath] = useState<string>(restImportConfig?.urlBasePath)
const [basePathList, setBasePathList] = useState<string[]>([]);
const [basePathList, setBasePathList] = useState<BasePathOption[]>([]);
const [basePathEnabled, setBasePathEnabled] = useState(!restImportConfig?.viewMode)
const [settingsDetailsResponse, setSettingsDetailsResponse] = useState(restImportConfig?.settingsDetailsResponse || {})

Expand Down Expand Up @@ -344,10 +350,23 @@ export default function RestImport({ language, restImportConfig }: { language: s
return decodePart.includes("{") || decodePart.includes("}")
});
const filteredParts = firstValidIndex === -1 ? parts : parts.slice(0, firstValidIndex);

const basePathDetails = filteredParts.map((_, index) => decodeURIComponent("/" + filteredParts.slice(0, index + 1).join("/")));

const basePathDetails: BasePathOption[] = [
{ label: "None", value: "/" }
];

for (let i = 0; i < filteredParts.length; i++) {
const segment = filteredParts.slice(0, i + 1).join("/");
const decodedSegment = decodeURIComponent(segment);
basePathDetails.push({
label: `/${decodedSegment}`,
value: `/${decodedSegment}`
});
}


if(basePathDetails.length > 0){
setBasePath(restImportConfig?.urlBasePath ? restImportConfig?.urlBasePath : basePathDetails[0]);
setBasePath(restImportConfig?.urlBasePath ? restImportConfig?.urlBasePath : basePathDetails[1].value);
}
setBasePathList(basePathDetails)
} catch (error) {
Expand Down Expand Up @@ -1307,7 +1326,11 @@ export default function RestImport({ language, restImportConfig }: { language: s
disabled={ basePathEnabled}
onChange={handleChangeBasePath}
>
{basePathList.map((basePath) => <MenuItem key={basePath} title={basePath} value={basePath}>{basePath}</MenuItem>)}
{basePathList.map((option) => (
<MenuItem key={option.label} title={option.label} value={option.value}>
{option.label}
</MenuItem>
))}
</Select>
</FormControl>
</Stack>
Expand Down