diff --git a/frontend/src/components/DNS/DNSOverrideList.js b/frontend/src/components/DNS/DNSOverrideList.js index f16fb1b22..cbf31b9e7 100644 --- a/frontend/src/components/DNS/DNSOverrideList.js +++ b/frontend/src/components/DNS/DNSOverrideList.js @@ -1,38 +1,12 @@ import React from 'react' import PropTypes from 'prop-types' -import { AlertContext } from 'layouts/Admin' -import { blockAPI } from 'api/DNS' -import { format as timeAgo } from 'timeago.js' - -import { - Box, - VStack, - FlatList, - HStack, - Text, - Button, - ButtonIcon, - CloseIcon -} from '@gluestack-ui/themed' +import { FlatList, Text } from '@gluestack-ui/themed' import ListHeader from 'components/List/ListHeader' -import { ListItem } from 'components/List' - -const DNSOverrideList = ({ title, list, ...props }) => { - const context = React.useContext(AlertContext) - - const deleteListItem = async (item) => { - blockAPI - .deleteOverride(item) - .then((res) => { - props.notifyChange('config') - }) - .catch((error) => { - context.error('API Failure: ' + error.message) - }) - } +import DNSOverrideListItem from './DNSOverrideListItem' +const DNSOverrideList = ({ title, list, deleteListItem, ...props }) => { return ( <> @@ -45,59 +19,7 @@ const DNSOverrideList = ({ title, list, ...props }) => { ( - - - - {item.Domain} - - - = - - {item.ResultIP || '0.0.0.0'} - - - - - - Client: - {item.ClientIP} - - - - Expiration: - - {item.Expiration - ? timeAgo(new Date(item.Expiration * 1e3)) - : 'Never'} - - - - - - - + )} keyExtractor={(item) => item.Domain} /> @@ -108,7 +30,8 @@ const DNSOverrideList = ({ title, list, ...props }) => { DNSOverrideList.propTypes = { title: PropTypes.string.isRequired, list: PropTypes.array, - notifyChange: PropTypes.func + notifyChange: PropTypes.func, + deleteListItem: PropTypes.func } export default DNSOverrideList diff --git a/frontend/src/views/DNS/DNSOverride.js b/frontend/src/views/DNS/DNSOverride.js index 85bda6ade..91932bbd4 100644 --- a/frontend/src/views/DNS/DNSOverride.js +++ b/frontend/src/views/DNS/DNSOverride.js @@ -58,6 +58,17 @@ const DNSBlock = (props) => { refreshConfig() } + const deleteListItem = async (item) => { + blockAPI + .deleteOverride(item) + .then((res) => { + notifyChange('config') + }) + .catch((error) => { + context.error('API Failure: ' + error.message) + }) + } + if (!enabled) { return } @@ -74,6 +85,7 @@ const DNSBlock = (props) => { list={BlockDomains} title="Block Custom Domain" notifyChange={notifyChange} + deleteListItem={deleteListItem} renderHeader={() => ( { list={PermitDomains} title="Permit Domain Override" notifyChange={notifyChange} + deleteListItem={deleteListItem} renderHeader={() => (