Skip to content

Commit

Permalink
[PRD] TCI/Assembla Handshake with SVN/P4 (#2778)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiMysko authored and vitalie committed Aug 15, 2023
1 parent 4532177 commit ad78185
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 18 deletions.
9 changes: 7 additions & 2 deletions app/adapters/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ export default V3Adapter.extend({
const prefix = this.urlPrefix();

if (query) {
const { provider, slug, custom } = query;
const { provider, slug, serverType, custom } = query;
const providerPrefix = provider ? `${provider}/` : '';

delete query.provider;
delete query.slug;
delete query.custom;
delete query.serverType;

// fetch repo by slug
if (!id && slug) {
return `${prefix}/repo/${providerPrefix}${encodeURIComponent(slug)}`;
let url = `${prefix}/repo/${providerPrefix}${encodeURIComponent(slug)}`;
if (serverType) {
url = `${url}?server_type=${serverType}`;
}
return url;
}

if (custom && custom.type === 'byOwner') {
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default Controller.extend({
features: service(),
updateTimesService: service('updateTimes'),

queryParams: ['migrationStatus'],
queryParams: ['migrationStatus', 'serverType'],
serverType: null,
migrationStatus: null,

jobController: controller('job'),
Expand Down
9 changes: 6 additions & 3 deletions app/models/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,15 @@ Repo.reopenClass({
});
},

fetchBySlug(store, slug, provider = defaultVcsConfig.urlPrefix) {
const loadedRepos = store.peekAll('repo').filterBy('provider', provider).filterBy('slug', slug);
fetchBySlug(store, slug, provider = defaultVcsConfig.urlPrefix, serverType = undefined) {
let loadedRepos = store.peekAll('repo').filterBy('provider', provider).filterBy('slug', slug);
if (serverType) {
loadedRepos = loadedRepos.filterBy('serverType', serverType);
}
if (!isEmpty(loadedRepos)) {
return EmberPromise.resolve(loadedRepos.firstObject);
}
return store.queryRecord('repo', { slug, provider });
return store.queryRecord('repo', { slug, provider, serverType });
},
});

Expand Down
2 changes: 2 additions & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Router.map(function () {
this.route('legacy-repo-url', { path: '/:owner/:repo/:method' });
this.route('legacy-repo-url', { path: '/:owner/:repo/:method/:id' });
this.route('legacy-repo-url', { path: '/:owner/:repo/:method/:id/:view' });
this.route('legacy-repo-url', { path: '/:provider/:owner/:repo/:serverType/:method/:id' });
this.route('legacy-repo-url', { path: '/:provider/:owner/:repo/:serverType/:method/:id/:view' });

this.route('error404', { path: '/404' });
this.route('page-not-found', { path: '/*wildcard' });
Expand Down
23 changes: 18 additions & 5 deletions app/routes/legacy-repo-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,32 @@ export default Route.extend({

beforeModel(transition) {
const { params, queryParams } = transition.to;
let { owner, repo, method, id, view } = params;
let provider, routeName = 'provider', routeModels = [];
let { owner, repo, method, id, view, provider, serverType } = params;
let vcsConfig, routeName = 'provider', routeModels = [];

const vcsConfig = vcsConfigByUrlPrefix(owner);
if (provider) {
vcsConfig = vcsConfigByUrlPrefix(provider);
} else {
vcsConfig = vcsConfigByUrlPrefix(owner);
}

const isLegacyUrl = isEmpty(vcsConfig);
const serverTypes = ['git', 'svn', 'perforce'];
const isServerTypeUrl = serverTypes.includes(serverType) || serverTypes.includes(id);

if (isLegacyUrl) {
provider = defaultVcsConfig.urlPrefix;
} else {
// params include provider, so swap them accordingly
[provider, owner, repo, method, id] = [owner, repo, method, id, view];
if (!isServerTypeUrl) {
[provider, owner, repo, method, id] = [owner, repo, method, id, view];
} else if (serverTypes.includes(id)) {
[provider, owner, repo, serverType, method, id, view] = [owner, repo, method, id, view];
}
}

const newQueryParams = { serverType: serverType, ...queryParams };

routeModels.push(provider);

if (owner) {
Expand All @@ -43,7 +56,7 @@ export default Route.extend({

if (this._router.hasRoute(routeName)) {
transition.abort();
this.transitionTo(routeName, ...routeModels, { queryParams });
this.transitionTo(routeName, ...routeModels, { queryParams: newQueryParams });
}
}
});
4 changes: 2 additions & 2 deletions app/routes/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export default TravisRoute.extend(ScrollResetMixin, {
return { provider, owner, name };
},

model({ provider, owner, name }) {
model({ provider, owner, name, serverType }) {
const slug = `${owner}/${name}`;
this.set('slug', slug);
return Repo.fetchBySlug(this.store, slug, provider);
return Repo.fetchBySlug(this.store, slug, provider, serverType);
},

beforeModel() {
Expand Down
5 changes: 4 additions & 1 deletion app/templates/account/settings.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@
{{#each this.unsubscribedRepos as |repo|}}
<div class="row" data-test-email-settings-resubscribe-item>
<div class="name">
<LinkTo @route="repo" @models={{array repo.provider repo.urlOwnerName repo.urlName}}>
<LinkTo
@route="repo" @models={{array repo.provider repo.urlOwnerName repo.urlName}}
@query={{hash serverType=repo.serverType}}
>
{{repo.formattedSlug}}
</LinkTo>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/templates/components/dashboard-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@route="repo"
@models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}}
@title={{this.repo.name}}
@query={{hash serverType=this.repo.serverType}}
>
{{this.repo.name}}
{{#if this.repo.shared}}
Expand Down
2 changes: 2 additions & 0 deletions app/templates/components/email-unsubscribe.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<LinkTo
@route="repo"
@models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}}
@query={{hash serverType=this.repo.serverType}}
@target="_blank"
class="repo-link repo-slug"
>
Expand Down Expand Up @@ -72,6 +73,7 @@
<LinkTo
@route="repo"
@models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}}
@query={{hash serverType=this.repo.serverType}}
@tagName="button"
@disabled={{this.task.isRunning}}
class="no-button control"
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/github-apps-repository.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LinkTo
@route="repo"
@models={{array this.repository.provider this.repository.urlOwnerName this.repository.urlName}}
@query={{this.hash}}
@query={{hash serverType=this.repository.serverType}}
class="profile-repo"
>
<span class="profile-repo-name">{{this.name}}</span>
Expand Down
1 change: 1 addition & 0 deletions app/templates/components/my-build.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<LinkTo
@route="repo"
@models={{array this.build.repo.provider this.build.repo.urlOwnerName this.build.repo.urlName}}
@query={{hash serverType=this.build.repo.serverType}}
class="inner-underline"
>
{{this.build.repo.name}}
Expand Down
1 change: 1 addition & 0 deletions app/templates/components/owner-repo-tile.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<LinkTo
@route="repo"
@models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}}
@query={{hash serverType=this.repo.serverType}}
class="label-align"
>
<span class="repo-title-text">
Expand Down
5 changes: 4 additions & 1 deletion app/templates/components/plan_usage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@
{{#each this.summarizedRepositories as |repository|}}
<tr data-test-repository='true'>
<td>
<LinkTo @route="repo" @models={{array repository.provider repository.urlOwnerName repository.urlName}}>
<LinkTo
@route="repo" @models={{array repository.provider repository.urlOwnerName repository.urlName}}
@query={{hash serverType=this.repo.serverType}}
>
{{repository.formattedSlug}}
</LinkTo>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/repos-list-item.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="tile {{this.repo.currentBuild.state}}">
<h2 class="tile-title {{this.repo.currentBuild.state}}">
{{#if this.repo.slug}}
<LinkTo @route="repo" @models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}}>
<LinkTo @route="repo" @models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}} @query={{hash serverType=this.repo.serverType}}>
<StatusIcon @status={{this.repo.currentBuild.state}} />
<span data-test-repos-list-item-slug class="label-align inner-underline">
{{this.repo.slug}}
Expand Down
5 changes: 4 additions & 1 deletion app/templates/components/repository-layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
{{this.repo.owner.login}}
</LinkTo>
/
<LinkTo @route="repo" @models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}} >
<LinkTo
@route="repo" @models={{array this.repo.provider this.repo.urlOwnerName this.repo.urlName}}
@query={{hash serverType=this.repo.serverType}}
>
{{this.repo.name}}
</LinkTo>
</h1>
Expand Down
1 change: 1 addition & 0 deletions app/templates/components/repository-status-toggle.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<LinkTo
@route="repo"
@models={{array this.repository.provider this.repository.urlOwnerName this.repository.urlName}}
@query={{hash serverType=this.repository.serverType}}
class="profile-repo"
@classNameBindings="admin:admin:non-admin"
>
Expand Down

0 comments on commit ad78185

Please sign in to comment.