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 classNames from 'classnames';
@ -43,6 +43,7 @@ export default class Counter extends PureComponent {
state = {
loading: true,
data: null,
empty: false,
};
componentDidMount () {
@ -52,6 +53,7 @@ export default class Counter extends PureComponent {
this.setState({
loading: false,
data: res.data,
empty: res.data.length === 0,
});
}).catch(err => {
console.error(err);
@ -60,7 +62,7 @@ export default class Counter extends PureComponent {
render () {
const { label, href, target } = this.props;
const { loading, data } = this.state;
const { loading, data, empty } = this.state;
let content;
@ -71,6 +73,12 @@ export default class Counter extends PureComponent {
<span className='sparkline__value__change'><Skeleton width={43} /></span>
</>
);
} else if (empty) {
content = (
<span className='sparkline__value__change'>
<FormattedMessage id='admin.dimenssions.disabled_key' defaultMessage='This information is invalid.' />
</span>
);
} else {
const measure = data[0];
const percentChange = measure.previous_total && percIncrease(measure.previous_total * 1, measure.total * 1);
@ -94,7 +102,7 @@ export default class Counter extends PureComponent {
</div>
<div className='sparkline__graph'>
{!loading && (
{!loading && !empty && (
<Sparklines width={259} height={55} data={data[0].data.map(x => x.value * 1)}>
<SparklinesCurve />
</Sparklines>