Updates #4209.
Squashed commit of the following:
commit 0c31a59c5bf6bcc27a4779adf226d9a1ac9eece1
Merge: 803f32db 8455940b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Tue Feb 1 19:33:55 2022 +0300
Merge branch 'master' into 4209-ann-url
commit 803f32dbc7276077a4374ed0f5e0a1fa36f91c9b
Author: Ildar Kamalov <ik@adguard.com>
Date: Tue Feb 1 14:46:47 2022 +0300
client: add manual update link to update topline
commit ca375b52fa53503a3987b9723eb9a1d74878e890
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Mon Jan 31 20:49:42 2022 +0300
all: imp ann url
60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
import React from 'react';
|
|
import { Trans } from 'react-i18next';
|
|
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
|
|
|
|
import Topline from './Topline';
|
|
import { getUpdate } from '../../actions';
|
|
import { MANUAL_UPDATE_LINK } from '../../helpers/constants';
|
|
|
|
const UpdateTopline = () => {
|
|
const {
|
|
announcementUrl,
|
|
newVersion,
|
|
canAutoUpdate,
|
|
processingUpdate,
|
|
} = useSelector((state) => state.dashboard, shallowEqual);
|
|
const dispatch = useDispatch();
|
|
|
|
const handleUpdate = () => {
|
|
dispatch(getUpdate());
|
|
};
|
|
|
|
return <Topline type="info">
|
|
<>
|
|
<Trans
|
|
values={{ version: newVersion }}
|
|
components={[
|
|
<a href={announcementUrl} target="_blank" rel="noopener noreferrer" key="0">
|
|
Click here
|
|
</a>,
|
|
]}
|
|
>
|
|
update_announcement
|
|
</Trans>
|
|
|
|
{canAutoUpdate ? (
|
|
<button
|
|
type="button"
|
|
className="btn btn-sm btn-primary ml-3"
|
|
onClick={handleUpdate}
|
|
disabled={processingUpdate}
|
|
>
|
|
<Trans>update_now</Trans>
|
|
</button>
|
|
) : (
|
|
<Trans components={{
|
|
a: (
|
|
<a href={MANUAL_UPDATE_LINK} target="_blank" rel="noopener noreferrer" key="0">
|
|
Link
|
|
</a>
|
|
),
|
|
}}>
|
|
manual_update
|
|
</Trans>
|
|
)}
|
|
</>
|
|
</Topline>;
|
|
};
|
|
|
|
export default UpdateTopline;
|