Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Align auth method config ttl value with system setting #26658

Closed
wants to merge 9 commits into from
35 changes: 14 additions & 21 deletions ui/app/adapters/auth-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,21 @@ export default ApplicationAdapter.extend({

findAll(store, type, sinceToken, snapshotRecordArray) {
const isUnauthenticated = snapshotRecordArray?.adapterOptions?.unauthenticated;
if (isUnauthenticated) {
const url = `/${this.urlPrefix()}/internal/ui/mounts`;
return this.ajax(url, 'GET', {
unauthenticated: true,
const url = `/${this.urlPrefix()}/internal/ui/mounts`;
return this.ajax(url, 'GET', { unauthenticated: isUnauthenticated })
.then((result) => {
return {
data: result.data.auth,
};
})
.then((result) => {
return {
data: result.data.auth,
};
})
.catch(() => {
return {
data: {},
};
});
}
return this.ajax(this.url(), 'GET').catch((e) => {
if (e instanceof AdapterError) {
set(e, 'policyPath', 'sys/auth');
}
throw e;
});
.catch((e) => {
if (isUnauthenticated) {
return { data: {} };
} else if (e instanceof AdapterError) {
set(e, 'policyPath', 'sys/auth');
}
throw e;
});
},

createRecord(store, type, snapshot) {
Expand Down
2 changes: 2 additions & 0 deletions ui/app/templates/components/auth-method/configuration.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
@alwaysRender={{not (is-empty-value (get @model attr.name))}}
@label={{or attr.options.label (to-label attr.name)}}
@value={{stringify (get @model attr.name)}}
@formatTtl={{eq attr.options.editType "ttl"}}
/>
{{else}}
<InfoTableRow
@alwaysRender={{not (is-empty-value (get @model attr.name))}}
@label={{or attr.options.label (to-label attr.name)}}
@value={{get @model attr.name}}
@formatTtl={{eq attr.options.editType "ttl"}}
/>
{{/if}}
{{/each}}
Expand Down
7 changes: 5 additions & 2 deletions ui/lib/core/addon/helpers/format-duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { helper } from '@ember/component/helper';
import { durationToSeconds } from 'core/utils/duration-utils';
import { convertFromSeconds, durationToSeconds, largestUnitFromSeconds } from 'core/utils/duration-utils';
import { formatDuration, intervalToDuration } from 'date-fns';

export function duration([time]) {
Expand All @@ -23,7 +23,10 @@ export function duration([time]) {
return '0 seconds';
}
// convert to human-readable format: '1 hour 6 seconds'
return formatDuration(durationObject);
let unit = largestUnitFromSeconds(seconds);
if (unit === 'd') unit = 'h'; // highest increment backend returns is hour
const duration = convertFromSeconds(seconds, unit);
return `${formatDuration(durationObject)} (${duration}${unit})`;
}
return time;
}
Expand Down
Loading