Skip to content

Commit

Permalink
feat: add indexers site hyperlink (#2061)
Browse files Browse the repository at this point in the history
* Feature: add indexers site hyperlink

* Fix: add an option taget on settings, change color to grey
  • Loading branch information
hillaliy authored May 25, 2024
1 parent dfe7b0d commit 68ff84c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
5 changes: 4 additions & 1 deletion public/locales/en/modules/indexer-manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"name": "Indexer manager status",
"description": "Status about your indexers",
"settings": {
"title": "Indexer manager status"
"title": "Indexer manager status",
"openIndexerSiteInNewTab": {
"label": "Open Indexer Site In New Tab"
}
}
},
"indexersStatus": {
Expand Down
33 changes: 27 additions & 6 deletions src/widgets/indexer-manager/IndexerManagerTile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { Button, Card, Flex, Group, ScrollArea, Text } from '@mantine/core';
import {
Anchor,
Button,
Card,
Flex,
Group,
ScrollArea,
Text,
useMantineTheme,
} from '@mantine/core';
import { IconCircleCheck, IconCircleX, IconReportSearch, IconTestPipe } from '@tabler/icons-react';
import { useSession } from 'next-auth/react';
import { useTranslation } from 'next-i18next';
Expand All @@ -12,7 +21,12 @@ import { IWidget } from '../widgets';
const definition = defineWidget({
id: 'indexer-manager',
icon: IconReportSearch,
options: {},
options: {
openIndexerSiteInNewTab: {
type: 'switch',
defaultValue: true,
},
},
gridstack: {
minWidth: 1,
minHeight: 1,
Expand All @@ -30,6 +44,7 @@ interface IndexerManagerWidgetProps {

function IndexerManagerWidgetTile({ widget }: IndexerManagerWidgetProps) {
const { t } = useTranslation('modules/indexer-manager');
const mantineTheme = useMantineTheme();
const { data: sessionData } = useSession();
const { name: configName } = useConfigContext();
const utils = api.useUtils();
Expand All @@ -49,7 +64,7 @@ function IndexerManagerWidgetTile({ widget }: IndexerManagerWidgetProps) {
configName: configName!,
},
{
staleTime: 1000 * 60 * 2,
refetchInterval: 1000 * 60 * 2,
}
);
if (indexersLoading || !indexersData || statusesLoading) {
Expand All @@ -63,9 +78,15 @@ function IndexerManagerWidgetTile({ widget }: IndexerManagerWidgetProps) {
<ScrollArea h="100%">
{indexersData.map((indexer: any) => (
<Group key={indexer.id} position="apart">
<Text color="dimmed" align="center" size="xs">
{indexer.name}
</Text>
<Anchor
href={indexer.indexerUrls[0]}
target={widget.properties.openIndexerSiteInNewTab ? '_blank' : '_self'}
c={mantineTheme.colorScheme === 'dark' ? 'gray.3' : 'gray.8'}
>
<Text color="dimmed" align="center" size="xs">
{indexer.name}
</Text>
</Anchor>
{!statusesData.find((status: any) => indexer.id === status.indexerId) &&
indexer.enable ? (
<IconCircleCheck color="#2ecc71" />
Expand Down

0 comments on commit 68ff84c

Please sign in to comment.