Skip to content

Commit f1de354

Browse files
authored
trustpub: Rename controller properties (#12319)
These are more generic terms, that can also be used for GitLab
1 parent d7a2b9e commit f1de354

File tree

5 files changed

+113
-113
lines changed

5 files changed

+113
-113
lines changed

app/controllers/crate/settings/new-trusted-publisher.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export default class NewTrustedPublisherController extends Controller {
1212
@service router;
1313

1414
@tracked publisher = 'GitHub';
15-
@tracked repositoryOwner = '';
16-
@tracked repositoryName = '';
17-
@tracked workflowFilename = '';
15+
@tracked namespace = '';
16+
@tracked project = '';
17+
@tracked workflow = '';
1818
@tracked environment = '';
19-
@tracked repositoryOwnerInvalid = false;
20-
@tracked repositoryNameInvalid = false;
21-
@tracked workflowFilenameInvalid = false;
19+
@tracked namespaceInvalid = false;
20+
@tracked projectInvalid = false;
21+
@tracked workflowInvalid = false;
2222

2323
get crate() {
2424
return this.model.crate;
@@ -29,14 +29,14 @@ export default class NewTrustedPublisherController extends Controller {
2929
}
3030

3131
get repository() {
32-
if (this.repositoryOwner && this.repositoryName) {
33-
return `${this.repositoryOwner}/${this.repositoryName}`;
32+
if (this.namespace && this.project) {
33+
return `${this.namespace}/${this.project}`;
3434
}
3535
}
3636

3737
get verificationUrl() {
38-
if (this.repositoryOwner && this.repositoryName && this.workflowFilename) {
39-
return `https://raw.githubusercontent.com/${this.repositoryOwner}/${this.repositoryName}/HEAD/.github/workflows/${this.workflowFilename}`;
38+
if (this.namespace && this.project && this.workflow) {
39+
return `https://raw.githubusercontent.com/${this.namespace}/${this.project}/HEAD/.github/workflows/${this.workflow}`;
4040
}
4141
}
4242

@@ -67,19 +67,19 @@ export default class NewTrustedPublisherController extends Controller {
6767

6868
let config = this.store.createRecord('trustpub-github-config', {
6969
crate: this.crate,
70-
repository_owner: this.repositoryOwner,
71-
repository_name: this.repositoryName,
72-
workflow_filename: this.workflowFilename,
70+
repository_owner: this.namespace,
71+
repository_name: this.project,
72+
workflow_filename: this.workflow,
7373
environment: this.environment || null,
7474
});
7575

7676
try {
7777
// Save the new config on the backend
7878
await config.save();
7979

80-
this.repositoryOwner = '';
81-
this.repositoryName = '';
82-
this.workflowFilename = '';
80+
this.namespace = '';
81+
this.project = '';
82+
this.workflow = '';
8383
this.environment = '';
8484

8585
// Navigate back to the crate settings page
@@ -99,22 +99,22 @@ export default class NewTrustedPublisherController extends Controller {
9999
});
100100

101101
validate() {
102-
this.repositoryOwnerInvalid = !this.repositoryOwner;
103-
this.repositoryNameInvalid = !this.repositoryName;
104-
this.workflowFilenameInvalid = !this.workflowFilename;
102+
this.namespaceInvalid = !this.namespace;
103+
this.projectInvalid = !this.project;
104+
this.workflowInvalid = !this.workflow;
105105

106-
return !this.repositoryOwnerInvalid && !this.repositoryNameInvalid && !this.workflowFilenameInvalid;
106+
return !this.namespaceInvalid && !this.projectInvalid && !this.workflowInvalid;
107107
}
108108

109-
@action resetRepositoryOwnerValidation() {
110-
this.repositoryOwnerInvalid = false;
109+
@action resetNamespaceValidation() {
110+
this.namespaceInvalid = false;
111111
}
112112

113-
@action resetRepositoryNameValidation() {
114-
this.repositoryNameInvalid = false;
113+
@action resetProjectValidation() {
114+
this.projectInvalid = false;
115115
}
116116

117-
@action resetWorkflowFilenameValidation() {
118-
this.workflowFilenameInvalid = false;
117+
@action resetWorkflowValidation() {
118+
this.workflowInvalid = false;
119119
}
120120
}

app/routes/crate/settings/new-trusted-publisher.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export default class NewTrustedPublisherRoute extends Route {
99
setupController(controller, model) {
1010
super.setupController(controller, model);
1111

12-
controller.repositoryOwner = '';
13-
controller.repositoryName = '';
14-
controller.workflowFilename = '';
12+
controller.namespace = '';
13+
controller.project = '';
14+
controller.workflow = '';
1515
controller.environment = '';
1616

1717
let repository = model.crate.repository;
@@ -20,8 +20,8 @@ export default class NewTrustedPublisherRoute extends Route {
2020
let url = new URL(repository);
2121
let pathParts = url.pathname.slice(1).split('/');
2222
if (pathParts.length >= 2) {
23-
controller.repositoryOwner = pathParts[0];
24-
controller.repositoryName = pathParts[1].replace(/.git$/, '');
23+
controller.namespace = pathParts[0];
24+
controller.project = pathParts[1].replace(/.git$/, '');
2525
}
2626
} catch {
2727
// ignore malformed URLs

app/templates/crate/settings/new-trusted-publisher.gjs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@ import LoadingSpinner from 'crates-io/components/loading-spinner';
3737
</div>
3838

3939
{{#if (eq @controller.publisher 'GitHub')}}
40-
<div class='form-group' data-test-repository-owner-group>
40+
<div class='form-group' data-test-namespace-group>
4141
{{#let (uniqueId) as |id|}}
4242
<label for={{id}} class='form-group-name'>Repository owner</label>
4343

4444
<Input
4545
id={{id}}
4646
@type='text'
47-
@value={{@controller.repositoryOwner}}
47+
@value={{@controller.namespace}}
4848
disabled={{@controller.saveConfigTask.isRunning}}
4949
aria-required='true'
50-
aria-invalid={{if @controller.repositoryOwnerInvalid 'true' 'false'}}
50+
aria-invalid={{if @controller.namespaceInvalid 'true' 'false'}}
5151
class='input base-input'
52-
data-test-repository-owner
52+
data-test-namespace
5353
{{autoFocus}}
54-
{{on 'input' @controller.resetRepositoryOwnerValidation}}
54+
{{on 'input' @controller.resetNamespaceValidation}}
5555
{{on 'input' (perform @controller.verifyWorkflowTask)}}
5656
/>
5757

58-
{{#if @controller.repositoryOwnerInvalid}}
58+
{{#if @controller.namespaceInvalid}}
5959
<div class='form-group-error' data-test-error>
6060
Please enter a repository owner.
6161
</div>
@@ -67,24 +67,24 @@ import LoadingSpinner from 'crates-io/components/loading-spinner';
6767
{{/let}}
6868
</div>
6969

70-
<div class='form-group' data-test-repository-name-group>
70+
<div class='form-group' data-test-project-group>
7171
{{#let (uniqueId) as |id|}}
7272
<label for={{id}} class='form-group-name'>Repository name</label>
7373

7474
<Input
7575
id={{id}}
7676
@type='text'
77-
@value={{@controller.repositoryName}}
77+
@value={{@controller.project}}
7878
disabled={{@controller.saveConfigTask.isRunning}}
7979
aria-required='true'
80-
aria-invalid={{if @controller.repositoryNameInvalid 'true' 'false'}}
80+
aria-invalid={{if @controller.projectInvalid 'true' 'false'}}
8181
class='input base-input'
82-
data-test-repository-name
83-
{{on 'input' @controller.resetRepositoryNameValidation}}
82+
data-test-project
83+
{{on 'input' @controller.resetProjectValidation}}
8484
{{on 'input' (perform @controller.verifyWorkflowTask)}}
8585
/>
8686

87-
{{#if @controller.repositoryNameInvalid}}
87+
{{#if @controller.projectInvalid}}
8888
<div class='form-group-error' data-test-error>
8989
Please enter a repository name.
9090
</div>
@@ -96,24 +96,24 @@ import LoadingSpinner from 'crates-io/components/loading-spinner';
9696
{{/let}}
9797
</div>
9898

99-
<div class='form-group' data-test-workflow-filename-group>
99+
<div class='form-group' data-test-workflow-group>
100100
{{#let (uniqueId) as |id|}}
101101
<label for={{id}} class='form-group-name'>Workflow filename</label>
102102

103103
<Input
104104
id={{id}}
105105
@type='text'
106-
@value={{@controller.workflowFilename}}
106+
@value={{@controller.workflow}}
107107
disabled={{@controller.saveConfigTask.isRunning}}
108108
aria-required='true'
109-
aria-invalid={{if @controller.workflowFilenameInvalid 'true' 'false'}}
109+
aria-invalid={{if @controller.workflowInvalid 'true' 'false'}}
110110
class='input base-input'
111-
data-test-workflow-filename
112-
{{on 'input' @controller.resetWorkflowFilenameValidation}}
111+
data-test-workflow
112+
{{on 'input' @controller.resetWorkflowValidation}}
113113
{{on 'input' (perform @controller.verifyWorkflowTask)}}
114114
/>
115115

116-
{{#if @controller.workflowFilenameInvalid}}
116+
{{#if @controller.workflowInvalid}}
117117
<div class='form-group-error' data-test-error>
118118
Please enter a workflow filename.
119119
</div>

e2e/routes/crate/settings/new-trusted-publisher.spec.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
115115
await page.goto(`/crates/${crate.name}/settings/new-trusted-publisher`);
116116

117117
await expect(page.locator('[data-test-publisher]')).toHaveValue(publisher);
118-
await expect(page.locator('[data-test-repository-owner]')).toHaveValue(owner);
119-
await expect(page.locator('[data-test-repository-name]')).toHaveValue(repo);
118+
await expect(page.locator('[data-test-namespace]')).toHaveValue(owner);
119+
await expect(page.locator('[data-test-project]')).toHaveValue(repo);
120120
});
121121
}
122122
});
@@ -140,17 +140,17 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
140140

141141
// Check that the form is displayed correctly
142142
await expect(page.locator('[data-test-publisher]')).toBeVisible();
143-
await expect(page.locator('[data-test-repository-owner]')).toBeVisible();
144-
await expect(page.locator('[data-test-repository-name]')).toBeVisible();
145-
await expect(page.locator('[data-test-workflow-filename]')).toBeVisible();
143+
await expect(page.locator('[data-test-namespace]')).toBeVisible();
144+
await expect(page.locator('[data-test-project]')).toBeVisible();
145+
await expect(page.locator('[data-test-workflow]')).toBeVisible();
146146
await expect(page.locator('[data-test-environment]')).toBeVisible();
147147
await expect(page.locator('[data-test-add]')).toBeVisible();
148148
await expect(page.locator('[data-test-cancel]')).toBeVisible();
149149

150150
// Fill in the form
151-
await page.fill('[data-test-repository-owner]', 'rust-lang');
152-
await page.fill('[data-test-repository-name]', 'crates.io');
153-
await page.fill('[data-test-workflow-filename]', 'ci.yml');
151+
await page.fill('[data-test-namespace]', 'rust-lang');
152+
await page.fill('[data-test-project]', 'crates.io');
153+
await page.fill('[data-test-workflow]', 'ci.yml');
154154
await page.fill('[data-test-environment]', 'release');
155155

156156
// Submit the form
@@ -194,14 +194,14 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
194194
await page.click('[data-test-add]');
195195

196196
// Check that validation errors are displayed
197-
await expect(page.locator('[data-test-repository-owner-group] [data-test-error]')).toBeVisible();
198-
await expect(page.locator('[data-test-repository-name-group] [data-test-error]')).toBeVisible();
199-
await expect(page.locator('[data-test-workflow-filename-group] [data-test-error]')).toBeVisible();
197+
await expect(page.locator('[data-test-namespace-group] [data-test-error]')).toBeVisible();
198+
await expect(page.locator('[data-test-project-group] [data-test-error]')).toBeVisible();
199+
await expect(page.locator('[data-test-workflow-group] [data-test-error]')).toBeVisible();
200200

201201
// Fill in the required fields
202-
await page.fill('[data-test-repository-owner]', 'rust-lang');
203-
await page.fill('[data-test-repository-name]', 'crates.io');
204-
await page.fill('[data-test-workflow-filename]', 'ci.yml');
202+
await page.fill('[data-test-namespace]', 'rust-lang');
203+
await page.fill('[data-test-project]', 'crates.io');
204+
await page.fill('[data-test-workflow]', 'ci.yml');
205205

206206
// Submit the form
207207
await page.click('[data-test-add]');
@@ -221,17 +221,17 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
221221
await expect(page).toHaveURL(`/crates/${crate.name}/settings/new-trusted-publisher`);
222222

223223
// Fill in the form
224-
await page.fill('[data-test-repository-owner]', 'rust-lang');
225-
await page.fill('[data-test-repository-name]', 'crates.io');
226-
await page.fill('[data-test-workflow-filename]', 'ci.yml');
224+
await page.fill('[data-test-namespace]', 'rust-lang');
225+
await page.fill('[data-test-project]', 'crates.io');
226+
await page.fill('[data-test-workflow]', 'ci.yml');
227227

228228
// Submit the form
229229
await page.click('[data-test-add]');
230230
await expect(page.locator('[data-test-add] [data-test-spinner]')).toBeVisible();
231231
await expect(page.locator('[data-test-publisher]')).toBeDisabled();
232-
await expect(page.locator('[data-test-repository-owner]')).toBeDisabled();
233-
await expect(page.locator('[data-test-repository-name]')).toBeDisabled();
234-
await expect(page.locator('[data-test-workflow-filename]')).toBeDisabled();
232+
await expect(page.locator('[data-test-namespace]')).toBeDisabled();
233+
await expect(page.locator('[data-test-project]')).toBeDisabled();
234+
await expect(page.locator('[data-test-workflow]')).toBeDisabled();
235235
await expect(page.locator('[data-test-environment]')).toBeDisabled();
236236
await expect(page.locator('[data-test-add]')).toBeDisabled();
237237

@@ -244,9 +244,9 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
244244
);
245245

246246
await expect(page.locator('[data-test-publisher]')).toBeEnabled();
247-
await expect(page.locator('[data-test-repository-owner]')).toBeEnabled();
248-
await expect(page.locator('[data-test-repository-name]')).toBeEnabled();
249-
await expect(page.locator('[data-test-workflow-filename]')).toBeEnabled();
247+
await expect(page.locator('[data-test-namespace]')).toBeEnabled();
248+
await expect(page.locator('[data-test-project]')).toBeEnabled();
249+
await expect(page.locator('[data-test-workflow]')).toBeEnabled();
250250
await expect(page.locator('[data-test-environment]')).toBeEnabled();
251251
await expect(page.locator('[data-test-add]')).toBeEnabled();
252252

@@ -272,9 +272,9 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
272272
'The workflow filename will be verified once all necessary fields are filled.',
273273
);
274274

275-
await page.fill('[data-test-repository-owner]', 'rust-lang');
276-
await page.fill('[data-test-repository-name]', 'crates.io');
277-
await page.fill('[data-test-workflow-filename]', 'ci.yml');
275+
await page.fill('[data-test-namespace]', 'rust-lang');
276+
await page.fill('[data-test-project]', 'crates.io');
277+
await page.fill('[data-test-workflow]', 'ci.yml');
278278

279279
await expect(page.locator('[data-test-workflow-verification="success"]')).toHaveText(
280280
'✓ Workflow file found at https://raw.githubusercontent.com/rust-lang/crates.io/HEAD/.github/workflows/ci.yml',
@@ -293,9 +293,9 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
293293
}),
294294
);
295295

296-
await page.fill('[data-test-repository-owner]', 'rust-lang');
297-
await page.fill('[data-test-repository-name]', 'crates.io');
298-
await page.fill('[data-test-workflow-filename]', 'missing.yml');
296+
await page.fill('[data-test-namespace]', 'rust-lang');
297+
await page.fill('[data-test-project]', 'crates.io');
298+
await page.fill('[data-test-workflow]', 'missing.yml');
299299

300300
await expect(page.locator('[data-test-workflow-verification="not-found"]')).toHaveText(
301301
'⚠ Workflow file not found at https://raw.githubusercontent.com/rust-lang/crates.io/HEAD/.github/workflows/missing.yml',
@@ -318,9 +318,9 @@ test.describe('Route | crate.settings.new-trusted-publisher', { tag: '@routes' }
318318
}),
319319
);
320320

321-
await page.fill('[data-test-repository-owner]', 'rust-lang');
322-
await page.fill('[data-test-repository-name]', 'crates.io');
323-
await page.fill('[data-test-workflow-filename]', 'ci.yml');
321+
await page.fill('[data-test-namespace]', 'rust-lang');
322+
await page.fill('[data-test-project]', 'crates.io');
323+
await page.fill('[data-test-workflow]', 'ci.yml');
324324

325325
await expect(page.locator('[data-test-workflow-verification="error"]')).toHaveText(
326326
'⚠ Could not verify workflow file at https://raw.githubusercontent.com/rust-lang/crates.io/HEAD/.github/workflows/ci.yml (network error)',

0 commit comments

Comments
 (0)