Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions src/webview/create-component/createComponentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ export default class CreateComponentLoader {
*/
case 'getRecommendedDevfileFromGit': {
tmpFolder = Uri.parse(await promisify(tmp.dir)());
void CreateComponentLoader.panel.webview.postMessage({
action: 'cloneStart',
});
const cloneProcess: CloneProcess = await clone(
message.data.url,
tmpFolder.fsPath,
Expand Down Expand Up @@ -425,6 +428,9 @@ export default class CreateComponentLoader {
let analyzeRes: AnalyzeResponse[] = [];
let compDescriptions: ComponentTypeDescription[] = [];
try {
void CreateComponentLoader.panel.webview.postMessage({
action: 'getRecommendedDevfileStart'
});
analyzeRes = await OdoImpl.Instance.analyze(uri.fsPath);
compDescriptions = getCompDescription(analyzeRes);
} catch (error) {
Expand Down Expand Up @@ -464,6 +470,9 @@ export default class CreateComponentLoader {
}
}
} finally {
void CreateComponentLoader.panel.webview.postMessage({
action: 'getRecommendedDevfile'
});
const devfileRegistry: DevfileRegistry[] = getDevfileRegistries();
const allDevfiles: Devfile[] = devfileRegistry.flatMap((registry) => registry.devfiles);
const devfile: Devfile =
Expand Down Expand Up @@ -530,6 +539,9 @@ function clone(url: string, location: string, branch?: string): Promise<ClonePro
const git = gitExtension.getAPI(1).git.path;
let command = `${git} clone ${url} ${location}`;
command = branch ? `${command} --branch ${branch}` : command;
Comment thread
datho7561 marked this conversation as resolved.
void CreateComponentLoader.panel.webview.postMessage({
action: 'cloneExecution'
});
// run 'git clone url location' as external process and return location
return new Promise((resolve, reject) =>
cp.exec(command, (error: cp.ExecException) => {
Expand Down
46 changes: 43 additions & 3 deletions src/webview/create-component/pages/fromExistingGitRepo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type RecommendedDevfileState = {
devfile: Devfile;
showRecommendation: boolean;
isLoading: boolean;
completionValue: number;
isDevfileExistsInRepo: boolean;
noRecommendation: boolean;
};
Expand All @@ -58,6 +59,7 @@ export function FromExistingGitRepo({ setCurrentView }) {
devfile: undefined,
showRecommendation: false,
isLoading: false,
completionValue: 0,
isDevfileExistsInRepo: false,
noRecommendation: false,
});
Expand All @@ -77,6 +79,10 @@ export function FromExistingGitRepo({ setCurrentView }) {
showRecommendation: true,
}));
} else {
setRecommendedDevfile((prevState) => ({
...prevState,
completionValue: 100,
}));
setRecommendedDevfile((prevState) => ({
...prevState,
devfile: message.data.devfile,
Expand All @@ -97,14 +103,28 @@ export function FromExistingGitRepo({ setCurrentView }) {
case 'devfileExists': {
setRecommendedDevfile((prevState) => ({
...prevState,
isDevfileExistsInRepo: message.data,
completionValue: prevState.completionValue + 10
}));
setRecommendedDevfile((prevState) => ({
...prevState,
isDevfileExistsInRepo: message.data
}));
break;
}
case 'cloneFailed': {
setCloneFailed(true);
break;
}
case 'cloneStart':
case 'cloneExecution':
case 'getRecommendedDevfileStart': {
setRecommendedDevfile((prevState) => ({ ...prevState, completionValue: prevState.completionValue + 10}));
break;
}
case 'getRecommendedDevfile': {
setRecommendedDevfile((prevState) => ({ ...prevState, completionValue: prevState.completionValue + 45}));
break;
}
default:
break;
}
Expand All @@ -125,7 +145,7 @@ export function FromExistingGitRepo({ setCurrentView }) {
branch: branchOption,
},
});
setRecommendedDevfile((prevState) => ({ ...prevState, isLoading: true }));
setRecommendedDevfile((prevState) => ({ ...prevState, isLoading: true, completionValue: 5 }));
}

function createComponentFromGitRepo(
Expand Down Expand Up @@ -229,7 +249,27 @@ export function FromExistingGitRepo({ setCurrentView }) {
spacing={2}
alignItems="center"
>
<CircularProgress />
<Box sx={{ position: 'relative', display: 'inline-flex' }}>
<CircularProgress />
Comment thread
datho7561 marked this conversation as resolved.
Outdated
Comment thread
msivasubramaniaan marked this conversation as resolved.
Outdated
<Box
sx={{
top: 0,
left: 0,
bottom: 0,
right: 0,
position: 'absolute',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Typography
variant='caption'
component='div'
color='text.secondary'
>{`${Math.round(recommendedDevfile.completionValue)}%`}</Typography>
</Box>
</Box>
<Typography variant="body2">
Cloning git repository and scanning for
recommended devfile.
Expand Down