feat: Initial clean release of CHM
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
这个提交包含在:
@@ -0,0 +1,82 @@
|
||||
import { ItemEvent, OnPluginSettingChangeEvent } from '@joplin/lib/components/shared/config/plugins/types';
|
||||
import useOnDeleteHandler from '@joplin/lib/components/shared/config/plugins/useOnDeleteHandler';
|
||||
import useOnInstallHandler from '@joplin/lib/components/shared/config/plugins/useOnInstallHandler';
|
||||
import NavService from '@joplin/lib/services/NavService';
|
||||
import { PluginSettings, defaultPluginSetting } from '@joplin/lib/services/plugins/PluginService';
|
||||
import RepositoryApi from '@joplin/lib/services/plugins/RepositoryApi';
|
||||
import { useCallback, useMemo, useRef, useState } from 'react';
|
||||
|
||||
interface Props {
|
||||
updatePluginStates: (settingValue: PluginSettings)=> void;
|
||||
pluginSettings: PluginSettings;
|
||||
repoApi: RepositoryApi;
|
||||
}
|
||||
|
||||
export type PluginCallback = (event: ItemEvent)=> void;
|
||||
|
||||
export interface PluginCallbacks {
|
||||
onToggle: PluginCallback;
|
||||
onUpdate: PluginCallback;
|
||||
onInstall: PluginCallback;
|
||||
onDelete: PluginCallback;
|
||||
onShowPluginLog: PluginCallback;
|
||||
}
|
||||
|
||||
const usePluginCallbacks = (props: Props) => {
|
||||
const onPluginSettingsChange = useCallback((event: OnPluginSettingChangeEvent) => {
|
||||
props.updatePluginStates(event.value);
|
||||
}, [props.updatePluginStates]);
|
||||
|
||||
const updatePluginEnabled = useCallback((pluginId: string, enabled: boolean) => {
|
||||
const newSettings = { ...props.pluginSettings };
|
||||
newSettings[pluginId] = {
|
||||
...defaultPluginSetting(),
|
||||
...newSettings[pluginId],
|
||||
enabled,
|
||||
};
|
||||
|
||||
props.updatePluginStates(newSettings);
|
||||
}, [props.pluginSettings, props.updatePluginStates]);
|
||||
|
||||
const onToggle = useCallback((event: ItemEvent) => {
|
||||
const pluginId = event.item.manifest.id;
|
||||
const settings = props.pluginSettings[pluginId] ?? defaultPluginSetting();
|
||||
updatePluginEnabled(pluginId, !settings.enabled);
|
||||
}, [props.pluginSettings, updatePluginEnabled]);
|
||||
|
||||
const pluginSettingsRef = useRef(props.pluginSettings);
|
||||
pluginSettingsRef.current = props.pluginSettings;
|
||||
|
||||
const onDelete = useOnDeleteHandler(pluginSettingsRef, onPluginSettingsChange, true);
|
||||
|
||||
const [updatingPluginIds, setUpdatingPluginIds] = useState<Record<string, boolean>>({});
|
||||
const onUpdate = useOnInstallHandler(setUpdatingPluginIds, pluginSettingsRef, props.repoApi, onPluginSettingsChange, true);
|
||||
|
||||
const [installingPluginIds, setInstallingPluginIds] = useState<Record<string, boolean>>({});
|
||||
const onInstall = useOnInstallHandler(
|
||||
setInstallingPluginIds, pluginSettingsRef, props.repoApi, onPluginSettingsChange, false,
|
||||
);
|
||||
|
||||
const onShowPluginLog = useCallback((event: ItemEvent) => {
|
||||
const pluginId = event.item.manifest.id;
|
||||
void NavService.go('Log', { defaultFilter: pluginId });
|
||||
}, []);
|
||||
|
||||
const callbacks = useMemo((): PluginCallbacks => {
|
||||
return {
|
||||
onToggle,
|
||||
onDelete,
|
||||
onUpdate,
|
||||
onInstall,
|
||||
onShowPluginLog,
|
||||
};
|
||||
}, [onToggle, onDelete, onUpdate, onInstall, onShowPluginLog]);
|
||||
|
||||
return {
|
||||
callbacks,
|
||||
updatingPluginIds,
|
||||
installingPluginIds,
|
||||
};
|
||||
};
|
||||
|
||||
export default usePluginCallbacks;
|
||||
在新工单中引用
屏蔽一个用户