11import Controller from '@ember/controller' ;
22import { action } from '@ember/object' ;
33import { inject as service } from '@ember/service' ;
4- import { htmlSafe } from '@ember/template' ;
54import { tracked } from '@glimmer/tracking' ;
65
76import { task } from 'ember-concurrency' ;
87import { TrackedArray } from 'tracked-built-ins' ;
98
9+ import { patternDescription , scopeDescription } from '../../../utils/token-scopes' ;
10+
1011export default class NewTokenController extends Controller {
1112 @service notifications ;
1213 @service sentry ;
@@ -19,12 +20,9 @@ export default class NewTokenController extends Controller {
1920 @tracked scopesInvalid ;
2021 @tracked crateScopes ;
2122
22- ENDPOINT_SCOPES = [
23- { id : 'change-owners' , description : 'Invite new crate owners or remove existing ones' } ,
24- { id : 'publish-new' , description : 'Publish new crates' } ,
25- { id : 'publish-update' , description : 'Publish new versions of existing crates' } ,
26- { id : 'yank' , description : 'Yank and unyank crate versions' } ,
27- ] ;
23+ ENDPOINT_SCOPES = [ 'change-owners' , 'publish-new' , 'publish-update' , 'yank' ] ;
24+
25+ scopeDescription = scopeDescription ;
2826
2927 constructor ( ) {
3028 super ( ...arguments ) ;
@@ -120,14 +118,10 @@ class CratePattern {
120118 get description ( ) {
121119 if ( ! this . pattern ) {
122120 return 'Please enter a crate name pattern' ;
123- } else if ( this . pattern === '*' ) {
124- return 'Matches all crates on crates.io' ;
125- } else if ( ! this . isValid ) {
126- return 'Invalid crate name pattern' ;
127- } else if ( this . hasWildcard ) {
128- return htmlSafe ( `Matches all crates starting with <strong>${ this . pattern . slice ( 0 , - 1 ) } </strong>` ) ;
121+ } else if ( this . isValid ) {
122+ return patternDescription ( this . pattern ) ;
129123 } else {
130- return htmlSafe ( `Matches only the <strong> ${ this . pattern } </strong> crate` ) ;
124+ return 'Invalid crate name pattern' ;
131125 }
132126 }
133127
0 commit comments