@goodandready/dsh-cron 0.3.19 → 0.3.20

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.css CHANGED
@@ -13,18 +13,18 @@
13
13
  [data-pane=conversation], [class*=centerCol] {
14
14
  position: relative !important;
15
15
  }
16
- [${VIEW_ATTR}] {
16
+ [data-dsh-cron-view] {
17
17
  z-index: 60;
18
18
  background: var(--dsw-alias-bg-base);
19
19
  display: none;
20
20
  position: absolute;
21
21
  inset: 0;
22
22
  }
23
- html[${ACTIVE_ATTR}] [${VIEW_ATTR}] {
23
+ html[data-dsh-cron-active] [data-dsh-cron-view] {
24
24
  display: block !important;
25
25
  }
26
- html[${ACTIVE_ATTR}] [data-pane=conversation] > *:not([${VIEW_ATTR}]),
27
- html[${ACTIVE_ATTR}] [class*=centerCol] > *:not([${VIEW_ATTR}]) {
26
+ html[data-dsh-cron-active] [data-pane=conversation] > *:not([data-dsh-cron-view]),
27
+ html[data-dsh-cron-active] [class*=centerCol] > *:not([data-dsh-cron-view]) {
28
28
  display: none !important;
29
29
  }
30
30
 
package/lib/client.js CHANGED
@@ -470,8 +470,12 @@ const listeners = new Set();
470
470
  return {
471
471
  isOpen: () => open,
472
472
  set: (v) => {
473
- if (open === v) return;
474
- open = !!v;
473
+ const next = !!v;
474
+ if (open === next) {
475
+ for (const fn of listeners) fn(open);
476
+ return;
477
+ }
478
+ open = next;
475
479
  for (const fn of listeners) fn(open);
476
480
  },
477
481
  toggle: () => {
@@ -1328,6 +1332,12 @@ style: { padding: '6px 16px', fontSize: '12px' }
1328
1332
  function CronScreen(props) {
1329
1333
  const { ctx, toggle, onClose } = props;
1330
1334
  const t = props.t || translate;
1335
+ const [isOpen, setIsOpen] = React.useState(toggle && typeof toggle.isOpen === 'function' ? toggle.isOpen() : true);
1336
+ React.useEffect(() => {
1337
+ if (!toggle || typeof toggle.subscribe !== 'function') return;
1338
+ return toggle.subscribe((val) => setIsOpen(val));
1339
+ }, [toggle]);
1340
+ if (!isOpen) return null;
1331
1341
  const [tab, setTab] = React.useState('all');
1332
1342
  const [query, setQuery] = React.useState('');
1333
1343
  const [filterType, setFilterType] = React.useState('');
@@ -4914,7 +4924,21 @@ function mountCronScreen(ctx, toggle) {
4914
4924
  if (typeof document === 'undefined') return () => {};
4915
4925
  let root;
4916
4926
  let container;
4927
+ const teardownPanel = () => {
4928
+ if (root !== undefined) {
4929
+ try { root.unmount(); } catch (e) { /* ignore */ }
4930
+ root = undefined;
4931
+ }
4932
+ if (container !== undefined) {
4933
+ try { container.remove(); } catch (e) { /* ignore */ }
4934
+ container = undefined;
4935
+ }
4936
+ };
4917
4937
  const ensure = () => {
4938
+ if (!toggle.isOpen()) {
4939
+ teardownPanel();
4940
+ return;
4941
+ }
4918
4942
  if (container !== undefined && container.isConnected) return;
4919
4943
  const column = document.querySelector(COLUMN_SELECTOR);
4920
4944
  if (column === null) return;
@@ -4934,8 +4958,10 @@ if (toggle.isOpen()) {
4934
4958
  ensureStyles();
4935
4959
  document.documentElement.setAttribute(ACTIVE_ATTR, '');
4936
4960
  document.dispatchEvent(new CustomEvent(ACTIVATE_EVENT, { detail: PANEL }));
4961
+ ensure();
4937
4962
  } else {
4938
4963
  document.documentElement.removeAttribute(ACTIVE_ATTR);
4964
+ teardownPanel();
4939
4965
  }
4940
4966
  };
4941
4967
  const onOtherActivate = (event) => {
@@ -4959,10 +4985,7 @@ document.removeEventListener(ACTIVATE_EVENT, onOtherActivate);
4959
4985
  document.removeEventListener('click', onSidebarClick, true);
4960
4986
  unsubscribe();
4961
4987
  document.documentElement.removeAttribute(ACTIVE_ATTR);
4962
- if (root !== undefined) root.unmount();
4963
- root = undefined;
4964
- if (container !== undefined) container.remove();
4965
- container = undefined;
4988
+ teardownPanel();
4966
4989
  };
4967
4990
  }
4968
4991
  function registerIntoMount(ctx, mountName, entry, component) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-cron",
3
- "version": "0.3.19",
3
+ "version": "0.3.20",
4
4
  "description": "Background automation runner for DSH: isolated agent runs, script/HTTP/SSH/Docker runtimes, cost guard, notifications, heartbeats.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",