mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 02:11:10 +01:00
Tweak workspace settings and a bunch of small things
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
import { copyToClipboard } from '../lib/copy';
|
||||
import { getThemes } from '../lib/theme/themes';
|
||||
import { getThemeCSS } from '../lib/theme/window';
|
||||
import { useListenToTauriEvent } from './useListenToTauriEvent';
|
||||
|
||||
export function useGenerateThemeCss() {
|
||||
useListenToTauriEvent('generate_theme_css', async () => {
|
||||
const themes = await getThemes();
|
||||
const themesCss = themes.themes.map(getThemeCSS).join('\n\n');
|
||||
copyToClipboard(themesCss);
|
||||
});
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import { openUrl } from '@tauri-apps/plugin-opener';
|
||||
import { Button } from '../components/core/Button';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useListenToTauriEvent } from './useListenToTauriEvent';
|
||||
import { showToast } from '../lib/toast';
|
||||
|
||||
export function useNotificationToast() {
|
||||
const markRead = (id: string) => {
|
||||
invokeCmd('cmd_dismiss_notification', { notificationId: id }).catch(console.error);
|
||||
};
|
||||
|
||||
useListenToTauriEvent<{
|
||||
id: string;
|
||||
timestamp: string;
|
||||
message: string;
|
||||
timeout?: number | null;
|
||||
action?: null | {
|
||||
url: string;
|
||||
label: string;
|
||||
};
|
||||
}>('notification', ({ payload }) => {
|
||||
console.log('Got notification event', payload);
|
||||
const actionUrl = payload.action?.url;
|
||||
const actionLabel = payload.action?.label;
|
||||
showToast({
|
||||
id: payload.id,
|
||||
timeout: payload.timeout ?? undefined,
|
||||
message: payload.message,
|
||||
onClose: () => {
|
||||
markRead(payload.id)
|
||||
},
|
||||
action: ({ hide }) =>
|
||||
actionLabel && actionUrl ? (
|
||||
<Button
|
||||
size="xs"
|
||||
color="secondary"
|
||||
className="mr-auto min-w-[5rem]"
|
||||
onClick={() => {
|
||||
hide();
|
||||
return openUrl(actionUrl);
|
||||
}}
|
||||
>
|
||||
{actionLabel}
|
||||
</Button>
|
||||
) : null,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import React from 'react';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { showConfirmDelete } from '../lib/confirm';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useFastMutation } from './useFastMutation';
|
||||
|
||||
export function useUninstallPlugin() {
|
||||
return useFastMutation({
|
||||
mutationKey: ['uninstall_plugin'],
|
||||
mutationFn: async ({ pluginId, name }: { pluginId: string; name: string }) => {
|
||||
const confirmed = await showConfirmDelete({
|
||||
id: 'uninstall-plugin-' + name,
|
||||
title: 'Uninstall Plugin',
|
||||
confirmText: 'Uninstall',
|
||||
description: (
|
||||
<>
|
||||
Permanently uninstall <InlineCode>{name}</InlineCode>?
|
||||
</>
|
||||
),
|
||||
});
|
||||
if (confirmed) {
|
||||
await invokeCmd('cmd_uninstall_plugin', { pluginId });
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user