2020-08-13 08:15:45 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
import { Trans } from 'react-i18next';
|
|
|
|
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
2019-02-20 13:54:14 +00:00
|
|
|
import Topline from './Topline';
|
2020-08-13 08:15:45 +00:00
|
|
|
import { getUpdate } from '../../actions';
|
|
|
|
|
|
|
|
|
|
const UpdateTopline = () => {
|
|
|
|
|
const {
|
|
|
|
|
announcementUrl,
|
|
|
|
|
newVersion,
|
|
|
|
|
canAutoUpdate,
|
|
|
|
|
processingUpdate,
|
|
|
|
|
} = useSelector((state) => state.dashboard, shallowEqual);
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
const handleUpdate = () => {
|
|
|
|
|
dispatch(getUpdate());
|
|
|
|
|
};
|
2019-02-20 13:54:14 +00:00
|
|
|
|
2020-08-13 08:15:45 +00:00
|
|
|
return <Topline type="info">
|
|
|
|
|
<>
|
2019-05-16 14:24:30 +00:00
|
|
|
<Trans
|
2020-08-13 08:15:45 +00:00
|
|
|
values={{ version: newVersion }}
|
2019-05-16 14:24:30 +00:00
|
|
|
components={[
|
2020-08-13 08:15:45 +00:00
|
|
|
<a href={announcementUrl} target="_blank" rel="noopener noreferrer" key="0">
|
2019-05-16 14:24:30 +00:00
|
|
|
Click here
|
|
|
|
|
</a>,
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
update_announcement
|
|
|
|
|
</Trans>
|
2020-08-13 08:15:45 +00:00
|
|
|
{canAutoUpdate
|
|
|
|
|
&& <button
|
|
|
|
|
type="button"
|
|
|
|
|
className="btn btn-sm btn-primary ml-3"
|
|
|
|
|
onClick={handleUpdate}
|
|
|
|
|
disabled={processingUpdate}
|
|
|
|
|
>
|
|
|
|
|
<Trans>update_now</Trans>
|
|
|
|
|
</button>
|
2019-05-16 14:24:30 +00:00
|
|
|
}
|
2020-08-13 08:15:45 +00:00
|
|
|
</>
|
|
|
|
|
</Topline>;
|
2019-02-20 13:54:14 +00:00
|
|
|
};
|
|
|
|
|
|
2020-08-13 08:15:45 +00:00
|
|
|
export default UpdateTopline;
|