1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Desktop: In config screen, click on a plugin name to open its home page

This commit is contained in:
Laurent Cozic
2021-01-24 18:20:00 +00:00
parent a320e113ac
commit 351a05fb0d
2 changed files with 20 additions and 2 deletions

View File

@ -1,9 +1,11 @@
import * as React from 'react'; import * as React from 'react';
import { useCallback } from 'react';
import { _ } from '@joplin/lib/locale'; import { _ } from '@joplin/lib/locale';
import styled from 'styled-components'; import styled from 'styled-components';
import ToggleButton from '../../../lib/ToggleButton/ToggleButton'; import ToggleButton from '../../../lib/ToggleButton/ToggleButton';
import Button, { ButtonLevel } from '../../../Button/Button'; import Button, { ButtonLevel } from '../../../Button/Button';
import { PluginManifest } from '@joplin/lib/services/plugins/utils/types'; import { PluginManifest } from '@joplin/lib/services/plugins/utils/types';
import bridge from '../../../../services/bridge';
export enum InstallState { export enum InstallState {
NotInstalled = 1, NotInstalled = 1,
@ -40,6 +42,7 @@ function manifestToItem(manifest: PluginManifest): PluginItem {
deleted: false, deleted: false,
devMode: false, devMode: false,
hasBeenUpdated: false, hasBeenUpdated: false,
homepage_url: manifest.homepage_url,
}; };
} }
@ -52,6 +55,7 @@ export interface PluginItem {
deleted: boolean; deleted: boolean;
devMode: boolean; devMode: boolean;
hasBeenUpdated: boolean; hasBeenUpdated: boolean;
homepage_url: string;
} }
const CellRoot = styled.div` const CellRoot = styled.div`
@ -95,7 +99,7 @@ const DevModeLabel = styled.div`
color: ${props => props.theme.color}; color: ${props => props.theme.color};
`; `;
const StyledName = styled.div` const StyledNameAndVersion = styled.div`
font-family: ${props => props.theme.fontFamily}; font-family: ${props => props.theme.fontFamily};
color: ${props => props.theme.color}; color: ${props => props.theme.color};
font-size: ${props => props.theme.fontSize}px; font-size: ${props => props.theme.fontSize}px;
@ -104,6 +108,14 @@ const StyledName = styled.div`
flex: 1; flex: 1;
`; `;
const StyledName = styled.a`
color: ${props => props.theme.color};
&:hover {
text-decoration: underline;
}
`;
const StyledVersion = styled.span` const StyledVersion = styled.span`
color: ${props => props.theme.colorFaded}; color: ${props => props.theme.colorFaded};
font-size: ${props => props.theme.fontSize * 0.9}px; font-size: ${props => props.theme.fontSize * 0.9}px;
@ -119,6 +131,11 @@ const StyledDescription = styled.div`
export default function(props: Props) { export default function(props: Props) {
const item = props.item ? props.item : manifestToItem(props.manifest); const item = props.item ? props.item : manifestToItem(props.manifest);
const onNameClick = useCallback(() => {
if (!props.item.homepage_url) return;
bridge().openExternal(props.item.homepage_url);
}, [props.item]);
// For plugins in dev mode things like enabling/disabling or // For plugins in dev mode things like enabling/disabling or
// uninstalling them doesn't make sense, as that should be done by // uninstalling them doesn't make sense, as that should be done by
// adding/removing them from wherever they were loaded from. // adding/removing them from wherever they were loaded from.
@ -190,7 +207,7 @@ export default function(props: Props) {
return ( return (
<CellRoot> <CellRoot>
<CellTop> <CellTop>
<StyledName mb={'5px'}><span style={{ marginRight: 5 }}>{item.name} {item.deleted ? '(Deleted)' : ''}</span><StyledVersion>v{item.version}</StyledVersion></StyledName> <StyledNameAndVersion mb={'5px'}><StyledName onClick={onNameClick} href="#" style={{ marginRight: 5 }}>{item.name} {item.deleted ? _('(%s)', 'Deleted') : ''}</StyledName><StyledVersion>v{item.version}</StyledVersion></StyledNameAndVersion>
{renderToggleButton()} {renderToggleButton()}
</CellTop> </CellTop>
<CellContent> <CellContent>

View File

@ -71,6 +71,7 @@ function usePluginItems(plugins: Plugins, settings: PluginSettings): PluginItem[
deleted: setting.deleted, deleted: setting.deleted,
devMode: plugin.devMode, devMode: plugin.devMode,
hasBeenUpdated: setting.hasBeenUpdated, hasBeenUpdated: setting.hasBeenUpdated,
homepage_url: plugin.manifest.homepage_url,
}); });
} }