mirror of https://github.com/laurent22/joplin.git
Desktop: Fixed installing plugins
parent
11b8821bf4
commit
cda9441c69
|
@ -20,6 +20,10 @@ export enum UpdateState {
|
||||||
HasBeenUpdated = 4,
|
HasBeenUpdated = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ItemEvent {
|
||||||
|
item: PluginItem;
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item?: PluginItem;
|
item?: PluginItem;
|
||||||
manifest?: PluginManifest;
|
manifest?: PluginManifest;
|
||||||
|
@ -27,10 +31,10 @@ interface Props {
|
||||||
updateState?: UpdateState;
|
updateState?: UpdateState;
|
||||||
themeId: number;
|
themeId: number;
|
||||||
isCompatible: boolean;
|
isCompatible: boolean;
|
||||||
onToggle?: Function;
|
onToggle?: (event: ItemEvent)=> void;
|
||||||
onDelete?: Function;
|
onDelete?: (event: ItemEvent)=> void;
|
||||||
onInstall?: Function;
|
onInstall?: (event: ItemEvent)=> void;
|
||||||
onUpdate?: Function;
|
onUpdate?: (event: ItemEvent)=> void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function manifestToItem(manifest: PluginManifest): PluginItem {
|
function manifestToItem(manifest: PluginManifest): PluginItem {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import PluginService, { defaultPluginSetting, Plugins, PluginSetting, PluginSett
|
||||||
import { _ } from '@joplin/lib/locale';
|
import { _ } from '@joplin/lib/locale';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import SearchPlugins from './SearchPlugins';
|
import SearchPlugins from './SearchPlugins';
|
||||||
import PluginBox, { UpdateState } from './PluginBox';
|
import PluginBox, { ItemEvent, UpdateState } from './PluginBox';
|
||||||
import Button, { ButtonLevel } from '../../../Button/Button';
|
import Button, { ButtonLevel } from '../../../Button/Button';
|
||||||
import bridge from '../../../../services/bridge';
|
import bridge from '../../../../services/bridge';
|
||||||
import produce from 'immer';
|
import produce from 'immer';
|
||||||
|
@ -128,8 +128,8 @@ export default function(props: Props) {
|
||||||
};
|
};
|
||||||
}, [manifestsLoaded, pluginItems]);
|
}, [manifestsLoaded, pluginItems]);
|
||||||
|
|
||||||
const onDelete = useCallback(async (event: any) => {
|
const onDelete = useCallback(async (event: ItemEvent) => {
|
||||||
const item: PluginItem = event.item;
|
const item = event.item;
|
||||||
const confirm = await bridge().showConfirmMessageBox(_('Delete plugin "%s"?', item.manifest.name));
|
const confirm = await bridge().showConfirmMessageBox(_('Delete plugin "%s"?', item.manifest.name));
|
||||||
if (!confirm) return;
|
if (!confirm) return;
|
||||||
|
|
||||||
|
@ -141,8 +141,8 @@ export default function(props: Props) {
|
||||||
props.onChange({ value: pluginService.serializePluginSettings(newSettings) });
|
props.onChange({ value: pluginService.serializePluginSettings(newSettings) });
|
||||||
}, [pluginSettings, props.onChange]);
|
}, [pluginSettings, props.onChange]);
|
||||||
|
|
||||||
const onToggle = useCallback((event: any) => {
|
const onToggle = useCallback((event: ItemEvent) => {
|
||||||
const item: PluginItem = event.item;
|
const item = event.item;
|
||||||
|
|
||||||
const newSettings = produce(pluginSettings, (draft: PluginSettings) => {
|
const newSettings = produce(pluginSettings, (draft: PluginSettings) => {
|
||||||
if (!draft[item.manifest.id]) draft[item.manifest.id] = defaultPluginSetting();
|
if (!draft[item.manifest.id]) draft[item.manifest.id] = defaultPluginSetting();
|
||||||
|
|
|
@ -3,6 +3,7 @@ import PluginService, { defaultPluginSetting, PluginSettings } from '@joplin/lib
|
||||||
import produce from 'immer';
|
import produce from 'immer';
|
||||||
import { _ } from '@joplin/lib/locale';
|
import { _ } from '@joplin/lib/locale';
|
||||||
import Logger from '@joplin/lib/Logger';
|
import Logger from '@joplin/lib/Logger';
|
||||||
|
import { ItemEvent } from './PluginBox';
|
||||||
|
|
||||||
const logger = Logger.create('useOnInstallHandler');
|
const logger = Logger.create('useOnInstallHandler');
|
||||||
|
|
||||||
|
@ -13,8 +14,8 @@ export interface OnPluginSettingChangeEvent {
|
||||||
type OnPluginSettingChangeHandler = (event: OnPluginSettingChangeEvent)=> void;
|
type OnPluginSettingChangeHandler = (event: OnPluginSettingChangeEvent)=> void;
|
||||||
|
|
||||||
export default function(setInstallingPluginIds: Function, pluginSettings: PluginSettings, repoApi: Function, onPluginSettingsChange: OnPluginSettingChangeHandler, isUpdate: boolean) {
|
export default function(setInstallingPluginIds: Function, pluginSettings: PluginSettings, repoApi: Function, onPluginSettingsChange: OnPluginSettingChangeHandler, isUpdate: boolean) {
|
||||||
return useCallback(async (event: any) => {
|
return useCallback(async (event: ItemEvent) => {
|
||||||
const pluginId = event.item.id;
|
const pluginId = event.item.manifest.id;
|
||||||
|
|
||||||
setInstallingPluginIds((prev: any) => {
|
setInstallingPluginIds((prev: any) => {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue