New: (UI) Indexer privacy label

Fixes #2132
This commit is contained in:
Bogdan
2024-06-28 05:35:13 +03:00
parent 715ce1fc6c
commit 9c599a6be4
7 changed files with 67 additions and 8 deletions

View File

@@ -4,16 +4,16 @@ import TableRowCell from 'Components/Table/Cells/TableRowCell';
import TableRowButton from 'Components/Table/TableRowButton'; import TableRowButton from 'Components/Table/TableRowButton';
import { icons } from 'Helpers/Props'; import { icons } from 'Helpers/Props';
import CapabilitiesLabel from 'Indexer/Index/Table/CapabilitiesLabel'; import CapabilitiesLabel from 'Indexer/Index/Table/CapabilitiesLabel';
import PrivacyLabel from 'Indexer/Index/Table/PrivacyLabel';
import ProtocolLabel from 'Indexer/Index/Table/ProtocolLabel'; import ProtocolLabel from 'Indexer/Index/Table/ProtocolLabel';
import { IndexerCapabilities } from 'Indexer/Indexer'; import { IndexerCapabilities, IndexerPrivacy } from 'Indexer/Indexer';
import firstCharToUpper from 'Utilities/String/firstCharToUpper';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import styles from './SelectIndexerRow.css'; import styles from './SelectIndexerRow.css';
interface SelectIndexerRowProps { interface SelectIndexerRowProps {
name: string; name: string;
protocol: string; protocol: string;
privacy: string; privacy: IndexerPrivacy;
language: string; language: string;
description: string; description: string;
capabilities: IndexerCapabilities; capabilities: IndexerCapabilities;
@@ -63,7 +63,9 @@ function SelectIndexerRow(props: SelectIndexerRowProps) {
<TableRowCell>{description}</TableRowCell> <TableRowCell>{description}</TableRowCell>
<TableRowCell>{translate(firstCharToUpper(privacy))}</TableRowCell> <TableRowCell>
<PrivacyLabel privacy={privacy} />
</TableRowCell>
<TableRowCell> <TableRowCell>
<CapabilitiesLabel capabilities={capabilities} /> <CapabilitiesLabel capabilities={capabilities} />

View File

@@ -1,7 +1,6 @@
import React, { useCallback, useState } from 'react'; import React, { useCallback, useState } from 'react';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { useSelect } from 'App/SelectContext'; import { useSelect } from 'App/SelectContext';
import Label from 'Components/Label';
import IconButton from 'Components/Link/IconButton'; import IconButton from 'Components/Link/IconButton';
import RelativeDateCell from 'Components/Table/Cells/RelativeDateCell'; import RelativeDateCell from 'Components/Table/Cells/RelativeDateCell';
import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell';
@@ -15,10 +14,10 @@ import createIndexerIndexItemSelector from 'Indexer/Index/createIndexerIndexItem
import Indexer from 'Indexer/Indexer'; import Indexer from 'Indexer/Indexer';
import IndexerTitleLink from 'Indexer/IndexerTitleLink'; import IndexerTitleLink from 'Indexer/IndexerTitleLink';
import { SelectStateInputProps } from 'typings/props'; import { SelectStateInputProps } from 'typings/props';
import firstCharToUpper from 'Utilities/String/firstCharToUpper';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import CapabilitiesLabel from './CapabilitiesLabel'; import CapabilitiesLabel from './CapabilitiesLabel';
import IndexerStatusCell from './IndexerStatusCell'; import IndexerStatusCell from './IndexerStatusCell';
import PrivacyLabel from './PrivacyLabel';
import ProtocolLabel from './ProtocolLabel'; import ProtocolLabel from './ProtocolLabel';
import styles from './IndexerIndexRow.css'; import styles from './IndexerIndexRow.css';
@@ -175,7 +174,7 @@ function IndexerIndexRow(props: IndexerIndexRowProps) {
if (name === 'privacy') { if (name === 'privacy') {
return ( return (
<VirtualTableRowCell key={name} className={styles[name]}> <VirtualTableRowCell key={name} className={styles[name]}>
<Label>{translate(firstCharToUpper(privacy))}</Label> <PrivacyLabel privacy={privacy} />
</VirtualTableRowCell> </VirtualTableRowCell>
); );
} }

View File

@@ -0,0 +1,20 @@
.publicLabel {
composes: label from '~Components/Label.css';
border-color: var(--dangerColor);
background-color: var(--dangerColor);
}
.semiPrivateLabel {
composes: label from '~Components/Label.css';
border-color: var(--warningColor);
background-color: var(--warningColor);
}
.privateLabel {
composes: label from '~Components/Label.css';
border-color: var(--infoColor);
background-color: var(--infoColor);
}

View File

@@ -0,0 +1,9 @@
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
'privateLabel': string;
'publicLabel': string;
'semiPrivateLabel': string;
}
export const cssExports: CssExports;
export default cssExports;

View File

@@ -0,0 +1,20 @@
import React from 'react';
import Label from 'Components/Label';
import { IndexerPrivacy } from 'Indexer/Indexer';
import firstCharToUpper from 'Utilities/String/firstCharToUpper';
import translate from 'Utilities/String/translate';
import styles from './PrivacyLabel.css';
interface PrivacyLabelProps {
privacy: IndexerPrivacy;
}
function PrivacyLabel({ privacy }: PrivacyLabelProps) {
return (
<Label className={styles[`${privacy}Label`]}>
{translate(firstCharToUpper(privacy))}
</Label>
);
}
export default PrivacyLabel;

View File

@@ -24,6 +24,8 @@ export interface IndexerCapabilities extends ModelBase {
categories: IndexerCategory[]; categories: IndexerCategory[];
} }
export type IndexerPrivacy = 'public' | 'semiPrivate' | 'private';
export interface IndexerField extends ModelBase { export interface IndexerField extends ModelBase {
order: number; order: number;
name: string; name: string;
@@ -47,7 +49,7 @@ interface Indexer extends ModelBase {
supportsRedirect: boolean; supportsRedirect: boolean;
supportsPagination: boolean; supportsPagination: boolean;
protocol: string; protocol: string;
privacy: string; privacy: IndexerPrivacy;
priority: number; priority: number;
fields: IndexerField[]; fields: IndexerField[];
tags: number[]; tags: number[];

View File

@@ -24,6 +24,7 @@ import TagListConnector from 'Components/TagListConnector';
import { kinds } from 'Helpers/Props'; import { kinds } from 'Helpers/Props';
import DeleteIndexerModal from 'Indexer/Delete/DeleteIndexerModal'; import DeleteIndexerModal from 'Indexer/Delete/DeleteIndexerModal';
import EditIndexerModalConnector from 'Indexer/Edit/EditIndexerModalConnector'; import EditIndexerModalConnector from 'Indexer/Edit/EditIndexerModalConnector';
import PrivacyLabel from 'Indexer/Index/Table/PrivacyLabel';
import Indexer, { IndexerCapabilities } from 'Indexer/Indexer'; import Indexer, { IndexerCapabilities } from 'Indexer/Indexer';
import { createIndexerSelectorForHook } from 'Store/Selectors/createIndexerSelector'; import { createIndexerSelectorForHook } from 'Store/Selectors/createIndexerSelector';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
@@ -64,6 +65,7 @@ function IndexerInfoModalContent(props: IndexerInfoModalContentProps) {
fields, fields,
tags, tags,
protocol, protocol,
privacy,
capabilities = {} as IndexerCapabilities, capabilities = {} as IndexerCapabilities,
} = indexer as Indexer; } = indexer as Indexer;
@@ -160,6 +162,11 @@ function IndexerInfoModalContent(props: IndexerInfoModalContentProps) {
title={translate('Language')} title={translate('Language')}
data={language ?? '-'} data={language ?? '-'}
/> />
<DescriptionListItem
descriptionClassName={styles.description}
title={translate('Privacy')}
data={privacy ? <PrivacyLabel privacy={privacy} /> : '-'}
/>
{vipExpiration ? ( {vipExpiration ? (
<DescriptionListItem <DescriptionListItem
descriptionClassName={styles.description} descriptionClassName={styles.description}