Ver código fonte

Update notifications dropdown for new nomenclature.

Signed-off-by: Nashwan Azhari <nazhari@cloudbasesolutions.com>
Nashwan Azhari 1 ano atrás
pai
commit
46b9a4f95d

+ 7 - 2
src/components/ui/Dropdowns/NotificationDropdown/NotificationDropdown.tsx

@@ -274,6 +274,11 @@ class NotificationDropdown extends React.Component<Props, State> {
     const list = (
       <List>
         {this.props.items.map(item => {
+          const typeUrl =
+            item.type === "migration"
+              ? "deployments"
+              : "transfers";
+
           const executionsPath =
             item.status === "RUNNING"
               ? item.type === "replica"
@@ -295,13 +300,13 @@ class NotificationDropdown extends React.Component<Props, State> {
               onClick={() => {
                 this.handleItemClick();
               }}
-              to={`/${item.type}s/${item.id}${executionsPath}`}
+              to={`/${typeUrl}/${item.id}${executionsPath}`}
             >
               <InfoColumn>
                 <MainItemInfo>
                   <StatusIcon status={item.status} hollow />
                   <ItemReplicaBadge type={item.type}>
-                    {item.type === "replica" ? "RE" : "MI"}
+                    {item.type === "replica" ? "RE" : "DE"}
                   </ItemReplicaBadge>
                   <ItemTitle>{item.name}</ItemTitle>
                 </MainItemInfo>

+ 9 - 6
src/sources/NotificationSource.ts

@@ -20,9 +20,9 @@ import type {
 } from "@src/@types/NotificationItem";
 import {
   TransferItem,
-  MigrationItem,
   ReplicaItem,
   getTransferItemTitle,
+  DeploymentItem,
 } from "@src/@types/MainItem";
 
 class NotificationStorage {
@@ -79,7 +79,10 @@ class NotificationStorage {
 
 class DataUtils {
   static getItemDescription(item: TransferItem) {
-    return `New ${item.type} ${item.id.substr(
+    let item_type = item.type === "replica"
+      ? "replica"
+      : "deployment";
+    return `New ${item_type} ${item.id.substr(
       0,
       7
     )}... status: ${item.last_execution_status
@@ -90,9 +93,9 @@ class DataUtils {
 
 class NotificationSource {
   async loadData(): Promise<NotificationItemData[]> {
-    const [migrationsResponse, replicasResponse] = await Promise.all([
+    const [deploymentsResponse, replicasResponse] = await Promise.all([
       Api.send({
-        url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/migrations`,
+        url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/deployments`,
         skipLog: true,
         quietError: true,
       }),
@@ -103,9 +106,9 @@ class NotificationSource {
       }),
     ]);
 
-    const migrations: MigrationItem[] = migrationsResponse.data.migrations;
+    const deployments: DeploymentItem[] = deploymentsResponse.data.deployments;
     const replicas: ReplicaItem[] = replicasResponse.data.replicas;
-    const apiData = [...migrations, ...replicas];
+    const apiData = [...deployments, ...replicas];
     apiData.sort(
       (a, b) =>
         new Date(b.updated_at || b.created_at).getTime() -