1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Resolves #10288: Show plugin versions in settings (#10289)

This commit is contained in:
Henry Heino 2024-04-10 03:39:18 -07:00 committed by GitHub
parent d2f3252de2
commit 681d1d67f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import * as React from 'react';
import { Icon, Card, Chip } from 'react-native-paper';
import { Icon, Card, Chip, Text } from 'react-native-paper';
import { _ } from '@joplin/lib/locale';
import { Alert, Linking, View } from 'react-native';
import { Alert, Linking, TextStyle, View } from 'react-native';
import { PluginItem } from '@joplin/lib/components/shared/config/plugins/types';
import shim from '@joplin/lib/shim';
import PluginService from '@joplin/lib/services/plugins/PluginService';
@ -56,6 +56,10 @@ const onRecommendedPress = () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
const PluginIcon = (props: any) => <Icon {...props} source='puzzle'/>;
const versionTextStyle: TextStyle = {
opacity: 0.8,
};
const PluginBox: React.FC<Props> = props => {
const manifest = props.item.manifest;
const item = props.item;
@ -157,10 +161,13 @@ const PluginBox: React.FC<Props> = props => {
const updateStateIsIdle = props.updateState !== UpdateState.Idle;
const titleComponent = <>
<Text variant='titleMedium'>{manifest.name}</Text> <Text variant='bodySmall' style={versionTextStyle}>v{manifest.version}</Text>
</>;
return (
<Card style={{ margin: 8, opacity: props.isCompatible ? undefined : 0.75 }} testID='plugin-card'>
<Card.Title
title={manifest.name}
title={titleComponent}
subtitle={manifest.description}
left={PluginIcon}
/>

View File

@ -86,6 +86,9 @@ describe('PluginStates', () => {
await switchClient(0);
pluginServiceSetup();
resetRepoApi();
await mockMobilePlatform('android');
await mockRepositoryApiConstructor();
});
afterEach(async () => {
for (const pluginId of PluginService.instance().pluginIds) {
@ -137,4 +140,22 @@ describe('PluginStates', () => {
expect(await screen.queryByRole('button', backlinksToNoteQuery)).toBeNull();
}
});
it('should show the current plugin version on updatable plugins', async () => {
const abcPluginId = 'org.joplinapp.plugins.AbcSheetMusic';
const defaultPluginSettings: PluginSettings = { [abcPluginId]: defaultPluginSetting() };
const outdatedVersion = '0.0.1';
await loadMockPlugin(abcPluginId, 'ABC Sheet Music', outdatedVersion, defaultPluginSettings);
expect(PluginService.instance().plugins[abcPluginId]).toBeTruthy();
render(
<PluginStatesWrapper
initialPluginSettings={defaultPluginSettings}
/>,
);
expect(await screen.findByText('ABC Sheet Music')).toBeVisible();
expect(await screen.findByRole('button', { name: 'Update ABC Sheet Music', disabled: false })).toBeVisible();
expect(await screen.findByText(`v${outdatedVersion}`)).toBeVisible();
});
});