Skip to content

Commit 41bc12f

Browse files
committed
Revert "Improve inline copy button with temporary "Copied" hint in details dialog"
This reverts commit 9a353a4.
1 parent 9d15615 commit 41bc12f

2 files changed

Lines changed: 10 additions & 75 deletions

File tree

src/helpers/notificationAugmentor.ts

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Notification, showDialog, Dialog } from '@jupyterlab/apputils';
22
import { Widget } from '@lumino/widgets';
3-
import { copyIcon } from '@jupyterlab/ui-components';
43

54
const MAX_VISIBLE_CHARS = 140;
65
const VIEW_DETAILS_LABEL = 'View details';
@@ -18,55 +17,25 @@ function createViewDetailsAction(fullMessage: string, dialogTitle = 'Details'):
1817
label: VIEW_DETAILS_LABEL,
1918
caption: 'Show full message',
2019
callback: async () => {
21-
const DURATION = 1200;
22-
2320
const dialogBody = new Widget();
2421
dialogBody.addClass('xircuits-notification-details');
2522

26-
const wrap = document.createElement('div');
27-
wrap.className = 'x-details-copyWrap';
28-
29-
const copyBtn = document.createElement('button');
30-
copyBtn.className = 'x-copy-icon-btn jp-Button jp-mod-minimal';
31-
copyBtn.type = 'button';
32-
copyBtn.title = 'Copy';
33-
copyBtn.setAttribute('aria-label', 'Copy');
34-
copyIcon.element({ container: copyBtn, height: '16px', width: '16px' });
35-
36-
wrap.appendChild(copyBtn);
37-
3823
const pre = document.createElement('pre');
39-
pre.className = 'x-details-pre';
4024
pre.textContent = fullMessage;
25+
dialogBody.node.appendChild(pre);
4126

42-
dialogBody.node.append(wrap, pre);
43-
44-
let timer: number | null = null;
45-
copyBtn.addEventListener('click', async () => {
46-
try {
47-
await navigator.clipboard.writeText(fullMessage);
27+
const copyButton = Dialog.createButton({ label: 'Copy' });
28+
const closeButton = Dialog.okButton({ label: 'Close' });
4829

49-
copyBtn.classList.add('is-copied');
50-
copyBtn.title = 'Copied';
51-
copyBtn.setAttribute('aria-label', 'Copied');
52-
53-
if (timer) clearTimeout(timer);
54-
timer = window.setTimeout(() => {
55-
copyBtn.classList.remove('is-copied');
56-
copyBtn.title = 'Copy';
57-
copyBtn.setAttribute('aria-label', 'Copy');
58-
timer = null;
59-
}, DURATION);
60-
} catch (err) {
61-
console.error('Copy failed', err);
62-
}
63-
});
64-
65-
await showDialog({
30+
const result = await showDialog({
6631
title: dialogTitle,
6732
body: dialogBody,
68-
buttons: [Dialog.okButton({ label: 'Close' })]
33+
buttons: [copyButton, closeButton]
6934
});
35+
36+
if (result.button.label === 'Copy') {
37+
await navigator.clipboard.writeText(fullMessage);
38+
}
7039
}
7140
};
7241
}

style/base.css

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -170,38 +170,4 @@ body.light-mode jp-button[title="Toggle Light/Dark Mode"] .sun { visibility: v
170170
margin: 0;
171171
font-family: var(--jp-code-font-family);
172172
font-size: var(--jp-code-font-size);
173-
}
174-
175-
.xircuits-notification-details { position: relative; }
176-
177-
.x-details-copyWrap {
178-
position: absolute;
179-
top: 6px;
180-
right: 6px;
181-
}
182-
183-
.x-copy-icon-btn { position: relative; }
184-
185-
.x-copy-icon-btn.is-copied::after {
186-
content: "Copied";
187-
position: absolute;
188-
top: 50%;
189-
right: calc(100% + 8px);
190-
transform: translateY(-50%);
191-
white-space: nowrap;
192-
pointer-events: none;
193-
padding: 2px 6px;
194-
background: var(--jp-layout-color2);
195-
border: 1px solid var(--jp-border-color2);
196-
border-radius: 4px;
197-
font-size: var(--jp-ui-font-size1);
198-
line-height: 1.4;
199-
z-index: 1;
200-
}
201-
202-
.xircuits-notification-details .x-details-pre {
203-
margin-top: 36px;
204-
}
205-
206-
207-
173+
}

0 commit comments

Comments
 (0)