Merge pull request #12172 from keithjgrant/11869-users-help-text

Add help text to user token detail
This commit is contained in:
JST
2022-05-05 15:35:14 -03:00
committed by GitHub
3 changed files with 14 additions and 6 deletions

View File

@@ -12,6 +12,7 @@ import { TokensAPI } from 'api';
import { formatDateString } from 'util/dates'; import { formatDateString } from 'util/dates';
import useRequest, { useDismissableError } from 'hooks/useRequest'; import useRequest, { useDismissableError } from 'hooks/useRequest';
import { toTitleCase } from 'util/strings'; import { toTitleCase } from 'util/strings';
import helptext from '../shared/User.helptext';
function UserTokenDetail({ token }) { function UserTokenDetail({ token }) {
const { scope, description, created, modified, expires, summary_fields } = const { scope, description, created, modified, expires, summary_fields } =
@@ -37,6 +38,7 @@ function UserTokenDetail({ token }) {
label={t`Application`} label={t`Application`}
value={summary_fields?.application?.name} value={summary_fields?.application?.name}
dataCy="application-token-detail-name" dataCy="application-token-detail-name"
helpText={helptext.application}
/> />
<Detail <Detail
label={t`Description`} label={t`Description`}
@@ -47,6 +49,7 @@ function UserTokenDetail({ token }) {
label={t`Scope`} label={t`Scope`}
value={toTitleCase(scope)} value={toTitleCase(scope)}
dataCy="application-token-detail-scope" dataCy="application-token-detail-scope"
helpText={helptext.scope}
/> />
<Detail <Detail
label={t`Expires`} label={t`Expires`}

View File

@@ -0,0 +1,8 @@
import { t } from '@lingui/macro';
const userHelpTextStrings = {
application: t`The application that this token belongs to, or leave this field empty to create a Personal Access Token.`,
scope: t`Scope for the token's access`,
};
export default userHelpTextStrings;

View File

@@ -9,6 +9,7 @@ import ApplicationLookup from 'components/Lookup/ApplicationLookup';
import Popover from 'components/Popover'; import Popover from 'components/Popover';
import { required } from 'util/validators'; import { required } from 'util/validators';
import { FormColumnLayout } from 'components/FormLayout'; import { FormColumnLayout } from 'components/FormLayout';
import helptext from './User.helptext';
function UserTokenFormFields() { function UserTokenFormFields() {
const { setFieldValue, setFieldTouched } = useFormikContext(); const { setFieldValue, setFieldTouched } = useFormikContext();
@@ -45,9 +46,7 @@ function UserTokenFormFields() {
label={ label={
<span> <span>
{t`Application`} {t`Application`}
<Popover <Popover content={helptext.application} />
content={t`Select the application that this token will belong to, or leave this field empty to create a Personal Access Token.`}
/>
</span> </span>
} }
touched={applicationMeta.touched} touched={applicationMeta.touched}
@@ -67,9 +66,7 @@ function UserTokenFormFields() {
isRequired isRequired
validated={!scopeMeta.touched || !scopeMeta.error ? 'default' : 'error'} validated={!scopeMeta.touched || !scopeMeta.error ? 'default' : 'error'}
label={t`Scope`} label={t`Scope`}
labelIcon={ labelIcon={<Popover content={helptext.scope} />}
<Popover content={t`Specify a scope for the token's access`} />
}
> >
<AnsibleSelect <AnsibleSelect
{...scopeField} {...scopeField}