@goodandready/dsh-cron 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +36 -8
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -129,8 +129,27 @@ window.__ModuleLoader__.load({
|
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
function startNewSession(ctx) {
|
|
133
|
+
if (ctx) {
|
|
134
|
+
const uiWorkspace = typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : ctx.uiWorkspace;
|
|
135
|
+
if (uiWorkspace && typeof uiWorkspace.startSession === 'function') {
|
|
136
|
+
uiWorkspace.startSession();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const sessions = typeof ctx.get === 'function' ? ctx.get('sessions') : ctx.sessions;
|
|
140
|
+
if (sessions && typeof sessions.create === 'function') {
|
|
141
|
+
sessions.create({}).then((sessionId) => {
|
|
142
|
+
if (sessions.open) sessions.open(sessionId);
|
|
143
|
+
}).catch(() => {});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const btn = nativeButton();
|
|
148
|
+
if (btn) btn.click();
|
|
149
|
+
}
|
|
150
|
+
|
|
132
151
|
function CronScreen(props) {
|
|
133
|
-
const { toggle, onClose } = props;
|
|
152
|
+
const { ctx, toggle, onClose } = props;
|
|
134
153
|
const [tab, setTab] = React.useState('all');
|
|
135
154
|
const [query, setQuery] = React.useState('');
|
|
136
155
|
const [tasks, setTasks] = React.useState([]);
|
|
@@ -225,13 +244,24 @@ window.__ModuleLoader__.load({
|
|
|
225
244
|
setDropdownOpen(false);
|
|
226
245
|
if (onClose) onClose();
|
|
227
246
|
else toggle.set(false);
|
|
228
|
-
|
|
229
|
-
|
|
247
|
+
|
|
248
|
+
startNewSession(ctx);
|
|
249
|
+
|
|
250
|
+
const promptText = 'Помоги мне настроить новую запланированную задачу cron: ';
|
|
251
|
+
let attempts = 0;
|
|
252
|
+
const fillTextarea = () => {
|
|
253
|
+
const textarea = document.querySelector('textarea[placeholder*="message"], textarea[class*="prompt"], textarea[placeholder*="сообщение"], textarea[placeholder*="спросить"]');
|
|
230
254
|
if (textarea) {
|
|
231
|
-
textarea.value =
|
|
255
|
+
textarea.value = promptText;
|
|
256
|
+
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
|
232
257
|
textarea.focus();
|
|
258
|
+
textarea.setSelectionRange(promptText.length, promptText.length);
|
|
259
|
+
} else if (attempts < 10) {
|
|
260
|
+
attempts++;
|
|
261
|
+
setTimeout(fillTextarea, 150);
|
|
233
262
|
}
|
|
234
|
-
}
|
|
263
|
+
};
|
|
264
|
+
setTimeout(fillTextarea, 100);
|
|
235
265
|
};
|
|
236
266
|
|
|
237
267
|
return React.createElement('div', { className: 'dsh-cron-overlay' },
|
|
@@ -552,13 +582,11 @@ window.__ModuleLoader__.load({
|
|
|
552
582
|
ensureStyles();
|
|
553
583
|
const toggle = createToggle();
|
|
554
584
|
|
|
555
|
-
// Карточка в Настройках -> Плагины
|
|
556
585
|
const cardSlot = registerFirst(ctx, [
|
|
557
586
|
{ name: 'settings.plugin.item', key: NS, inject: () => ({ ctx, toggle }) },
|
|
558
587
|
{ name: 'settings.section', id: '@goodandready/dsh-cron', order: 34, label: () => 'Cron Задачи', inject: () => ({ ctx, toggle }) }
|
|
559
588
|
], CronSettingsCard);
|
|
560
589
|
|
|
561
|
-
// Чип в шапке диалога
|
|
562
590
|
const chipSlot = registerFirst(ctx, [
|
|
563
591
|
{ name: 'conversation.session.header.utilities', id: '@goodandready/dsh-cron.chip', order: 27, inject: () => ({ ctx, toggle }) }
|
|
564
592
|
], () => React.createElement('button', {
|
|
@@ -583,4 +611,4 @@ window.__ModuleLoader__.load({
|
|
|
583
611
|
module.exports = { apply, inject: ['slots', 'locale', 'settingsScope'] };
|
|
584
612
|
return module.exports;
|
|
585
613
|
}
|
|
586
|
-
});
|
|
614
|
+
});
|