1
0
Fork 0
forked from gitea/nas

Add: 管理画面で特に負荷の大きい処理を無効にする環境変数 (#633)

This commit is contained in:
KMY(雪あすか) 2024-03-05 12:05:52 +09:00 committed by GitHub
parent 0ed58512a1
commit 0a3007a9b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 41 additions and 5 deletions

View file

@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import { PureComponent } from 'react';
import { FormattedNumber } from 'react-intl';
import { FormattedNumber, FormattedMessage } from 'react-intl';
import api from 'mastodon/api';
import { Skeleton } from 'mastodon/components/skeleton';
@ -21,6 +21,7 @@ export default class Dimension extends PureComponent {
state = {
loading: true,
data: null,
empty: false,
};
componentDidMount () {
@ -30,6 +31,7 @@ export default class Dimension extends PureComponent {
this.setState({
loading: false,
data: res.data,
empty: res.data.length === 0,
});
}).catch(err => {
console.error(err);
@ -38,7 +40,7 @@ export default class Dimension extends PureComponent {
render () {
const { label, limit } = this.props;
const { loading, data } = this.state;
const { loading, data, empty } = this.state;
let content;
@ -60,6 +62,18 @@ export default class Dimension extends PureComponent {
</tbody>
</table>
);
} else if (empty) {
content = (
<table>
<tbody>
<tr className='dimension__item'>
<td className='dimension__item__value' colSpan={2}>
<FormattedMessage id='admin.dimenssions.disabled_key' defaultMessage='This information is invalid.' />
</td>
</tr>
</tbody>
</table>
);
} else {
const sum = data[0].data.reduce((sum, cur) => sum + (cur.value * 1), 0);