Skip to content

Commit 4adad1a

Browse files
slack: dismissable error/offline indicator (#1371)
1 parent 75582c3 commit 4adad1a

6 files changed

Lines changed: 72 additions & 3 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Add: Jupyter dataframes align cells right
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Add: Dismissable slack offline indicator instead of an error banner on every page.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Doc: Jupyter improved example for docs

znai-docs/znai/release-notes/2025.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.82
2+
3+
:include-markdowns: 1.82
4+
15
# 1.81.1
26

37
:include-markdowns: 1.81.1

znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,31 @@
7373
.theme-znai-dark .znai-highlight-bubble-resolve-wrapper {
7474
border-right: 1px solid rgba(255, 255, 255, 0.1);
7575
}
76+
77+
.znai-slack-connection-indicator {
78+
position: fixed;
79+
top: 16px;
80+
right: 16px;
81+
z-index: 10000;
82+
}
83+
84+
.znai-slack-connection-content {
85+
display: flex;
86+
align-items: center;
87+
gap: 8px;
88+
background: rgba(255, 152, 0, 0.15);
89+
border: 1px solid rgba(255, 152, 0, 0.4);
90+
border-radius: 4px;
91+
padding: 8px 12px;
92+
font-size: 13px;
93+
}
94+
95+
.znai-slack-connection-close {
96+
background: none;
97+
border: none;
98+
color: rgba(255, 152, 0, 0.8);
99+
cursor: pointer;
100+
font-size: 16px;
101+
padding: 0;
102+
margin-left: 4px;
103+
}

znai-reactjs/src/doc-elements/text-selection/SlackActiveQuestions.tsx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import { HighlightedText } from "./HighlightedText";
2222
import { TocItem } from "../../structure/TocItem";
2323

2424
import { ResolveQuestionButton } from "./ResolveQuestionButton";
25-
import "./SlackActiveQuestions.css";
2625
import { removeTrailingSlashFromQueryParam } from "./queryParamUtils";
2726

27+
import "./SlackActiveQuestions.css";
28+
2829
interface Question {
2930
id: string;
3031
selectedText: string;
@@ -37,9 +38,34 @@ interface Question {
3738
resolved: boolean;
3839
}
3940

41+
let slackConnectionDismissed = false;
42+
43+
function SlackConnectionIndicator({ onDismiss }: { onDismiss: () => void }) {
44+
const handleDismiss = () => {
45+
slackConnectionDismissed = true;
46+
onDismiss();
47+
};
48+
49+
return (
50+
<div className="znai-slack-connection-indicator">
51+
<div className="znai-slack-connection-content">
52+
<span className="znai-slack-connection-message">Slack conversations are offline</span>
53+
<button
54+
className="znai-slack-connection-close"
55+
onClick={handleDismiss}
56+
aria-label="Dismiss Slack connection indicator"
57+
>
58+
59+
</button>
60+
</div>
61+
</div>
62+
);
63+
}
64+
4065
export function SlackActiveQuestions({ containerNode, tocItem }: { containerNode: HTMLElement; tocItem: TocItem }) {
4166
const [questions, setQuestions] = useState<Question[]>([]);
4267
const [notification, setNotification] = useState<{ type: "success" | "error"; message: string } | null>(null);
68+
const [showConnectionIndicator, setShowConnectionIndicator] = useState(false);
4369

4470
const params = new URLSearchParams(window.location.search);
4571
const questionId = params.get("questionId") || "";
@@ -80,11 +106,18 @@ export function SlackActiveQuestions({ containerNode, tocItem }: { containerNode
80106
}));
81107
setQuestions(questions);
82108
} else {
83-
setNotification({ type: "error", message: `Failed to fetch slack questions: ${response.statusText}` });
109+
handleFetchError(`Failed to fetch slack questions: ${response.status} ${response.statusText}`);
84110
setQuestions([]);
85111
}
86112
} catch (err) {
87-
setNotification({ type: "error", message: `Failed to fetch slack questions: ${err}` });
113+
handleFetchError(`Failed to fetch slack questions: ${err}`);
114+
}
115+
}
116+
117+
function handleFetchError(errorMessage: string) {
118+
console.error(errorMessage);
119+
if (!slackConnectionDismissed) {
120+
setShowConnectionIndicator(true);
88121
}
89122
}
90123

@@ -150,6 +183,7 @@ export function SlackActiveQuestions({ containerNode, tocItem }: { containerNode
150183
return (
151184
<>
152185
{renderedQuestions}
186+
{showConnectionIndicator && <SlackConnectionIndicator onDismiss={() => setShowConnectionIndicator(false)} />}
153187
{notification && (
154188
<Notification type={notification.type} message={notification.message} onClose={() => setNotification(null)} />
155189
)}

0 commit comments

Comments
 (0)