Skip to content

Commit

Permalink
Added button to clear "updatable" adapters if nothing shown
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Dec 8, 2024
1 parent 752d5ce commit 8808e77
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 150 deletions.
186 changes: 75 additions & 111 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/adapter-react-v5/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"ra_Add objects tree from JSON file": "Objektbaum aus JSON-Datei hinzufügen",
"ra_Add row": "Zeile hinzufügen",
"ra_Advanced options": "Erweiterte Optionen",
"ra_All items are filtered out": "Alle Elemente werden herausgefiltert",
"ra_All items are filtered out": "Alle Elemente sind herausgefiltert",
"ra_All objects": "Alle Objekte",
"ra_Append": "Anhängen",
"ra_Append %s entries or replace existing?": "%s Einträge anhängen oder vorhandene ersetzen?",
Expand Down Expand Up @@ -447,4 +447,4 @@
"sch_validTo": "bis",
"sch_wholeDay": "Ganzer Tag",
"sch_yearEveryMonth": "jeden Monat"
}
}
4 changes: 2 additions & 2 deletions packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"semver": "^7.6.3"
},
"devDependencies": {
"@iobroker/build-tools": "^2.0.9",
"@iobroker/build-tools": "^2.0.11",
"@iobroker/dm-gui-components": "file:../dm-gui-components",
"@iobroker/json-config": "file:../jsonConfig",
"@iobroker/legacy-testing": "^2.0.1",
Expand All @@ -61,7 +61,7 @@
"@types/validator": "^13.12.2",
"colorette": "^2.0.20",
"less": "^4.2.1",
"puppeteer": "^23.9.0",
"puppeteer": "^23.10.1",
"src-rx": "file:src-admin",
"typescript": "^5.7.2"
},
Expand Down
67 changes: 52 additions & 15 deletions packages/admin/src-admin/src/components/Adapters/AdaptersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ import React, { Component, Fragment, type JSX } from 'react';

import {
Box,
Button,
LinearProgress,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
Tooltip,
Typography,
} from '@mui/material';

import { Update as UpdateIcon } from '@mui/icons-material';

import { TabContent } from '@iobroker/adapter-react-v5';

import type { AdaptersContext } from '@/components/Adapters/AdapterInstallDialog';
Expand Down Expand Up @@ -126,13 +130,14 @@ interface AdaptersListProps {
adapters: string[];
}[];
toggleCategory: (category: string) => void;
clearAllFilters: () => void;
clearAllFilters: (onlyUpdate?: boolean) => void;
update: boolean;
descWidth: number;
sortByName: boolean;
sortPopularFirst: boolean;
sortRecentlyUpdated: boolean;
commandRunning: boolean;
updateListFilter: boolean;
}

interface AdaptersListState {
Expand Down Expand Up @@ -281,16 +286,27 @@ class AdaptersList extends Component<AdaptersListProps, AdaptersListState> {
return !this.props.update ? (
<tr>
<td
colSpan={4}
style={{
padding: 16,
fontSize: 18,
cursor: 'pointer',
}}
title={this.props.context.t('Click to clear all filters')}
onClick={() => this.props.clearAllFilters()}
colSpan={8}
style={{ textAlign: 'center' }}
>
{this.props.context.t('all items are filtered out')}
<Button
variant="outlined"
title={this.props.context.t('Click to clear all filters')}
onClick={() => this.props.clearAllFilters()}
>
{this.props.context.t('all items are filtered out')}
</Button>
{this.props.updateListFilter ? <br /> : null}
{this.props.updateListFilter ? (
<Button
style={{ marginTop: 16 }}
variant="outlined"
onClick={() => this.props.clearAllFilters(true)}
startIcon={<UpdateIcon />}
>
{this.props.context.t('Remove filter for updatable adapters')}
</Button>
) : null}
</td>
</tr>
) : null;
Expand All @@ -308,13 +324,34 @@ class AdaptersList extends Component<AdaptersListProps, AdaptersListState> {
return !this.props.update ? (
<div
style={{
margin: 20,
fontSize: 26,
width: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
gap: 16,
}}
title={this.props.context.t('Click to clear all filters')}
onClick={() => this.props.clearAllFilters()}
>
{this.props.context.t('all items are filtered out')}
<Tooltip
title={this.props.context.t('Click to clear all filters')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
<Button
variant="outlined"
onClick={() => this.props.clearAllFilters()}
>
{this.props.context.t('all items are filtered out')}
</Button>
</Tooltip>
{this.props.updateListFilter ? (
<Button
variant="outlined"
onClick={() => this.props.clearAllFilters(true)}
startIcon={<UpdateIcon />}
>
{this.props.context.t('Remove filter for updatable adapters')}
</Button>
) : null}
</div>
) : null;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/admin/src-admin/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"All": "Alle",
"All addresses": "Alle Adressen",
"All backups older than these hours will be deleted, but only if the number of files is greater than of the files number": "Alle Sicherungen, die älter als diese Stunden sind, werden gelöscht, jedoch nur, wenn die Anzahl der Dateien größer als die Anzahl der Dateien ist",
"All items are filtered out": "Alle Elemente werden herausgefiltert",
"All items are filtered out": "Alle Elemente sind herausgefiltert",
"All objects": "Alle Objekte",
"All_group": "Alle",
"Allow automatic adapter upgrades for this repository": "Automatische Adapter-Upgrades für dieses Repository zulassen",
Expand Down Expand Up @@ -857,6 +857,7 @@
"Remove": "Entfernen",
"Remove attribute %s": "Attribut %s entfernen",
"Remove color": "Farbe entfernen",
"Remove filter for updatable adapters": "Filter für aktualisierbare Adapter entfernen",
"Remove icon": "Symbol entfernen",
"Removed": "Entfernt",
"Removing of adapter...": "Entfernen des Adapters...",
Expand Down Expand Up @@ -1238,7 +1239,7 @@
"alarm_group": "Alarm",
"alive": "aktiv",
"all": "alle",
"all items are filtered out": "Alle Elemente werden herausgefiltert",
"all items are filtered out": "Alle Elemente sind herausgefiltert",
"allow set of compact groups": "Erlaube die Einstellung von Kompaktgruppen",
"alpha": "Alpha",
"any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise info[MESSAGE] will be written": "Beliebiger Node.js-Stream. Wenn ein objectMode-Stream bereitgestellt wird, wird das gesamte Info-Objekt geschrieben. Andernfalls wird info [MESSAGE] geschrieben",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Remove",
"Remove attribute %s": "Remove attribute %s",
"Remove color": "Remove color",
"Remove filter for updatable adapters": "Remove filter for updatable adapters",
"Remove icon": "Remove icon",
"Removed": "Removed",
"Removing of adapter...": "Removing of adapter...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Eliminar",
"Remove attribute %s": "Eliminar atributo %s",
"Remove color": "Quitar color",
"Remove filter for updatable adapters": "Eliminar filtro para adaptadores actualizables",
"Remove icon": "Eliminar icono",
"Removed": "Removido",
"Removing of adapter...": "Quitar el adaptador...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Supprimer",
"Remove attribute %s": "Supprimer l'attribut %s",
"Remove color": "Supprimer la couleur",
"Remove filter for updatable adapters": "Supprimer le filtre pour les adaptateurs actualisables",
"Remove icon": "Supprimer l'icône",
"Removed": "Supprimé",
"Removing of adapter...": "Retrait de l'adaptateur...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Rimuovere",
"Remove attribute %s": "Rimuovi l'attributo %s",
"Remove color": "Rimuovi il colore",
"Remove filter for updatable adapters": "Rimuovere il filtro per gli adattatori aggiornabili",
"Remove icon": "Rimuovi icona",
"Removed": "Rimosso",
"Removing of adapter...": "Rimozione dell'adattatore...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Verwijderen",
"Remove attribute %s": "Attribuut %s verwijderen",
"Remove color": "Kleur verwijderen",
"Remove filter for updatable adapters": "Verwijder filter voor updatebare adapters",
"Remove icon": "Pictogram verwijderen",
"Removed": "verwijderd",
"Removing of adapter...": "Adapter verwijderen...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Usunąć",
"Remove attribute %s": "Usuń atrybut %s",
"Remove color": "Usuń kolor",
"Remove filter for updatable adapters": "Usuń filtr dla aktualizowalnych adapterów",
"Remove icon": "Usuń ikonę",
"Removed": "Usunięte",
"Removing of adapter...": "Usuwanie adaptera ...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Remover",
"Remove attribute %s": "Remover atributo %s",
"Remove color": "Remover cor",
"Remove filter for updatable adapters": "Remover filtro para adaptadores actualizáveis",
"Remove icon": "Remover ícone",
"Removed": "Removido",
"Removing of adapter...": "Removendo o adaptador...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "Удалить",
"Remove attribute %s": "Удалить атрибут %s",
"Remove color": "Удалить цвет",
"Remove filter for updatable adapters": "Удалить фильтр для обновляемых адаптеров",
"Remove icon": "Удалить иконку",
"Removed": "Удалено",
"Removing of adapter...": "Удаление драйвера...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "видалити",
"Remove attribute %s": "Видалити атрибут %s",
"Remove color": "Видаліть колір",
"Remove filter for updatable adapters": "Видалити фільтр для оновлюваних адаптерів",
"Remove icon": "Видалити значок",
"Removed": "Видалено",
"Removing of adapter...": "Зняття адаптера...",
Expand Down
1 change: 1 addition & 0 deletions packages/admin/src-admin/src/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@
"Remove": "去掉",
"Remove attribute %s": "删除属性 %s",
"Remove color": "去除颜色",
"Remove filter for updatable adapters": "Remove filter for updatable adapters",
"Remove icon": "删除图标",
"Removed": "删除",
"Removing of adapter...": "删除插件...",
Expand Down
44 changes: 27 additions & 17 deletions packages/admin/src-admin/src/tabs/Adapters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1325,23 +1325,32 @@ class Adapters extends AdapterInstallDialog<AdaptersProps, AdaptersState> {
}, 200);
};

clearAllFilters(): void {
(((window as any)._localStorage as Storage) || window.localStorage).removeItem('Adapter.search');
(((window as any)._localStorage as Storage) || window.localStorage).removeItem('Adapters.installedList');
(((window as any)._localStorage as Storage) || window.localStorage).removeItem('Adapters.updateList');
if (this.inputRef.current) {
this.inputRef.current.value = '';
clearAllFilters(onlyUpdate?: boolean): void {
if (onlyUpdate) {
(((window as any)._localStorage as Storage) || window.localStorage).removeItem('Adapters.updateList');
this.setState(
{
updateList: false,
},
() => this.filterAdapters(),
);
} else {
(((window as any)._localStorage as Storage) || window.localStorage).removeItem('Adapter.search');
(((window as any)._localStorage as Storage) || window.localStorage).removeItem('Adapters.installedList');
if (this.inputRef.current) {
this.inputRef.current.value = '';
}
this.setState(
{
filteredList: null,
updateList: false,
filterConnectionType: false,
installedList: 0,
search: '',
},
() => this.filterAdapters(),
);
}
this.setState(
{
filteredList: null,
updateList: false,
filterConnectionType: false,
installedList: 0,
search: '',
},
() => this.filterAdapters(),
);
}

getContext(descHidden: boolean): AdaptersContext {
Expand Down Expand Up @@ -2053,12 +2062,13 @@ class Adapters extends AdapterInstallDialog<AdaptersProps, AdaptersState> {
tableViewMode={this.state.tableViewMode}
oneListView={this.state.oneListView}
update={this.state.update}
updateListFilter={this.state.updateList}
cachedAdapters={this.cache.adapters}
categories={this.state.categories}
categoriesExpanded={this.state.categoriesExpanded}
listOfVisibleAdapter={this.cache.listOfVisibleAdapter}
toggleCategory={category => this.toggleCategory(category)}
clearAllFilters={() => this.clearAllFilters()}
clearAllFilters={(onlyUpdate?: boolean) => this.clearAllFilters(onlyUpdate)}
descWidth={this.state.descWidth}
sortByName={this.state.filterTiles === 'Name A-Z'}
sortPopularFirst={context.sortPopularFirst}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ class ConfigTable extends ConfigGeneric<ConfigTableProps, ConfigTableState> {
) : null}
</TableContainer>
{schema.help ? (
<FormHelperText>
<FormHelperText style={{ paddingLeft: 16 }}>
{this.renderHelp(
this.props.schema.help,
this.props.schema.helpLink,
Expand Down

0 comments on commit 8808e77

Please sign in to comment.