Skip to content

Commit

Permalink
[PRD] TCI/Assembla Handshake with SVN/P4 (#2769)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiMysko authored and vitalie committed Aug 22, 2023
1 parent a61a11b commit 2555880
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 25 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
16 changes: 16 additions & 0 deletions app/components/dashboard-row.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { alias, reads } from '@ember/object/computed';
import { task, timeout } from 'ember-concurrency';
Expand All @@ -24,6 +25,21 @@ export default Component.extend({

displayMenuTofu: alias('repo.permissions.create_request'),

repositoryProvider: computed('repo.provider', function () {
return this.repo.provider.capitalize();
}),

repositoryType: computed('repo.serverType', function () {
switch (this.repo.serverType) {
case 'git':
return 'GIT';
case 'subversion':
return 'SVN';
case 'perforce':
return 'P4';
}
}),

openDropup() {
this.set('dropupIsOpen', true);
},
Expand Down
15 changes: 15 additions & 0 deletions app/components/github-apps-repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ export default Component.extend({
isMatchGithub: match('vcsType', /Github\S+$/),
isNotMatchGithub: not('isMatchGithub'),

repositoryProvider: computed('repository.provider', function () {
return this.repository.provider.capitalize();
}),

repositoryType: computed('repository.serverType', function () {
switch (this.repository.serverType) {
case 'git':
return 'GIT';
case 'subversion':
return 'SVN';
case 'perforce':
return 'P4';
}
}),

accessSettingsUrl: computed('user.vcsType', 'user.vcsId', function () {
return this.user && vcsLinks.accessSettingsUrl(this.user.vcsType, { owner: this.user.login });
}),
Expand Down
15 changes: 15 additions & 0 deletions app/components/repository-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ export default Component.extend({
currentUser: alias('auth.currentUser'),
userRoMode: reads('currentUser.roMode'),

repositoryProvider: computed('repo.provider', function () {
return this.repo.provider.capitalize();
}),

repositoryType: computed('repo.serverType', function () {
switch (this.repo.serverType) {
case 'git':
return 'GIT';
case 'subversion':
return 'SVN';
case 'perforce':
return 'P4';
}
}),

repoUrl: computed('repo.{ownerName,vcsName,vcsType}', function () {
const owner = this.get('repo.ownerName');
const repo = this.get('repo.vcsName');
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
10 changes: 7 additions & 3 deletions app/models/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const Repo = VcsEntity.extend({
migrationStatus: attr('string'),
historyMigrationStatus: attr('string'),
scanFailedAt: attr('date'),
serverType: attr('string', { defaultValue: 'git' }),

currentScan: computed('scanFailedAt', function () {
let scanFailedAt = this.get('scanFailedAt');
Expand Down Expand Up @@ -425,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
5 changes: 2 additions & 3 deletions app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ export default Owner.extend({
this.set('applyFilterRepos', !isOrganization);
return this.api
.post(`/user/${this.id}/sync`)
.then(() => this.poll(),
() => this.set('isSyncing', false));
.then(() => this.poll());
},

schedulePoll() {
Expand All @@ -91,7 +90,7 @@ export default Owner.extend({

poll() {
return this.reload().then(() => {
if (!this.isSyncing) {
if (this.isSyncing) {
this.schedulePoll();
} else {
this.permissionsService.fetchPermissions.perform();
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
2 changes: 2 additions & 0 deletions app/routes/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export default TravisRoute.extend({
fetchSshKey() {
if (config.endpoints.sshKey) {
const repo = this.modelFor('repo');
if (repo.serverType === 'perforce') return;

const url = `/repos/${repo.get('id')}/key`;
return this.api.get(url, { travisApiVersion: null }).then((data) => {
const fingerprint = EmberObject.create({
Expand Down
3 changes: 3 additions & 0 deletions app/styles/app/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,6 @@ $padding-top: 24px;
display: none !important;
}
}
.mr-1_2 {
margin-right: 1.2rem;
}
16 changes: 14 additions & 2 deletions app/styles/app/layouts/profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ $profile-breakpoint: 600px;
.profile-repo {
display: flex;
position: relative;
flex: 1;
flex: 0;
padding: 0.25em 0.5em 0.3em;
border-radius: 2px;
margin-right: 1rem;

.profile-repo-name {
height: 21px;
white-space: nowrap;
overflow: hidden;
}

Expand All @@ -239,6 +239,18 @@ $profile-breakpoint: 600px;
}
}

.profile-repo-type {
display: flex;
flex: 1;

.profile-repo-type-span {
background-color: #d8d8d8;
padding: 2px 6px;
border-radius: 25%;
font-weight: 600;
}
}

.profile-text,
.profile-additional,
.profile-betafeatures {
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
11 changes: 11 additions & 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 Expand Up @@ -70,6 +71,16 @@
{{/if}}
</p>
</section>
{{#if (eq this.repo.provider 'assembla')}}
<section class="dash-last">
<h3 class="label">
Repo type
</h3>
<p class="row-content color">
{{this.repositoryType}}
</p>
</section>
{{/if}}
{{#if this.repo.currentBuild}}
<section class="dash-last {{this.repo.currentBuild.state}}">
<h3 class="label">
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
12 changes: 10 additions & 2 deletions 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 All @@ -13,6 +13,14 @@
</span>
{{/if}}
</LinkTo>
{{#if (eq this.repository.provider 'assembla')}}
<span class="profile-repo-type">
<span class="profile-repo-type-span">
{{this.repositoryType}}
<EmberTooltip @text="{{this.repositoryProvider}} {{this.repositoryType}} Repository" />
</span>
</span>
{{/if}}
{{#if this.hasSettingsPermission}}
{{#if this.isNotMatchGithub}}
<TravisSwitch
Expand Down Expand Up @@ -60,4 +68,4 @@
{{/if}}
</p>
</div>
{{/if}}
{{/if}}
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
Loading

0 comments on commit 2555880

Please sign in to comment.