Skip to content

Commit af192bd

Browse files
committed
Various fixes to message builder
1 parent c97de25 commit af192bd

13 files changed

Lines changed: 461 additions & 384 deletions

services/backend-api/client/src/components/NavigableTree/index.tsx

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ interface TreeItemProps extends PropsWithChildren {
5151
onActivate?: () => void;
5252
onEscape?: () => void;
5353
ariaLabel?: string;
54+
withoutProvider?: boolean;
5455
}
5556

5657
export const NavigableTreeItem = ({
@@ -60,6 +61,7 @@ export const NavigableTreeItem = ({
6061
onActivate,
6162
onEscape,
6263
ariaLabel,
64+
withoutProvider,
6365
}: TreeItemProps) => {
6466
const { currentSelectedId } = useNavigableTreeContext();
6567
const treeItemRef = useRef<HTMLDivElement>(null);
@@ -85,56 +87,64 @@ export const NavigableTreeItem = ({
8587
setHasGroup(!!thisHasGroup);
8688
}, [treeItemRef.current]);
8789

90+
const content = (
91+
<NavigableTreeItemContext.Consumer>
92+
{({ isExpanded, onFocused, onKeyDown, onBlurred }) => {
93+
return (
94+
<div
95+
aria-label={ariaLabel}
96+
ref={treeItemRef}
97+
role="treeitem"
98+
data-id={id}
99+
onFocus={(e) => {
100+
// const focusedElem = document.activeElement as HTMLElement;
101+
// if (focusedElem !== treeItemRef.current) {
102+
// return;
103+
// }
104+
e.stopPropagation();
105+
onFocused();
106+
}}
107+
tabIndex={tabIndex}
108+
onBlur={(e) => {
109+
e.stopPropagation();
110+
onBlurred();
111+
}}
112+
onKeyDown={(e) => {
113+
// if current div is not focused, do nothing
114+
// const focusedElem = document.activeElement as HTMLElement;
115+
// if (focusedElem !== treeItemRef.current) {
116+
// return;
117+
// }
118+
119+
// if enter or space
120+
if (e.key === "Enter" || e.key === " ") {
121+
onActivate?.();
122+
} else if (e.key === "Escape") {
123+
onEscape?.();
124+
} else {
125+
onKeyDown(e);
126+
}
127+
}}
128+
aria-selected={currentSelectedId === id}
129+
aria-expanded={hasGroup ? isExpanded : undefined}
130+
style={{
131+
outline: "none",
132+
}}
133+
>
134+
{children}
135+
</div>
136+
);
137+
}}
138+
</NavigableTreeItemContext.Consumer>
139+
);
140+
141+
if (withoutProvider) {
142+
return content;
143+
}
144+
88145
return (
89146
<NavigableTreeItemProvider id={id} isExpanded={isRootItem}>
90-
<NavigableTreeItemContext.Consumer>
91-
{({ isExpanded, onFocused, onKeyDown, onBlurred }) => {
92-
return (
93-
<div
94-
aria-label={ariaLabel}
95-
ref={treeItemRef}
96-
role="treeitem"
97-
data-id={id}
98-
onFocus={(e) => {
99-
// const focusedElem = document.activeElement as HTMLElement;
100-
// if (focusedElem !== treeItemRef.current) {
101-
// return;
102-
// }
103-
e.stopPropagation();
104-
onFocused();
105-
}}
106-
tabIndex={tabIndex}
107-
onBlur={(e) => {
108-
e.stopPropagation();
109-
onBlurred();
110-
}}
111-
onKeyDown={(e) => {
112-
// if current div is not focused, do nothing
113-
// const focusedElem = document.activeElement as HTMLElement;
114-
// if (focusedElem !== treeItemRef.current) {
115-
// return;
116-
// }
117-
118-
// if enter or space
119-
if (e.key === "Enter" || e.key === " ") {
120-
onActivate?.();
121-
} else if (e.key === "Escape") {
122-
onEscape?.();
123-
} else {
124-
onKeyDown(e);
125-
}
126-
}}
127-
aria-selected={currentSelectedId === id}
128-
aria-expanded={hasGroup ? isExpanded : undefined}
129-
style={{
130-
outline: "none",
131-
}}
132-
>
133-
{children}
134-
</div>
135-
);
136-
}}
137-
</NavigableTreeItemContext.Consumer>
147+
{content}
138148
</NavigableTreeItemProvider>
139149
);
140150
};

services/backend-api/client/src/components/PreviewerTour/index.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,21 @@ export const MESSAGE_BUILDER_TOUR_STEPS: TourStep[] = [
4343
placement: "right",
4444
offset: { x: 20, y: 0 },
4545
},
46+
{
47+
id: "selected-component",
48+
target: "[data-tour-target='selected-component']",
49+
title: "Selected Component",
50+
content:
51+
"This is your currently-selected component. You can select different components by clicking on them in the tree.\n\nThe selected component determines what you can edit in the properties panel and what add sub-component button options are available.",
52+
placement: "right",
53+
offset: { x: 20, y: 0 },
54+
},
4655
{
4756
id: "add-component-button",
4857
target: "[data-tour-target='add-component-button']",
4958
title: "Add New Components",
5059
content:
51-
"After you've selected a component, you may click here to add new components under the selected component. You can add text blocks, embeds, buttons, and more to customize how your feed messages appear.",
60+
"If the currently-selected component supports sub-components, you may click the add button next to the currently-selected component to add components under it.\n\nExamples may include text blocks, embeds, buttons, and more to customize how your feed messages appear.",
5261
placement: "bottom",
5362
offset: { x: 0, y: 20 },
5463
},
@@ -57,9 +66,9 @@ export const MESSAGE_BUILDER_TOUR_STEPS: TourStep[] = [
5766
target: "[data-tour-target='properties-panel']",
5867
title: "Component Properties",
5968
content:
60-
"When you select a component, its properties will appear here. This is where you can customize the content, styling, and behavior of each component.",
61-
placement: "left",
62-
offset: { x: -20, y: 0 },
69+
"The configurable properties of the currently-selected component will be visible in this Component Properties panel.",
70+
placement: "right",
71+
offset: { x: 20, y: 0 },
6372
},
6473
{
6574
id: "discord-preview",
@@ -297,7 +306,7 @@ const TourTooltip: React.FC<TourTooltipProps> = ({
297306
borderRadius="lg"
298307
border="4px solid"
299308
borderColor="blue.400"
300-
bg="rgba(59, 130, 246, 0.1)"
309+
bg="rgba(59, 130, 246, 0.05)"
301310
position="relative"
302311
>
303312
<motion.div
@@ -335,7 +344,7 @@ const TourTooltip: React.FC<TourTooltipProps> = ({
335344
}}
336345
>
337346
<Box
338-
bg="gray.800"
347+
bg="gray.700"
339348
color="white"
340349
p={4}
341350
borderRadius="md"

services/backend-api/client/src/contexts/PageAlertContext.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const PageAlertProvider = ({ children }: { children: ReactNode }) => {
7676
alerts,
7777
removeAlert,
7878
};
79-
}, [createErrorAlert, createSuccessAlert, createInfoAlert, alerts]);
79+
}, [createErrorAlert, createSuccessAlert, createInfoAlert, removeAlert, alerts]);
8080

8181
return <PageAlertContext.Provider value={contextValue}>{children}</PageAlertContext.Provider>;
8282
};
@@ -93,30 +93,28 @@ interface PageAlertContextOutletProps {
9393

9494
export const PageAlertContextOutlet = ({ containerProps }: PageAlertContextOutletProps) => {
9595
const { alerts, removeAlert } = usePageAlertContext();
96-
const [closedCount, setClosedCount] = useState(0);
9796

9897
const onRemoved = useCallback(
9998
(id: string) => {
100-
setClosedCount((prev) => prev + 1);
10199
removeAlert(id);
102100
},
103101
[removeAlert]
104102
);
105103

106104
return (
107105
<Stack
108-
hidden={closedCount === alerts.length}
106+
hidden={alerts.length === 0}
109107
spacing={2}
110108
position="sticky"
111109
top={0}
112110
zIndex={containerProps?.zIndex ?? 1}
113111
w="100%"
114112
{...containerProps}
115113
>
116-
{alerts.map((alert, index) => {
114+
{alerts.map((alert) => {
117115
return (
118116
<DismissableAlert
119-
key={alert.title + index.toString()}
117+
key={alert.id}
120118
status={alert.status}
121119
description={alert.description}
122120
title={alert.title}

services/backend-api/client/src/contexts/SendTestArticleContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export const SendTestArticleProvider = ({ children }: PropsWithChildren<{}>) =>
167167
<Heading size="md">
168168
{t("features.feedConnections.components.sendTestArticleButton.apiPayload")}
169169
</Heading>
170+
<Text>The configured message that was sent to Discord.</Text>
170171
<pre
171172
style={{
172173
backgroundColor: getChakraColor("gray.800"),
@@ -183,6 +184,10 @@ export const SendTestArticleProvider = ({ children }: PropsWithChildren<{}>) =>
183184
<Heading size="md">
184185
{t("features.feedConnections.components.sendTestArticleButton.apiResponse")}
185186
</Heading>
187+
<Text>
188+
The response Discord gave. This should include details on the issues that Discord
189+
is reporting with the configured message.
190+
</Text>
186191
<pre
187192
style={{
188193
backgroundColor: getChakraColor("gray.800"),

services/backend-api/client/src/pages/Previewer.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,27 @@ const PreviewerContent: React.FC = () => {
443443
</VStack>
444444
</Box>
445445
</Box>
446-
{/* Center Panel - Discord Preview and Problems */}
446+
{/* Middle Panel - Properties */}
447+
<Box
448+
minWidth={SIDE_PANEL_WIDTH}
449+
maxWidth={SIDE_PANEL_WIDTH}
450+
display={{ base: "none", lg: "block" }}
451+
>
452+
<Box
453+
bg="gray.800"
454+
borderRight="1px"
455+
borderColor="gray.600"
456+
height="100%"
457+
width="100%"
458+
overflowY="auto"
459+
data-tour-target="properties-panel"
460+
>
461+
{currentSelectedId && (
462+
<ComponentPropertiesPanel selectedComponentId={currentSelectedId} />
463+
)}
464+
</Box>
465+
</Box>
466+
{/* Right Panel - Discord Preview and Problems */}
447467
<Flex flex={1} direction="column" bg="gray.800" maxW={CENTER_PANEL_WIDTH}>
448468
{/* Discord Preview Section */}
449469
<Box p={4} borderBottom="1px" borderColor="gray.600" srOnly>
@@ -530,26 +550,6 @@ const PreviewerContent: React.FC = () => {
530550
</Tabs>
531551
</Box>
532552
</Flex>
533-
{/* Right Panel - Properties */}
534-
<Box
535-
minWidth={SIDE_PANEL_WIDTH}
536-
maxWidth={SIDE_PANEL_WIDTH}
537-
display={{ base: "none", lg: "block" }}
538-
>
539-
<Box
540-
bg="gray.800"
541-
borderLeft="1px"
542-
borderColor="gray.600"
543-
height="100%"
544-
width="100%"
545-
overflowY="auto"
546-
data-tour-target="properties-panel"
547-
>
548-
{currentSelectedId && (
549-
<ComponentPropertiesPanel selectedComponentId={currentSelectedId} />
550-
)}
551-
</Box>
552-
</Box>
553553
</Flex>
554554
</Flex>
555555
{/* Discard Confirmation Modal */}

0 commit comments

Comments
 (0)