Repository: MozillaSecurity/FuzzManager (language: python)

Issue:
Notifications should show date/time when created.



Discussion / hints:

Fix patch:
diff --git a/server/crashmanager/serializers.py b/server/crashmanager/serializers.py
index fdd7e9c0..3a3d8e1a 100644
--- a/server/crashmanager/serializers.py
+++ b/server/crashmanager/serializers.py
@@ -272,7 +272,7 @@ class NotificationSerializer(serializers.ModelSerializer):
 
     class Meta:
         model = Notification
-        fields = ('id', 'description', 'verb', 'actor_url', 'target_url', 'external_bug_url',)
+        fields = ('id', 'timestamp', 'description', 'verb', 'actor_url', 'target_url', 'external_bug_url',)
 
     def get_actor_url(self, notification):
         if isinstance(notification.actor, Bucket):
diff --git a/server/frontend/src/components/Notifications/BucketHit.vue b/server/frontend/src/components/Notifications/BucketHit.vue
index 01024342..a5784ea8 100644
--- a/server/frontend/src/components/Notifications/BucketHit.vue
+++ b/server/frontend/src/components/Notifications/BucketHit.vue
@@ -1,5 +1,8 @@
 <template>
   <div class="row override-row">
+    <small class="col-md-1">
+      Received {{ notification.timestamp | formatDate }}
+    </small>
     <span class="label label-info">Bucket hit</span>
     <span class="description">
       {{ notification.description }}
@@ -17,7 +20,7 @@
 </template>
 
 <script>
-import { errorParser } from "../../helpers";
+import { errorParser, formatClientTimestamp } from "../../helpers";
 import * as api from "../../api";
 
 export default {
@@ -30,6 +33,9 @@ export default {
   data: () => ({
     dismissError: null,
   }),
+  filters: {
+    formatDate: formatClientTimestamp,
+  },
   methods: {
     async dismiss() {
       this.dismissError = null;
@@ -61,4 +67,9 @@ export default {
 button.close {
   margin-left: 3rem;
 }
+small {
+  padding-left: 0rem;
+  padding-right: 0rem;
+  margin-right: 1rem;
+}
 </style>
diff --git a/server/frontend/src/components/Notifications/InaccessibleBug.vue b/server/frontend/src/components/Notifications/InaccessibleBug.vue
index 44b42dd8..1b06ca0e 100644
--- a/server/frontend/src/components/Notifications/InaccessibleBug.vue
+++ b/server/frontend/src/components/Notifications/InaccessibleBug.vue
@@ -1,5 +1,8 @@
 <template>
   <div class="row override-row">
+    <small class="col-md-1">
+      Received {{ notification.timestamp | formatDate }}
+    </small>
     <span class="label label-danger">Inaccessible bug</span>
     <span class="description">
       {{ notification.description }}
@@ -18,7 +21,7 @@
 </template>
 
 <script>
-import { errorParser } from "../../helpers";
+import { errorParser, formatClientTimestamp } from "../../helpers";
 import * as api from "../../api";
 
 export default {
@@ -31,6 +34,9 @@ export default {
   data: () => ({
     dismissError: null,
   }),
+  filters: {
+    formatDate: formatClientTimestamp,
+  },
   methods: {
     async dismiss() {
       this.dismissError = null;
@@ -62,4 +68,9 @@ export default {
 button.close {
   margin-left: 3rem;
 }
+small {
+  padding-left: 0rem;
+  padding-right: 0rem;
+  margin-right: 1rem;
+}
 </style>


Test patch:
diff --git a/server/crashmanager/tests/test_inbox_rest.py b/server/crashmanager/tests/test_inbox_rest.py
index 9c764c68..965a7d0c 100644
--- a/server/crashmanager/tests/test_inbox_rest.py
+++ b/server/crashmanager/tests/test_inbox_rest.py
@@ -108,6 +108,9 @@ def test_rest_notifications_list_unread(api_client, user, cm):
     assert resp["next"] is None
     assert resp["previous"] is None
     assert len(resp["results"]) == 2
+    # Popping out timestamps
+    for r in resp["results"]:
+        del r["timestamp"]
     assert resp["results"] == [{
         "id": 2,
         "actor_url": reverse("crashmanager:sigview", kwargs={"sigid": bucket.id}),