From ad781850bf82087e0ab23272fa3ceddfc6110e0a Mon Sep 17 00:00:00 2001 From: Andrii Mysko Date: Tue, 15 Aug 2023 16:07:53 +0300 Subject: [PATCH] [PRD] TCI/Assembla Handshake with SVN/P4 (#2778) --- app/adapters/repo.js | 9 ++++++-- app/controllers/repo.js | 3 ++- app/models/repo.js | 9 +++++--- app/router.js | 2 ++ app/routes/legacy-repo-url.js | 23 +++++++++++++++---- app/routes/repo.js | 4 ++-- app/templates/account/settings.hbs | 5 +++- app/templates/components/dashboard-row.hbs | 1 + .../components/email-unsubscribe.hbs | 2 ++ .../components/github-apps-repository.hbs | 2 +- app/templates/components/my-build.hbs | 1 + app/templates/components/owner-repo-tile.hbs | 1 + app/templates/components/plan_usage.hbs | 5 +++- app/templates/components/repos-list-item.hbs | 2 +- .../components/repository-layout.hbs | 5 +++- .../components/repository-status-toggle.hbs | 1 + 16 files changed, 57 insertions(+), 18 deletions(-) diff --git a/app/adapters/repo.js b/app/adapters/repo.js index 3485918a88..61059c0902 100644 --- a/app/adapters/repo.js +++ b/app/adapters/repo.js @@ -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') { diff --git a/app/controllers/repo.js b/app/controllers/repo.js index 16f85a16fd..ebc33cb8b4 100644 --- a/app/controllers/repo.js +++ b/app/controllers/repo.js @@ -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'), diff --git a/app/models/repo.js b/app/models/repo.js index 4233f9e01d..41bb6d98f2 100644 --- a/app/models/repo.js +++ b/app/models/repo.js @@ -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 }); }, }); diff --git a/app/router.js b/app/router.js index eed7e29f99..23a17a84f1 100644 --- a/app/router.js +++ b/app/router.js @@ -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' }); diff --git a/app/routes/legacy-repo-url.js b/app/routes/legacy-repo-url.js index 05f2897741..98e7ff6fa7 100644 --- a/app/routes/legacy-repo-url.js +++ b/app/routes/legacy-repo-url.js @@ -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) { @@ -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 }); } } }); diff --git a/app/routes/repo.js b/app/routes/repo.js index bbcc7443be..66166441ff 100644 --- a/app/routes/repo.js +++ b/app/routes/repo.js @@ -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() { diff --git a/app/templates/account/settings.hbs b/app/templates/account/settings.hbs index 4ff73a8e91..b878b28980 100644 --- a/app/templates/account/settings.hbs +++ b/app/templates/account/settings.hbs @@ -105,7 +105,10 @@ {{#each this.unsubscribedRepos as |repo|}}
- + {{repo.formattedSlug}}
diff --git a/app/templates/components/dashboard-row.hbs b/app/templates/components/dashboard-row.hbs index efc11609e1..5a6337fe43 100644 --- a/app/templates/components/dashboard-row.hbs +++ b/app/templates/components/dashboard-row.hbs @@ -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}} diff --git a/app/templates/components/email-unsubscribe.hbs b/app/templates/components/email-unsubscribe.hbs index b12388b23e..4f8fc7c828 100644 --- a/app/templates/components/email-unsubscribe.hbs +++ b/app/templates/components/email-unsubscribe.hbs @@ -29,6 +29,7 @@ @@ -72,6 +73,7 @@ {{this.name}} diff --git a/app/templates/components/my-build.hbs b/app/templates/components/my-build.hbs index b5fef0fdf9..a9771ca83f 100644 --- a/app/templates/components/my-build.hbs +++ b/app/templates/components/my-build.hbs @@ -24,6 +24,7 @@ {{this.build.repo.name}} diff --git a/app/templates/components/owner-repo-tile.hbs b/app/templates/components/owner-repo-tile.hbs index 429dc4110b..fff5ef2bba 100644 --- a/app/templates/components/owner-repo-tile.hbs +++ b/app/templates/components/owner-repo-tile.hbs @@ -17,6 +17,7 @@ diff --git a/app/templates/components/plan_usage.hbs b/app/templates/components/plan_usage.hbs index dc475cc668..07423ecbf9 100644 --- a/app/templates/components/plan_usage.hbs +++ b/app/templates/components/plan_usage.hbs @@ -108,7 +108,10 @@ {{#each this.summarizedRepositories as |repository|}} - + {{repository.formattedSlug}} diff --git a/app/templates/components/repos-list-item.hbs b/app/templates/components/repos-list-item.hbs index 91f9e42696..27feab45a1 100644 --- a/app/templates/components/repos-list-item.hbs +++ b/app/templates/components/repos-list-item.hbs @@ -1,7 +1,7 @@

{{#if this.repo.slug}} - + {{this.repo.slug}} diff --git a/app/templates/components/repository-layout.hbs b/app/templates/components/repository-layout.hbs index 0268369de1..4c7be473fe 100644 --- a/app/templates/components/repository-layout.hbs +++ b/app/templates/components/repository-layout.hbs @@ -9,7 +9,10 @@ {{this.repo.owner.login}} / - + {{this.repo.name}}

diff --git a/app/templates/components/repository-status-toggle.hbs b/app/templates/components/repository-status-toggle.hbs index f87e440067..23f38875eb 100644 --- a/app/templates/components/repository-status-toggle.hbs +++ b/app/templates/components/repository-status-toggle.hbs @@ -2,6 +2,7 @@