1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +00:00

[a11y] 'repo API Token' dialog: added support for 'keyboard access'

This commit is contained in:
llj
2021-10-09 14:17:06 +08:00
parent ccc0e764f3
commit fbc5b0d30c
3 changed files with 40 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ import { Utils } from '../../utils/utils';
import toaster from '../toast'; import toaster from '../toast';
import copy from 'copy-to-clipboard'; import copy from 'copy-to-clipboard';
import Loading from '../loading'; import Loading from '../loading';
import OpIcon from '../op-icon';
const apiTokenItemPropTypes = { const apiTokenItemPropTypes = {
item: PropTypes.object.isRequired, item: PropTypes.object.isRequired,
@@ -50,7 +51,7 @@ class APITokenItem extends React.Component {
let item = this.props.item; let item = this.props.item;
return ( return (
<tr onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave}> <tr onMouseEnter={this.onMouseEnter} onMouseLeave={this.onMouseLeave} tabIndex="0" onFocus={this.onMouseEnter}>
<td className="name">{item.app_name}</td> <td className="name">{item.app_name}</td>
<td> <td>
<RepoAPITokenPermissionEditor <RepoAPITokenPermissionEditor
@@ -63,13 +64,17 @@ class APITokenItem extends React.Component {
<td> <td>
<span>{item.api_token}</span> <span>{item.api_token}</span>
{this.state.isOperationShow && {this.state.isOperationShow &&
<span className="far fa-copy action-icon" onClick={this.onCopyAPIToken} /> <OpIcon
className="far fa-copy action-icon"
op={this.onCopyAPIToken}
title={gettext('Copy')}
/>
} }
</td> </td>
<td> <td>
<span <OpIcon
className={`sf2-icon-x3 action-icon ${this.state.isOperationShow ? '' : 'hide'}`} className={`sf2-icon-x3 action-icon ${this.state.isOperationShow ? '' : 'hide'}`}
onClick={this.onDeleteAPIToken} op={this.onDeleteAPIToken}
title={gettext('Delete')} title={gettext('Delete')}
/> />
</td> </td>

View File

@@ -0,0 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Utils } from '../utils/utils';
const propTypes = {
className: PropTypes.string.isRequired,
op: PropTypes.func,
title: PropTypes.string.isRequired
};
class OpIcon extends React.Component {
render() {
const { className, op, title } = this.props;
return (<span
tabIndex="0"
role="button"
className={className}
title={title}
aria-label={title}
onClick={op}
onKeyDown={Utils.onKeyDown}
></span>);
}
}
OpIcon.propTypes = propTypes;
export default OpIcon;

View File

@@ -2,6 +2,7 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Select from 'react-select'; import Select from 'react-select';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
import OpIcon from '../op-icon';
const propTypes = { const propTypes = {
isTextMode: PropTypes.bool.isRequired, isTextMode: PropTypes.bool.isRequired,
@@ -60,7 +61,7 @@ class RepoAPITokenPermissionEditor extends React.Component {
<Fragment> <Fragment>
<span>{optionTranslation}</span> <span>{optionTranslation}</span>
{this.props.isEditIconShow && {this.props.isEditIconShow &&
<span title={gettext('Edit')} className="fa fa-pencil-alt attr-action-icon" onClick={this.onEditPermission}/> <OpIcon title={gettext('Edit')} className="fa fa-pencil-alt attr-action-icon" op={this.onEditPermission} />
} }
</Fragment> </Fragment>
: :