Skip to content

Commit 2cb7ca4

Browse files
authored
Merge pull request #21 from zeusongit/config
Render webapp from env URL
2 parents aeb8d49 + 9c25c40 commit 2cb7ca4

File tree

4 files changed

+31
-26
lines changed

4 files changed

+31
-26
lines changed

config/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
NOTIFICATION_URL=""
1+
NOTIFICATION_URL="https://ddehnr4ewobxc.cloudfront.net/dynNotifications.json"

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dynamods/notifications-center",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"description": "Notification center maintained by Dynamo Team@Autodesk",
55
"author": "Autodesk Inc.",
66
"license": "MIT",

src/App.js

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,38 @@ function App() {
88
const [APIData, setAPIData] = useState(false);
99
useEffect(() => {
1010
window.RequestNotifications = RequestNotifications;
11+
RequestNotifications();
1112
}, []);
1213

1314
const RequestNotifications = (url) => {
14-
axios.get(url)
15-
.then((response) => {
16-
const notifications = response.data.notifications;
17-
let notificationData = [];
18-
for (let i = 0; i < notifications.length; i++) {
19-
var notificationItem = {
20-
id: notifications[i].id,
21-
featured: true,
22-
unread: true,
23-
image: <img width={40} src={notifications[i].thumbnail}></img>,
24-
message: notifications[i].title,
25-
href: notifications[i].linkTitle,
26-
timestamp: <Timestamp timestamp={notifications[i].created} />,
27-
content: <div>
28-
<b>{notifications[i].title}</b>
29-
<p>{notifications[i].longDescription}</p>
30-
<a href={notifications[i].link}>{notifications[i].linkTitle}</a>
31-
</div>
32-
};
33-
notificationData.push(notificationItem);
34-
}
35-
setAPIData(notificationData);
36-
});
15+
let getURL = url || process.env.NOTIFICATION_URL;
16+
if(getURL){
17+
axios.get(getURL)
18+
.then((response) => {
19+
const notifications = response.data.notifications;
20+
let notificationData = [];
21+
for (let i = 0; i < notifications.length; i++) {
22+
var notificationItem = {
23+
id: notifications[i].id,
24+
featured: true,
25+
unread: true,
26+
image: <img width={40} src={notifications[i].thumbnail}></img>,
27+
message: notifications[i].title,
28+
href: notifications[i].linkTitle,
29+
timestamp: <Timestamp timestamp={notifications[i].created} />,
30+
content: <div>
31+
<b>{notifications[i].title}</b>
32+
<p>{notifications[i].longDescription}</p>
33+
<a href={notifications[i].link}>{notifications[i].linkTitle}</a>
34+
</div>
35+
};
36+
notificationData.push(notificationItem);
37+
}
38+
setAPIData(notificationData);
39+
});
40+
}
3741
}
42+
3843
return APIData ?
3944
<NotificationsPanel class="NotificationsFlyout"
4045
heading="Notifications"

0 commit comments

Comments
 (0)