Skip to content

Commit

Permalink
Handle importing git repos that already have a Devfile
Browse files Browse the repository at this point in the history
Fixes #3104

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 committed Aug 28, 2023
1 parent 7c53b4e commit 0fdcb8b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
16 changes: 11 additions & 5 deletions src/webview/create-component/createComponentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ export default class CreateComponentLoader {
action: 'cloneFailed',
});
} else {
void CreateComponentLoader.panel.webview.postMessage({
action: 'devfileExists',
data: await isDevfileExists(tmpFolder),
});
CreateComponentLoader.getRecommendedDevfile(tmpFolder);
}
break;
Expand Down Expand Up @@ -283,11 +287,13 @@ export default class CreateComponentLoader {
await fse.copy(tmpFolder.fsPath, componentFolder);
}
const devfileType = getDevfileType(message.data.devfileDisplayName);
await OdoImpl.Instance.createComponentFromLocation(
devfileType,
componentName,
Uri.file(componentFolder),
);
if (!await isDevfileExists(Uri.file(componentFolder))) {
await OdoImpl.Instance.createComponentFromLocation(
devfileType,
componentName,
Uri.file(componentFolder),
);
}
await sendTelemetry('newComponentCreated', {
strategy,
component_type: devfileType,
Expand Down
45 changes: 26 additions & 19 deletions src/webview/create-component/pages/fromExistingGitRepo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
AccordionDetails,
AccordionSummary,
Alert,
Box,
Button,
CircularProgress,
Divider,
Expand Down Expand Up @@ -331,17 +332,21 @@ export function FromExistingGitRepo({ setCurrentView }) {
? 'Selected Devfile'
: 'Recommended Devfile'}
</Typography>
<DevfileRecommendationInfo />
{recommendedDevfile.isDevfileExistsInRepo ? (
<Alert severity="info">
The Devfile that exists in the repo will be used
</Alert>
) : (
<DevfileRecommendationInfo />
)}
</Stack>
{!recommendedDevfile.noRecommendation && (
<DevfileListItem
devfile={
selectedDevfile
? selectedDevfile
: recommendedDevfile.devfile
}
/>
)}
<DevfileListItem
devfile={
selectedDevfile
? selectedDevfile
: recommendedDevfile.devfile
}
/>
<Stack
direction="row"
justifyContent="flex-end"
Expand Down Expand Up @@ -369,15 +374,17 @@ export function FromExistingGitRepo({ setCurrentView }) {
>
BACK
</Button>
<Button
variant="contained"
onClick={() => {
setSelectedDevfile(undefined);
setCurrentPage('selectDifferentDevfile');
}}
>
SELECT A DIFFERENT DEVFILE
</Button>
{!recommendedDevfile.isDevfileExistsInRepo && (
<Button
variant="contained"
onClick={() => {
setSelectedDevfile(undefined);
setCurrentPage('selectDifferentDevfile');
}}
>
SELECT A DIFFERENT DEVFILE
</Button>
)}
<Button
variant="contained"
onClick={() => {
Expand Down

0 comments on commit 0fdcb8b

Please sign in to comment.