Skip to content

Commit 14e55bf

Browse files
authored
Merge pull request #2310 from dappnode/develop
merge to main
2 parents a7ba56c + 755a718 commit 14e55bf

File tree

13 files changed

+147
-52
lines changed

13 files changed

+147
-52
lines changed

packages/admin-ui/src/components/NotificationsMain.tsx

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { useEffect, useMemo, useState } from "react";
1+
import React, { useContext, useEffect, useMemo, useState } from "react";
22
import { NavLink } from "react-router-dom";
33
import RenderMarkdown from "components/RenderMarkdown";
44
import Button, { ButtonVariant } from "components/Button";
55
import { api, useApi } from "api";
66
import { Notification, Priority } from "@dappnode/types";
77
import { MdClose } from "react-icons/md";
8-
import { Accordion, useAccordionButton } from "react-bootstrap";
8+
import { Accordion, AccordionContext, useAccordionButton } from "react-bootstrap";
99
import { dappmanagerAliases, externalUrlProps } from "params";
1010
import { resolveDappnodeUrl } from "utils/resolveDappnodeUrl";
1111
import { IoIosArrowUp, IoIosArrowDown } from "react-icons/io";
@@ -103,7 +103,6 @@ export function CollapsableBannerNotification({
103103
onClose: () => void;
104104
}) {
105105
const [hasClosed, setHasClosed] = useState(false);
106-
const [isOpen, setIsOpen] = useState(notification.priority === Priority.critical);
107106

108107
const handleClose = () => {
109108
api.notificationSetSeenByCorrelationID({ correlationId: notification.correlationId });
@@ -114,12 +113,17 @@ export function CollapsableBannerNotification({
114113
const isExternalUrl =
115114
notification.callToAction && !dappmanagerAliases.some((alias) => notification.callToAction!.url.includes(alias));
116115

116+
// open by default if critical
117+
const defaultKey = notification.priority === Priority.critical ? "0" : undefined;
117118
const BannerToggle: React.FC<{
118119
eventKey: string;
119120
className?: string;
120121
children: React.ReactNode;
121-
}> = ({ eventKey, className, children }) => {
122-
const onClick = useAccordionButton(eventKey, () => setIsOpen((prev) => !prev));
122+
title: string;
123+
}> = ({ eventKey, className, children, title }) => {
124+
const onClick = useAccordionButton(eventKey);
125+
const { activeEventKey } = useContext(AccordionContext);
126+
const isOpen = activeEventKey === eventKey || (Array.isArray(activeEventKey) && activeEventKey.includes(eventKey));
123127
return (
124128
<div
125129
role="button"
@@ -133,36 +137,36 @@ export function CollapsableBannerNotification({
133137
}
134138
}}
135139
>
140+
<div className="banner-header">
141+
<h5 className="banner-title">
142+
{title}
143+
{isOpen ? <IoIosArrowUp /> : <IoIosArrowDown />}
144+
</h5>
145+
<button
146+
className="close-btn"
147+
onClick={(e) => {
148+
e.stopPropagation();
149+
handleClose();
150+
}}
151+
>
152+
<MdClose />
153+
</button>
154+
</div>
136155
{children}
137156
</div>
138157
);
139158
};
140159

141160
if (hasClosed) return null;
142161

143-
// open by default if critical
144-
const defaultKey = notification.priority === Priority.critical ? "0" : undefined;
145-
146162
return (
147-
<Accordion activeKey={isOpen ? "0" : undefined} defaultActiveKey={defaultKey}>
163+
<Accordion defaultActiveKey={defaultKey}>
148164
<Accordion.Item eventKey="0">
149-
<BannerToggle eventKey="0" className={`banner-card ${notification.priority}-priority`}>
150-
<div className="banner-header">
151-
<h5 className="banner-title">
152-
{notification.title}
153-
{isOpen ? <IoIosArrowUp /> : <IoIosArrowDown />}
154-
</h5>
155-
<button
156-
className="close-btn"
157-
onClick={(e) => {
158-
e.stopPropagation(); // don't toggle when closing
159-
handleClose();
160-
}}
161-
>
162-
<MdClose />
163-
</button>
164-
</div>
165-
165+
<BannerToggle
166+
eventKey="0"
167+
className={`banner-card ${notification.priority}-priority`}
168+
title={notification.title}
169+
>
166170
<Accordion.Body className="banner-body">
167171
<RenderMarkdown source={notification.body} />
168172
{notification.callToAction && (
@@ -181,4 +185,3 @@ export function CollapsableBannerNotification({
181185
</Accordion>
182186
);
183187
}
184-
// ...existing code...

packages/admin-ui/src/components/Title.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface TitleProps {
66
}
77

88
const Title: React.FC<TitleProps> = ({ title, children }) => {
9-
return <div className="section-title">{children ? children.toUpperCase() : title.toLocaleUpperCase()}</div>;
9+
return <div className="section-title">{children ? children : title}</div>;
1010
};
1111

1212
export default Title;

packages/admin-ui/src/components/notificationsMain.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
flex-direction: row;
4848
align-items: center;
4949
gap: 2px;
50+
font-weight: normal;
5051
}
5152

5253
.close-btn {

packages/admin-ui/src/components/sidebar/sidebar.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
&.selectable:hover,
5454
&.selectable.active {
5555
color: black;
56-
font-weight: 800;
56+
font-weight: 600;
5757
text-decoration: none;
5858
}
5959
&.selectable:hover {
14.1 KB
Loading

packages/admin-ui/src/pages/dashboard/components/PackageUpdates.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function UpdateCard({ update }: { update: UpdatesInterface }) {
7777
}}
7878
>
7979
<div>
80-
<strong>{prettyDnpName(update.dnpName)}</strong> v{update.newVersion}{" "}
80+
<span className="dnp-name">{prettyDnpName(update.dnpName)}</span> v{update.newVersion}{" "}
8181
{isOpen ? <IoIosArrowUp /> : <IoIosArrowDown />}
8282
</div>
8383
</div>

packages/admin-ui/src/pages/dashboard/components/dashboard.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
}
2929

3030
.package-updates {
31+
display: flex;
32+
flex-direction: column;
33+
gap: 1rem;
3134
@media screen and (min-width: 65rem) {
3235
// Give the single card a max width that matches the other cards
3336
grid-column: 1 / 4;
@@ -51,7 +54,7 @@
5154
.chain-card .name,
5255
.stats-card .id {
5356
text-transform: capitalize;
54-
font-weight: 800;
57+
font-weight: 600;
5558

5659
display: flex;
5760
.text {
@@ -95,6 +98,10 @@
9598
align-items: stretch;
9699
height: 100%;
97100

101+
.dnp-name {
102+
font-weight: 600;
103+
}
104+
98105
.package-update-accordion {
99106
min-width: max-content;
100107
display: flex;

packages/admin-ui/src/pages/installer/components/InstallCardComponents/details.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131

3232
header,
3333
.data > span:nth-child(2n-1) {
34-
font-weight: 800;
34+
font-weight: 600;
3535
}
3636
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Card from "components/Card";
2+
import React from "react";
3+
import aiStars from "img/ai_stars.png";
4+
import "./installerAiBanner.scss";
5+
6+
export function InstallerAIBanner({ onCategoryChange }: { onCategoryChange: (category: string) => void }) {
7+
return (
8+
<div
9+
className="installer-ai-banner group"
10+
onClick={() => {
11+
onCategoryChange("AI");
12+
}}
13+
>
14+
<Card>
15+
<div className="ai-banner-row">
16+
<img src={aiStars} alt="AI DAppNode Installer Banner" width={50} height={50} />
17+
<div>
18+
<h2>AI Toolkit</h2>
19+
<div className="description">
20+
Explore the new AI-powered Dappnode packages, running locally, privately, and securely on your node.
21+
</div>
22+
</div>
23+
</div>
24+
</Card>
25+
</div>
26+
);
27+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.installer-ai-banner {
2+
margin-bottom: var(--default-spacing);
3+
cursor: pointer;
4+
5+
&.group:hover h2 {
6+
color: var(--dappnode-strong-main-color);
7+
}
8+
.ai-banner-row {
9+
display: flex;
10+
flex-direction: row;
11+
align-items: center;
12+
gap: 10px;
13+
14+
img {
15+
height: 75px;
16+
width: 75px;
17+
}
18+
19+
h2 {
20+
margin: 0;
21+
}
22+
23+
.description {
24+
line-height: normal;
25+
26+
@media (max-width: 25rem) {
27+
display: none;
28+
}
29+
}
30+
}
31+
32+
// Adding margin-top in mobile view since category filter is hidden
33+
@media (max-width: 40rem) {
34+
margin-top: var(--default-spacing);
35+
}
36+
}

0 commit comments

Comments
 (0)