Squashed commit of the following: commit 5617cde490beea6f09e1beef1ff8b8e151e26244 Merge: 0a6500e757f9a3a73b
Author: Artem Baskal <a.baskal@adguard.com> Date: Tue Dec 8 18:34:19 2020 +0300 Merge branch 'master' into use-external-links commit 0a6500e75fbaa354a938c818f02f0b2419bd0d8e Merge: 9d2ff3bb573c30590e
Author: Artem Baskal <a.baskal@adguard.com> Date: Tue Dec 8 18:15:57 2020 +0300 Merge branch 'master' into use-external-links commit 9d2ff3bb5b3f5d5f08f26f54552ac07dd1724de5 Author: Artem Baskal <a.baskal@adguard.com> Date: Tue Dec 8 18:04:09 2020 +0300 client: open external links in new tab commit 57d0ed09a8d90282b9dcad1c4943dd6d15a13cc8 Author: Zhijie He <hezhijie0327@hotmail.com> Date: Tue Nov 24 09:53:37 2020 +0800 Encryption: use rel="noopener noreferrer" commit 0554590059a3e9d5a9c1b576af2b409cff8c77e8 Author: Zhijie He <hezhijie0327@hotmail.com> Date: Tue Nov 24 09:51:19 2020 +0800 Clients: use rel="noopener noreferrer"
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { getIpList, getDnsAddress, getWebAddress } from '../../helpers/helpers';
|
|
import { ALL_INTERFACES_IP } from '../../helpers/constants';
|
|
|
|
const renderItem = ({
|
|
ip, port, isDns,
|
|
}) => {
|
|
const webAddress = getWebAddress(ip, port);
|
|
const dnsAddress = getDnsAddress(ip, port);
|
|
|
|
return <li key={ip}>{isDns
|
|
? <strong>{dnsAddress}</strong>
|
|
: <a href={webAddress} target="_blank" rel="noopener noreferrer">{webAddress}</a>
|
|
}
|
|
</li>;
|
|
};
|
|
|
|
const AddressList = ({
|
|
address,
|
|
interfaces,
|
|
port,
|
|
isDns,
|
|
}) => <ul className="list-group pl-4">{
|
|
address === ALL_INTERFACES_IP
|
|
? getIpList(interfaces)
|
|
.map((ip) => renderItem({
|
|
ip,
|
|
port,
|
|
isDns,
|
|
}))
|
|
: renderItem({
|
|
ip: address,
|
|
port,
|
|
isDns,
|
|
})
|
|
}
|
|
</ul>;
|
|
|
|
AddressList.propTypes = {
|
|
interfaces: PropTypes.object.isRequired,
|
|
address: PropTypes.string.isRequired,
|
|
port: PropTypes.oneOfType([
|
|
PropTypes.string,
|
|
PropTypes.number,
|
|
]),
|
|
isDns: PropTypes.bool,
|
|
};
|
|
|
|
renderItem.propTypes = {
|
|
ip: PropTypes.string.isRequired,
|
|
port: PropTypes.string.isRequired,
|
|
isDns: PropTypes.bool.isRequired,
|
|
};
|
|
|
|
export default AddressList;
|