Skip to content

Commit

Permalink
Fixed ch cn (#2873)
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox authored Dec 21, 2024
1 parent 6bd5a2c commit ac69a28
Show file tree
Hide file tree
Showing 40 changed files with 220 additions and 99 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ The icons may not be reused in other projects without the proper flaticon licens
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**

- (@GermanBluefox) Show latest/stable labels by updating/downgrading of adapters
- (@GermanBluefox) Corrected selection of chinese language

### 7.4.7 (2024-12-12)

- (@GermanBluefox) Corrected the rendering of custom JSON config components
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/adapter-react-v5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you want to create the configuration page with ReactJS:
- Change `name` from `src` to `ADAPTERNAME-admin` (Of course replace `ADAPTERNAME` with yours)
- Add to devDependencies:
```json
"@iobroker/adapter-react-v5": "^7.4.6",
"@iobroker/adapter-react-v5": "^7.4.7",
```
Versions can be higher.
So your `src/package.json` should look like:
Expand All @@ -24,7 +24,7 @@ If you want to create the configuration page with ReactJS:
"version": "0.1.0",
"private": true,
"dependencies": {
"@iobroker/adapter-react-v5": "^7.4.6",
"@iobroker/adapter-react-v5": "^7.4.7",
"@iobroker/build-tools": "^1.0.0",
"babel-eslint": "^10.1.0",
"react-scripts": "^5.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@
}
]
],
"version": "7.4.6"
"version": "7.4.7"
}
10 changes: 5 additions & 5 deletions packages/admin/src-admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ import HostSelectors from './components/HostSelectors';
import ExpertModeDialog from './dialogs/ExpertModeDialog';
import NewsAdminDialog, { checkMessages, type DbType, type ShowMessage } from './dialogs/NewsAdminDialog';
import HostWarningDialog from './dialogs/HostWarningDialog';
import LogsWorker from './Workers/LogsWorker';
import InstancesWorker from './Workers/InstancesWorker';
import HostsWorker, { type HostEvent, type NotificationAnswer } from './Workers/HostsWorker';
import AdaptersWorker, { type AdapterEvent } from './Workers/AdaptersWorker';
import ObjectsWorker from './Workers/ObjectsWorker';
import { LogsWorker } from './Workers/LogsWorker';
import { InstancesWorker } from './Workers/InstancesWorker';
import { HostsWorker, type HostEvent, type NotificationAnswer } from './Workers/HostsWorker';
import { AdaptersWorker, type AdapterEvent } from './Workers/AdaptersWorker';
import { ObjectsWorker } from './Workers/ObjectsWorker';
import DiscoveryDialog from './dialogs/DiscoveryDialog';
import SlowConnectionWarningDialog, { SlowConnectionWarningDialogClass } from './dialogs/SlowConnectionWarningDialog';
import IsVisible from './components/IsVisible';
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src-admin/src/Workers/AdaptersWorker.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type AdminConnection } from '@iobroker/adapter-react-v5';
import GenericWorker, { type EventType, type GenericEvent } from './GenericWorker';
import { GenericWorker, type EventType, type GenericEvent } from './GenericWorker';

export type AdapterEventType = EventType;

export type AdapterEvent = GenericEvent<'adapter'>;

export default class AdaptersWorker extends GenericWorker<'adapter'> {
export class AdaptersWorker extends GenericWorker<'adapter'> {
private readonly repositoryHandlers: (() => void)[];

private repoTimer: ReturnType<typeof setTimeout> | null;
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src-admin/src/Workers/GenericWorker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export type GenericEvent<T extends ioBroker.ObjectType> = {
oldObj?: GetObjectFromType<T>;
};

export default class GenericWorker<T extends ioBroker.ObjectType> {
export class GenericWorker<T extends ioBroker.ObjectType> {
protected readonly socket: AdminConnection;

protected readonly handlers: ((events: GenericEvent<T>[]) => void)[] = [];
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src-admin/src/Workers/HostAdapterWorker.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type AdminConnection } from '@iobroker/adapter-react-v5';
import GenericWorker, { type EventType, type GenericEvent } from './GenericWorker';
import { GenericWorker, type EventType, type GenericEvent } from './GenericWorker';

export type HostAdapterEventType = EventType;

export type HostAdapterEvent = GenericEvent<'adapter'>;

export default class HostAdapterWorker extends GenericWorker<'adapter'> {
export class HostAdapterWorker extends GenericWorker<'adapter'> {
private readonly host: string;
private readonly prefix: string;

Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src-admin/src/Workers/HostsWorker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AdminConnection } from '@iobroker/adapter-react-v5';
import type { FilteredNotificationInformation } from '@iobroker/socket-client';
import GenericWorker, { type EventType, type GenericEvent } from './GenericWorker';
import { GenericWorker, type EventType, type GenericEvent } from './GenericWorker';

export type HostEventType = EventType;

Expand All @@ -14,7 +14,7 @@ export interface HostAliveEvent {
type: HostEventType;
}

export default class HostsWorker extends GenericWorker<'host'> {
export class HostsWorker extends GenericWorker<'host'> {
private readonly aliveHandlers: (((events: HostAliveEvent[]) => void) | false)[] = [];

private readonly notificationsHandlers: ((notifications: Record<string, NotificationAnswer>) => void)[] = [];
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src-admin/src/Workers/InstancesWorker.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type AdminConnection } from '@iobroker/adapter-react-v5';
import GenericWorker, { type EventType, type GenericEvent } from './GenericWorker';
import { GenericWorker, type EventType, type GenericEvent } from './GenericWorker';

export type InstanceEventType = EventType;

export type InstanceEvent = GenericEvent<'instance'>;

export default class InstancesWorker extends GenericWorker<'instance'> {
export class InstancesWorker extends GenericWorker<'instance'> {
constructor(socket: AdminConnection) {
super(socket, 'system.adapter', 'instance');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src-admin/src/Workers/LogsWorker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface LogLineSaved extends LogLine {
key?: number;
}

export default class LogsWorker {
export class LogsWorker {
private readonly socket: AdminConnection;

private readonly handlers: ((events: LogLineSaved[], messageSize: number) => void)[];
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src-admin/src/Workers/ObjectsWorker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ObjectEvent {
oldObj?: ioBroker.Object;
}

export default class ObjectsWorker {
export class ObjectsWorker {
private readonly socket: AdminConnection;

private readonly handlers: ((events: ObjectEvent[]) => void)[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import AdapterInstallDialog, {
import AutoUpgradeConfigDialog, { ICONS } from '@/dialogs/AutoUpgradeConfigDialog';

import IsVisible from '../IsVisible';
import { extractUrlLink } from './Utils';
import { extractUrlLink, type RepoInfo } from './Utils';
import sentryIcon from '../../assets/sentry.svg';

export const genericStyles: Record<string, any> = {
Expand Down Expand Up @@ -136,7 +136,12 @@ export const genericStyles: Record<string, any> = {
fontWeight: 'bold',
marginLeft: '4px',
}),
repoVersionText: (theme: IobTheme) => ({
repoStableVersionText: (theme: IobTheme) => ({
color: theme.palette.mode === 'dark' ? '#8dff7a' : '#2b9800',
fontWeight: 'bold',
marginLeft: '4px',
}),
repoLatestVersionText: (theme: IobTheme) => ({
color: theme.palette.mode === 'dark' ? '#a3fcff' : '#005498',
fontWeight: 'bold',
marginLeft: '4px',
Expand Down Expand Up @@ -676,6 +681,7 @@ export default abstract class AdapterGeneric<
onUpdate={version =>
this.setState({ showUpdateDialog: false, showDialog: false }, () => this.update(version))
}
isStable={(this.props.context.repository._repoInfo as unknown as RepoInfo).stable}
onIgnore={ignoreVersion =>
this.setState({ showUpdateDialog: false, showDialog: false }, () =>
this.props.context.socket
Expand Down Expand Up @@ -724,8 +730,16 @@ export default abstract class AdapterGeneric<
if (!this.state.showInstallVersion) {
return null;
}

const repoVersion = this.props.context.repository[this.props.adapterName]?.version;
let stableVersion: string;
let latestVersion: string;
const repoInfo: RepoInfo = this.props.context.repository._repoInfo as unknown as RepoInfo;
if (repoInfo?.stable) {
stableVersion = this.props.context.repository[this.props.adapterName]?.version;
latestVersion = this.props.context.repository[this.props.adapterName]?.latestVersion;
} else {
stableVersion = this.props.context.repository[this.props.adapterName]?.stable;
latestVersion = this.props.context.repository[this.props.adapterName]?.version;
}

return (
<CustomModal
Expand Down Expand Up @@ -838,11 +852,19 @@ export default abstract class AdapterGeneric<
sx={this.styles.currentVersionText}
>{`(${this.props.context.t('current')})`}</Box>
) : null}
{repoVersion === version ? (
{latestVersion === version ? (
<Box
component="span"
sx={this.styles.repoLatestVersionText}
>
(latest)
</Box>
) : null}
{stableVersion === version ? (
<Box
component="span"
sx={this.styles.repoVersionText}
>{`(${this.props.context.t('repository')})`}</Box>
sx={this.styles.repoStableVersionText}
>{`(${this.props.context.t('stable')})`}</Box>
) : null}
</Typography>
<Typography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { checkCondition, type CompactInstanceInfo } from '@/dialogs/AdapterUpdat
import AddInstanceDialog, { type AdapterDependencies } from '@/dialogs/AddInstanceDialog';
import LicenseDialog from '@/dialogs/LicenseDialog';
// import type { AdapterInformation } from '@iobroker/js-controller-common-db/build/esm/lib/common/tools';
import type InstancesWorker from '@/Workers/InstancesWorker';
import type HostsWorker from '@/Workers/HostsWorker';
import type { InstancesWorker } from '@/Workers/InstancesWorker';
import type { HostsWorker } from '@/Workers/HostsWorker';
import type { RatingDialogRepository } from '@/dialogs/RatingDialog';
import type HostAdapterWorker from '@/Workers/HostAdapterWorker';
import type { HostAdapterWorker } from '@/Workers/HostAdapterWorker';
import { extractUrlLink, type RepoAdapterObject } from './Utils';

// TODO: Placed here from @iobroker/js-controller-common-db/build/esm/lib/common/tools
Expand Down
46 changes: 28 additions & 18 deletions packages/admin/src-admin/src/components/Adapters/AdaptersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ interface AdaptersListProps {
sortRecentlyUpdated: boolean;
commandRunning: boolean;
updateListFilter: boolean;
/** Filter as string */
searchFilter: string;
/** Filter: show only installed */
installedListFilter: number;
}

interface AdaptersListState {
Expand Down Expand Up @@ -289,14 +293,18 @@ class AdaptersList extends Component<AdaptersListProps, AdaptersListState> {
colSpan={8}
style={{ textAlign: 'center' }}
>
<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.searchFilter || this.props.installedListFilter ? (
<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>
) : null}
{this.props.updateListFilter && (this.props.searchFilter || this.props.installedListFilter) ? (
<br />
) : null}
{this.props.updateListFilter ? (
<Button
style={{ marginTop: 16 }}
Expand Down Expand Up @@ -332,17 +340,19 @@ class AdaptersList extends Component<AdaptersListProps, AdaptersListState> {
gap: 16,
}}
>
<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.searchFilter || this.props.installedListFilter ? (
<Tooltip
title={this.props.context.t('Click to clear all filters')}
slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
>
{this.props.context.t('all items are filtered out')}
</Button>
</Tooltip>
<Button
variant="outlined"
onClick={() => this.props.clearAllFilters()}
>
{this.props.context.t('all items are filtered out')}
</Button>
</Tooltip>
) : null}
{this.props.updateListFilter ? (
<Button
variant="outlined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { I18n, type IobTheme, Utils } from '@iobroker/adapter-react-v5';

import type { AdapterRatingInfo, InstalledInfo } from '@/components/Adapters/AdapterInstallDialog';
import { checkCondition } from '@/dialogs/AdapterUpdateDialog';
import type { RepoAdapterObject } from '@/components/Adapters/Utils';
import type { RepoAdapterObject, RepoInfo } from '@/components/Adapters/Utils';

interface GetNewsResultEntry {
version: string;
Expand Down Expand Up @@ -88,6 +88,16 @@ const styles: Record<string, any> = {
fontWeight: 'bold',
color: theme.palette.mode === 'dark' ? 'black' : 'white',
}),
repoStableVersionText: (theme: IobTheme) => ({
color: theme.palette.mode === 'dark' ? '#8dff7a' : '#2b9800',
fontWeight: 'bold',
marginLeft: '4px',
}),
repoLatestVersionText: (theme: IobTheme) => ({
color: theme.palette.mode === 'dark' ? '#a3fcff' : '#005498',
fontWeight: 'bold',
marginLeft: '4px',
}),
};

interface AdaptersUpdaterProps {
Expand Down Expand Up @@ -333,6 +343,17 @@ class AdaptersUpdater extends Component<AdaptersUpdaterProps, AdaptersUpdaterSta
fromVersion = fromVersion || installed.version;
const result: JSX.Element[] = [];

let stableVersion: string;
let latestVersion: string;
const repoInfo: RepoInfo = this.props.repository._repoInfo as unknown as RepoInfo;
if (repoInfo?.stable) {
stableVersion = this.props.repository[adapter]?.version;
latestVersion = this.props.repository[adapter]?.latestVersion;
} else {
stableVersion = this.props.repository[adapter]?.stable;
latestVersion = this.props.repository[adapter]?.version;
}

if (installed && adapterObj?.news) {
Object.keys(adapterObj.news).forEach(version => {
try {
Expand All @@ -355,7 +376,23 @@ class AdaptersUpdater extends Component<AdaptersUpdaterProps, AdaptersUpdaterSta

result.push(
<Grid2 key={version}>
<Typography sx={styles.versionHeader}>{version}</Typography>
<Typography sx={styles.versionHeader}>
{version}
{latestVersion === version ? (
<Box
component="span"
sx={styles.repoLatestVersionText}
>
(latest)
</Box>
) : null}
{stableVersion === version ? (
<Box
component="span"
sx={styles.repoStableVersionText}
>{`(${I18n.t('stable')})`}</Box>
) : null}
</Typography>
{news.map((value, index) => (
<Typography
key={`${version}-${index}`}
Expand Down
13 changes: 13 additions & 0 deletions packages/admin/src-admin/src/components/Adapters/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export interface RepoInfo {
stable?: boolean;
name?: ioBroker.Translated;
repoTime: string;
recommendedVersions?: {
nodeJsAccepted: number[];
nodeJsRecommended: number;
npmRecommended: number;
};
}

export interface RepoAdapterObject extends ioBroker.AdapterCommon {
versionDate: string;
controller?: boolean;
Expand All @@ -8,6 +19,8 @@ export interface RepoAdapterObject extends ioBroker.AdapterCommon {
allowAdapterDelete?: boolean;
allowAdapterReadme?: boolean;
allowAdapterRating?: boolean;
stable?: string;
latestVersion?: string;
}

export function extractUrlLink(adapterRepo: RepoAdapterObject): string {
Expand Down
Loading

0 comments on commit ac69a28

Please sign in to comment.