Skip to content

Commit

Permalink
Merge pull request #449 from IgniteUI/dTsvetkov/add-correct-dv-sample…
Browse files Browse the repository at this point in the history
…s-path

Add correct dv samples path
  • Loading branch information
zdrawku authored Dec 5, 2023
2 parents c204db1 + 6e894e1 commit d18e22b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app/services/code-view/angular-code-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,23 @@ export class AngularCodeService extends CodeService {
this.xhrService.pushTask(sharedFileFetch);
}

private getAngularGitHubSampleUrl(editor: string, sampleUrl: string, branch: string) {
private getAngularGitHubSampleUrl(editor: string, sampleUrl: string, branch: string, demosBaseUrl: string) {
const dvSample = this.isDvSample(demosBaseUrl, sampleUrl);
if (util.isLocalhost) {
branch = 'vNext';
branch = dvSample ? 'vnext' : 'vNext';
}
if (editor === "stackblitz") return `https://stackblitz.com/github/IgniteUI/igniteui-live-editing-samples/tree/${branch}/${sampleUrl}`;
return `https://codesandbox.io/s/github/IgniteUI/igniteui-live-editing-samples/tree/${branch}/${sampleUrl}`
const repositoryPath = dvSample ? 'igniteui-angular-examples/tree/' : 'igniteui-live-editing-samples/tree/';
if (editor === "stackblitz") return `https://stackblitz.com/github/IgniteUI/${repositoryPath}${branch}/${sampleUrl}`;
return `https://codesandbox.io/s/github/IgniteUI/${repositoryPath}${branch}/${sampleUrl}`;
}

private getGitHubSampleUrl(demosBaseUrl: string, sampleUrl: string) {
// Get sample application base path
const projectPath = demosBaseUrl.substring(demosBaseUrl.lastIndexOf("/") + 1)
let demoPath = sampleUrl.replace(demosBaseUrl + "/", projectPath + "/");

if (util.isLocalhost) {
demoPath = demoPath.replace(projectPath, 'angular-demos');
demoPath = this.isDvSample(demosBaseUrl, sampleUrl) ? demoPath.replace(projectPath, 'samples') : demoPath.replace(projectPath, 'angular-demos');
}
return demoPath;
}
Expand All @@ -150,7 +153,7 @@ export class AngularCodeService extends CodeService {
let sampleFileUrl = codeService.getGitHubSampleUrl(demosBaseUrl, $codeView.attr(codeService.sampleUrlAttrName)!);
let editor = $button.hasClass(codeService.stkbButtonClass) ? "stackblitz" : "codesandbox";
let branch = demosBaseUrl.indexOf("staging.infragistics.com") !== -1 ? "vNext" : "master";
window.open(codeService.getAngularGitHubSampleUrl(editor, sampleFileUrl, branch), '_blank');
window.open(codeService.getAngularGitHubSampleUrl(editor, sampleFileUrl, branch, demosBaseUrl), '_blank');
codeService.isButtonClickInProgress = false;
}

Expand Down Expand Up @@ -181,7 +184,7 @@ export class AngularCodeService extends CodeService {
let sampleFileUrl = codeService.getGitHubSampleUrl(demosBaseUrl, $button.attr(codeService.buttonSampleSourceAttrName)!);
let editor = $button.hasClass(codeService.stkbButtonClass) ? "stackblitz" : "codesandbox";
let branch = demosBaseUrl.indexOf("staging.infragistics.com") !== -1 ? "vNext" : "master";
window.open(codeService.getAngularGitHubSampleUrl(editor, sampleFileUrl, branch), '_blank');
window.open(codeService.getAngularGitHubSampleUrl(editor, sampleFileUrl, branch, demosBaseUrl), '_blank');
codeService.isButtonClickInProgress = false;
}
}
Expand Down

0 comments on commit d18e22b

Please sign in to comment.