ui: Reformat MaxTokenTTL to sortBy as an integer (#9969)

* Install Duration JS

* Use Duration.js to sortBy reformatted MaxTokenTTL

* Remove @icholy/duration package

* Install parse-duration package

* Use parse-duration in auth-method model
This commit is contained in:
Kenia 2021-04-07 12:43:04 -04:00 committed by GitHub
parent 56b8616a17
commit a0d12ff164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 5 deletions

View File

@ -122,8 +122,8 @@ as |key value|}}
{{#let (from-entries (array
(array "MethodName:asc" (t "common.sort.alpha.asc"))
(array "MethodName:desc" (t "common.sort.alpha.desc"))
(array "MaxTokenTTL:desc" (t "common.sort.duration.asc"))
(array "MaxTokenTTL:asc" (t "common.sort.duration.desc"))
(array "TokenTTL:desc" (t "common.sort.duration.asc"))
(array "TokenTTL:asc" (t "common.sort.duration.desc"))
))
as |selectable|
}}
@ -138,8 +138,8 @@ as |key value|}}
<Option @value="MethodName:desc" @selected={{eq "MethodName:desc" @sort.value}}>{{t "common.sort.alpha.desc"}}</Option>
</Optgroup>
<Optgroup @label={{t "common.ui.maxttl"}}>
<Option @value="MaxTokenTTL:desc" @selected={{eq "MaxTokenTTL:desc" @sort.value}}>{{t "common.sort.duration.asc"}}</Option>
<Option @value="MaxTokenTTL:asc" @selected={{eq "MaxTokenTTL:asc" @sort.value}}>{{t "common.sort.duration.desc"}}</Option>
<Option @value="TokenTTL:desc" @selected={{eq "TokenTTL:desc" @sort.value}}>{{t "common.sort.duration.asc"}}</Option>
<Option @value="TokenTTL:asc" @selected={{eq "TokenTTL:asc" @sort.value}}>{{t "common.sort.duration.desc"}}</Option>
</Optgroup>
{{/let}}
</BlockSlot>

View File

@ -1,5 +1,7 @@
import Model, { attr } from '@ember-data/model';
import { or } from '@ember/object/computed';
import parse from 'parse-duration';
import { computed } from '@ember/object';
export const PRIMARY_KEY = 'uid';
export const SLUG_KEY = 'Name';
@ -22,4 +24,9 @@ export default class AuthMethod extends Model {
@attr('number') ModifyIndex;
@attr() Datacenters; // string[]
@attr() meta; // {}
@computed('MaxTokenTTL')
get TokenTTL() {
return parse(this.MaxTokenTTL);
}
}

View File

@ -1,3 +1,3 @@
export default ({ properties }) => (key = 'MethodName:asc') => {
return properties(['MethodName', 'MaxTokenTTL'])(key);
return properties(['MethodName', 'TokenTTL'])(key);
};

View File

@ -150,6 +150,7 @@
"loader.js": "^4.7.0",
"mnemonist": "^0.38.0",
"ngraph.graph": "^19.1.0",
"parse-duration": "^1.0.0",
"pretender": "^3.2.0",
"prettier": "^1.10.2",
"qunit-dom": "^1.0.0",

View File

@ -11046,6 +11046,11 @@ parse-asn1@^5.0.0, parse-asn1@^5.1.5:
pbkdf2 "^3.0.3"
safe-buffer "^5.1.1"
parse-duration@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/parse-duration/-/parse-duration-1.0.0.tgz#8605651745f61088f6fb14045c887526c291858c"
integrity sha512-X4kUkCTHU1N/kEbwK9FpUJ0UZQa90VzeczfS704frR30gljxDG0pSziws06XlK+CGRSo/1wtG1mFIdBFQTMQNw==
parse-entities@^1.1.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/parse-entities/-/parse-entities-1.2.2.tgz#c31bf0f653b6661354f8973559cb86dd1d5edf50"