Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: context merging for dr dashboard #783

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 80 additions & 42 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,21 @@
"Target cluster: {{targetCluster}}": "Target cluster: {{targetCluster}}",
"Not Initiated": "Not Initiated",
"Relocate status": "Relocate status",
"Data policy ({{count}})_one": "Data policy ({{count}})",
"Data policy ({{count}})_other": "Data policy ({{count}})",
"Data policies ({{count}})_one": "Data policies ({{count}})",
"Data policies ({{count}})_other": "Data policies ({{count}})",
"Data policy ({{count}})": "Data policy ({{count}})",
"Data policy ({{count}})_plural": "Data policy ({{count}})",
"Data policies ({{count}})": "Data policies ({{count}})",
"Data policies ({{count}})_plural": "Data policies ({{count}})",
"policy": "policy",
"policies": "policies",
"Data policies popover": "Data policies popover",
"Disaster Recovery ({{count}})_one": "Disaster Recovery ({{count}})",
"Disaster Recovery ({{count}})_other": "Disaster Recovery ({{count}})",
"Disaster Recovery ({{count}})": "Disaster Recovery ({{count}})",
"Disaster Recovery ({{count}})_plural": "Disaster Recovery ({{count}})",
"Close": "Close",
"View more details": "View more details",
"Disaster recovery: {{count}} policy_one": "Disaster recovery: {{count}} policy",
"Disaster recovery: {{count}} policy_other": "Disaster recovery: {{count}} policy",
"Disaster recovery: {{count}} policies_one": "Disaster recovery: {{count}} policies",
"Disaster recovery: {{count}} policies_other": "Disaster recovery: {{count}} policies",
"Disaster recovery: {{count}} policy": "Disaster recovery: {{count}} policy",
"Disaster recovery: {{count}} policy_plural": "Disaster recovery: {{count}} policy",
"Disaster recovery: {{count}} policies": "Disaster recovery: {{count}} policies",
"Disaster recovery: {{count}} policies_plural": "Disaster recovery: {{count}} policies",
"Failover:": "Failover:",
"Relocate:": "Relocate:",
"Disaster recovery policy": "Disaster recovery policy",
Expand Down Expand Up @@ -304,8 +304,8 @@
"Top clients": "Top clients",
"Client: {{ clientName }}": "Client: {{ clientName }}",
"Estimating {{formattedEta}} to completion": "Estimating {{formattedEta}} to completion",
"Object_one": "Object",
"Object_other": "Object",
"Object": "Object",
"Object_plural": "Object",
"Buckets": "Buckets",
"Buckets card represents the number of S3 buckets managed on Multicloud Object Gateway and the number of ObjectBucketClaims and the ObjectBuckets managed on both Multicloud Object Gateway and RGW (if deployed).": "Buckets card represents the number of S3 buckets managed on Multicloud Object Gateway and the number of ObjectBucketClaims and the ObjectBuckets managed on both Multicloud Object Gateway and RGW (if deployed).",
"NooBaa Bucket": "NooBaa Bucket",
Expand Down Expand Up @@ -369,7 +369,6 @@
"Savings": "Savings",
"Savings shows the uncompressed and non-deduped data that would have been stored without those techniques.": "Savings shows the uncompressed and non-deduped data that would have been stored without those techniques.",
"Block and File": "Block and File",
"Object": "Object",
"Network file system": "Network file system",
"Storage Classes": "Storage Classes",
"Pods": "Pods",
Expand Down Expand Up @@ -445,12 +444,12 @@
"Bucket created for Data Foundation's Service": "Bucket created for Data Foundation's Service",
"Tier 1 - BackingStores": "Tier 1 - BackingStores",
"Create BackingStore ": "Create BackingStore ",
"{{bs, number}} BackingStore_one": "{{bs, number}} BackingStore",
"{{bs, number}} BackingStore_other": "{{bs, number}} BackingStore",
"{{bs, number}} BackingStore": "{{bs, number}} BackingStore",
"{{bs, number}} BackingStore_plural": "{{bs, number}} BackingStore",
"selected": "selected",
"Tier 2 - BackingStores": "Tier 2 - BackingStores",
"{{bs, number}} BackingStore _one": "{{bs, number}} BackingStore ",
"{{bs, number}} BackingStore _other": "{{bs, number}} BackingStore ",
"{{bs, number}} BackingStore ": "{{bs, number}} BackingStore ",
"{{bs, number}} BackingStore _plural": "{{bs, number}} BackingStore ",
"General": "General",
"Placement Policy": "Placement Policy",
"Resources": "Resources",
Expand Down Expand Up @@ -501,8 +500,8 @@
"Read NamespaceStores": "Read NamespaceStores",
"Select a list of NamespaceStores that defines the read targets of the namespace bucket.": "Select a list of NamespaceStores that defines the read targets of the namespace bucket.",
"Create NamespaceStore": "Create NamespaceStore",
"{{nns, number}} namespace store _one": "{{nns, number}} namespace store ",
"{{nns, number}} namespace store _other": "{{nns, number}} namespace store ",
"{{nns, number}} namespace store ": "{{nns, number}} namespace store ",
"{{nns, number}} namespace store _plural": "{{nns, number}} namespace store ",
" selected": " selected",
"Write NamespaceStore": "Write NamespaceStore",
"Select a single NamespaceStore that defines the write targets of the namespace bucket.": "Select a single NamespaceStore that defines the write targets of the namespace bucket.",
Expand Down Expand Up @@ -594,8 +593,8 @@
"Arbiter zone selection": "Arbiter zone selection",
"Connection details": "Connection details",
"Disks on all nodes": "Disks on all nodes",
"{{nodes, number}} node_one": "{{nodes, number}} node",
"{{nodes, number}} node_other": "{{nodes, number}} node",
"{{nodes, number}} node": "{{nodes, number}} node",
"{{nodes, number}} node_plural": "{{nodes, number}} node",
"Please enter a positive Integer": "Please enter a positive Integer",
"LocalVolumeSet name": "LocalVolumeSet name",
"A LocalVolumeSet will be created to allow you to filter a set of disks, group them and create a dedicated StorageClass to consume storage from them.": "A LocalVolumeSet will be created to allow you to filter a set of disks, group them and create a dedicated StorageClass to consume storage from them.",
Expand Down Expand Up @@ -631,10 +630,10 @@
"Model": "Model",
"Capacity": "Capacity",
"Selected Disks": "Selected Disks",
"{{nodes, number}} Node_one": "{{nodes, number}} Node",
"{{nodes, number}} Node_other": "{{nodes, number}} Node",
"{{disks, number}} Disk_one": "{{disks, number}} Disk",
"{{disks, number}} Disk_other": "{{disks, number}} Disk",
"{{nodes, number}} Node": "{{nodes, number}} Node",
"{{nodes, number}} Node_plural": "{{nodes, number}} Node",
"{{disks, number}} Disk": "{{disks, number}} Disk",
"{{disks, number}} Disk_plural": "{{disks, number}} Disk",
"Selected versus Available Capacity": "Selected versus Available Capacity",
"Out of {{capacity}}": "Out of {{capacity}}",
"The endpoint is not a valid IP address": "The endpoint is not a valid IP address",
Expand All @@ -647,11 +646,11 @@
"External storage platform: {{storagePlatform}}": "External storage platform: {{storagePlatform}}",
"Capacity and nodes": "Capacity and nodes",
"Cluster capacity: {{capacity}}": "Cluster capacity: {{capacity}}",
"Selected nodes: {{nodeCount, number}} node_one": "Selected nodes: {{nodeCount, number}} node",
"Selected nodes: {{nodeCount, number}} node_other": "Selected nodes: {{nodeCount, number}} node",
"Selected nodes: {{nodeCount, number}} node": "Selected nodes: {{nodeCount, number}} node",
"Selected nodes: {{nodeCount, number}} node_plural": "Selected nodes: {{nodeCount, number}} node",
"CPU and memory: {{cpu, number}} CPU and {{memory}} memory": "CPU and memory: {{cpu, number}} CPU and {{memory}} memory",
"Zone: {{zoneCount, number}} zone_one": "Zone: {{zoneCount, number}} zone",
"Zone: {{zoneCount, number}} zone_other": "Zone: {{zoneCount, number}} zone",
"Zone: {{zoneCount, number}} zone": "Zone: {{zoneCount, number}} zone",
"Zone: {{zoneCount, number}} zone_plural": "Zone: {{zoneCount, number}} zone",
"Arbiter zone: {{zone}}": "Arbiter zone: {{zone}}",
"Taint nodes: {{ocsTaintsStatus}}": "Taint nodes: {{ocsTaintsStatus}}",
"Security": "Security",
Expand Down Expand Up @@ -692,11 +691,11 @@
"An error has occurred": "An error has occurred",
"Create StorageSystem": "Create StorageSystem",
"Create a StorageSystem to represent your Data Foundation system and all its required storage and computing resources.": "Create a StorageSystem to represent your Data Foundation system and all its required storage and computing resources.",
"{{nodeCount, number}} node_one": "{{nodeCount, number}} node",
"{{nodeCount, number}} node_other": "{{nodeCount, number}} node",
"{{nodeCount, number}} node": "{{nodeCount, number}} node",
"{{nodeCount, number}} node_plural": "{{nodeCount, number}} node",
"selected ({{cpu}} CPU and {{memory}} on ": "selected ({{cpu}} CPU and {{memory}} on ",
"{{zoneCount, number}} zone_one": "{{zoneCount, number}} zone",
"{{zoneCount, number}} zone_other": "{{zoneCount, number}} zone",
"{{zoneCount, number}} zone": "{{zoneCount, number}} zone",
"{{zoneCount, number}} zone_plural": "{{zoneCount, number}} zone",
"Node Table": "Node Table",
"Connection name": "Connection name",
"An unique name for the key management service within the project. Name must only include alphanumeric characters, \"-\", \"_\" or \".\"": "An unique name for the key management service within the project. Name must only include alphanumeric characters, \"-\", \"_\" or \".\"",
Expand Down Expand Up @@ -950,17 +949,17 @@
"{{humanAvailable}} available of {{humanMax}}": "{{humanAvailable}} available of {{humanMax}}",
"{{humanAvailable}} available": "{{humanAvailable}} available",
"Just now": "Just now",
"{{count}} day_one": "{{count}} day",
"{{count}} day_other": "{{count}} day",
"{{count}} hour_one": "{{count}} hour",
"{{count}} hour_other": "{{count}} hour",
"{{count}} minute_one": "{{count}} minute",
"{{count}} minute_other": "{{count}} minute",
"{{count}} day": "{{count}} day",
"{{count}} day_plural": "{{count}} day",
"{{count}} hour": "{{count}} hour",
"{{count}} hour_plural": "{{count}} hour",
"{{count}} minute": "{{count}} minute",
"{{count}} minute_plural": "{{count}} minute",
"Managed by": "Managed by",
"Edit": "Edit",
"Annotations": "Annotations",
"{{count}} annotation_one": "{{count}} annotation",
"{{count}} annotation_other": "{{count}} annotation",
"{{count}} annotation": "{{count}} annotation",
"{{count}} annotation_plural": "{{count}} annotation",
"Created at": "Created at",
"Owner": "Owner",
"No labels": "No labels",
Expand Down Expand Up @@ -1067,5 +1066,44 @@
"Cannot change resource kind (original: \"{{original}}\", updated: \"{{updated}}\").": "Cannot change resource kind (original: \"{{original}}\", updated: \"{{updated}}\").",
"Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\").": "Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\").",
"Required": "Required",
"Object_plural": "Object"
"Data policy ({{count}})_one": "Data policy ({{count}})",
"Data policy ({{count}})_other": "Data policy ({{count}})",
"Data policies ({{count}})_one": "Data policies ({{count}})",
"Data policies ({{count}})_other": "Data policies ({{count}})",
"Disaster Recovery ({{count}})_one": "Disaster Recovery ({{count}})",
"Disaster Recovery ({{count}})_other": "Disaster Recovery ({{count}})",
"Disaster recovery: {{count}} policy_one": "Disaster recovery: {{count}} policy",
"Disaster recovery: {{count}} policy_other": "Disaster recovery: {{count}} policy",
"Disaster recovery: {{count}} policies_one": "Disaster recovery: {{count}} policies",
"Disaster recovery: {{count}} policies_other": "Disaster recovery: {{count}} policies",
"Object_one": "Object",
"Object_other": "Object",
"{{bs, number}} BackingStore_one": "{{bs, number}} BackingStore",
"{{bs, number}} BackingStore_other": "{{bs, number}} BackingStore",
"{{bs, number}} BackingStore _one": "{{bs, number}} BackingStore ",
"{{bs, number}} BackingStore _other": "{{bs, number}} BackingStore ",
"{{nns, number}} namespace store _one": "{{nns, number}} namespace store ",
"{{nns, number}} namespace store _other": "{{nns, number}} namespace store ",
"{{nodes, number}} node_one": "{{nodes, number}} node",
"{{nodes, number}} node_other": "{{nodes, number}} node",
"{{nodes, number}} Node_one": "{{nodes, number}} Node",
"{{nodes, number}} Node_other": "{{nodes, number}} Node",
"{{disks, number}} Disk_one": "{{disks, number}} Disk",
"{{disks, number}} Disk_other": "{{disks, number}} Disk",
"Selected nodes: {{nodeCount, number}} node_one": "Selected nodes: {{nodeCount, number}} node",
"Selected nodes: {{nodeCount, number}} node_other": "Selected nodes: {{nodeCount, number}} node",
"Zone: {{zoneCount, number}} zone_one": "Zone: {{zoneCount, number}} zone",
"Zone: {{zoneCount, number}} zone_other": "Zone: {{zoneCount, number}} zone",
"{{nodeCount, number}} node_one": "{{nodeCount, number}} node",
"{{nodeCount, number}} node_other": "{{nodeCount, number}} node",
"{{zoneCount, number}} zone_one": "{{zoneCount, number}} zone",
"{{zoneCount, number}} zone_other": "{{zoneCount, number}} zone",
"{{count}} day_one": "{{count}} day",
"{{count}} day_other": "{{count}} day",
"{{count}} hour_one": "{{count}} hour",
"{{count}} hour_other": "{{count}} hour",
"{{count}} minute_one": "{{count}} minute",
"{{count}} minute_other": "{{count}} minute",
"{{count}} annotation_one": "{{count}} annotation",
"{{count}} annotation_other": "{{count}} annotation"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,42 @@ export const DRResourcesContext = React.createContext<DRResourcesContextType>(
{} as DRResourcesContextType
);

type CSVStatusesContextType = {
export type CSVStatusesContextType = {
csvData: PrometheusResponse;
csvError: any;
csvLoading: boolean;
};

type DRResourcesContextType = {
export type DRResourcesContextType = {
drClusterAppsMap: DrClusterAppsMap;
loaded: boolean;
loadError: any;
};

interface ContextProps<P> {
context: React.Provider<P>;
value: P;
}

export type DRContext =
| ContextProps<CSVStatusesContextType>
| ContextProps<DRResourcesContextType>;

export const combineComponents = (components): React.FC => {
return components.reduce(
(AccumulatedComponents, { context: CurrentComponent, value }) => {
return ({ children }: React.ComponentProps<React.FC>): JSX.Element => {
return (
<AccumulatedComponents>
<CurrentComponent value={value}>{children}</CurrentComponent>
</AccumulatedComponents>
);
};
},
({ children }) => <>{children}</>
);
};

export const AppContextProvider = (input: DRContext[]) => (
<>{combineComponents(input)}</>
);
29 changes: 22 additions & 7 deletions packages/mco/components/mco-dashboard/data-policy/dr-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ import {
import { StorageDashboard, STATUS_QUERIES } from '../queries';
import { AlertsCard } from './alert-card/alert-card';
import { ClusterAppCard } from './cluster-app-card/cluster-app-card';
import { CSVStatusesContext, DRResourcesContext } from './dr-dashboard-context';
import {
AppContextProvider,
CSVStatusesContext,
CSVStatusesContextType,
DRContext,
DRResourcesContext,
DRResourcesContextType,
} from './dr-dashboard-context';
import { StatusCard } from './status-card/status-card';
import { SummaryCard } from './summary-card/summary-card';
import '../mco-common.scss';
Expand Down Expand Up @@ -150,21 +157,29 @@ export const DRDashboard: React.FC = () => {
loadError,
]);

const dRResourcesContext = {
const csvStatusesContext: CSVStatusesContextType = {
csvData,
csvError,
csvLoading,
};
const dRResourcesContext: DRResourcesContextType = {
drClusterAppsMap,
loaded,
loadError,
};

const providers: DRContext[] = [
{ context: CSVStatusesContext.Provider, value: csvStatusesContext },
{ context: DRResourcesContext.Provider, value: dRResourcesContext },
];

// ToDo(Sanjal): combime multiple Context together to make it scalable
// refer: https://javascript.plainenglish.io/how-to-combine-context-providers-for-cleaner-react-code-9ed24f20225e
return (
<div className="odf-dashboard-body">
<CSVStatusesContext.Provider value={{ csvData, csvError, csvLoading }}>
<DRResourcesContext.Provider value={dRResourcesContext}>
<UpperSection />
</DRResourcesContext.Provider>
</CSVStatusesContext.Provider>
<AppContextProvider {...providers}>
<UpperSection />
</AppContextProvider>
</div>
);
};
Expand Down
Loading