Skip to content

Commit

Permalink
Merge pull request #906 from GowthamShanmugam/RHSTOR-4605
Browse files Browse the repository at this point in the history
Assign policy wizard
  • Loading branch information
openshift-merge-robot authored Jul 10, 2023
2 parents 4c45fbb + f01c7a1 commit e40d0bf
Show file tree
Hide file tree
Showing 33 changed files with 1,124 additions and 173 deletions.
27 changes: 22 additions & 5 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,19 @@
"{{selected}} of {{total}} selected": "{{selected}} of {{total}} selected",
"subscription-selector": "subscription-selector",
"Select the subscriptions groups you wish to replicate via": "Select the subscriptions groups you wish to replicate via",
"Assign policy": "Assign policy",
"Secure your application by assigning a policy from the available policy templates.": "Secure your application by assigning a policy from the available policy templates.",
"Manage data policy": "Manage data policy",
"Assign policy to protect the application and ensure quick recovery. Unassign policy from an application when they no longer require to be managed.": "Assign policy to protect the application and ensure quick recovery. Unassign policy from an application when they no longer require to be managed.",
"PVC details": "PVC details",
"Review and assign": "Review and assign",
"Assign": "Assign",
"New policy assigned to application.": "New policy assigned to application.",
"Unable to assign policy to application.": "Unable to assign policy to application.",
"Next": "Next",
"Back": "Back",
"Assign policy nav": "Assign policy nav",
"Assign policy content": "Assign policy content",
"Manage list view alert": "Manage list view alert",
"Confirm unassign": "Confirm unassign",
"All placements": "All placements",
Expand All @@ -214,7 +225,17 @@
"Assigned on": "Assigned on",
"View configurations": "View configurations",
"No activity": "No activity",
"Back": "Back",
"Delete": "Delete",
"Select a placement": "Select a placement",
"{{count}} selected_one": "{{count}} selected",
"{{count}} selected_other": "{{count}} selected",
"Select labels": "Select labels",
"Use PVC label selectors to effortlessly specify the application resources that need protection.": "Use PVC label selectors to effortlessly specify the application resources that need protection.",
"If no label is provided, all PVCs will be protected. Define your preferences to protect specific resources.": "If no label is provided, all PVCs will be protected. Define your preferences to protect specific resources.",
"Application resource": "Application resource",
"Add application resource": "Add application resource",
"Policy": "Policy",
"Select a policy": "Select a policy",
"Search": "Search",
"Search input": "Search input",
"Secondary actions": "Secondary actions",
Expand All @@ -226,7 +247,6 @@
"Selected policies ({{ count }}) unassigned for the application._other": "Selected policies ({{ count }}) unassigned for the application.",
"Unable to unassign all selected policies for the application.": "Unable to unassign all selected policies for the application.",
"My policies": "My policies",
"Assign policy": "Assign policy",
"Relocate in progress": "Relocate in progress",
"Failover in progress": "Failover in progress",
"List all the connected applications under a policy.": "List all the connected applications under a policy.",
Expand Down Expand Up @@ -254,7 +274,6 @@
"A selector label to DR protect only specific PVCs within an application.": "A selector label to DR protect only specific PVCs within an application.",
"When multiple applications are selected, DR protection will be applied for all the PVCs under the application's namespace.": "When multiple applications are selected, DR protection will be applied for all the PVCs under the application's namespace.",
"Protect all PVCs within the application's namespace": "Protect all PVCs within the application's namespace",
"Assign": "Assign",
"Asynchronous": "Asynchronous",
"Synchronous": "Synchronous",
"minutes": "minutes",
Expand Down Expand Up @@ -443,7 +462,6 @@
"Try Again": "Try Again",
"Finish": "Finish",
"Go To PVC List": "Go To PVC List",
"Delete": "Delete",
"BlockPool Update Form": "BlockPool Update Form",
"Filesystem name": "Filesystem name",
"Enter filesystem name": "Enter filesystem name",
Expand Down Expand Up @@ -499,7 +517,6 @@
"Create BucketClass": "Create BucketClass",
"Create new BucketClass": "Create new BucketClass",
"BucketClass is a CRD representing a class for buckets that defines tiering policies and data placements for an OBC.": "BucketClass is a CRD representing a class for buckets that defines tiering policies and data placements for an OBC.",
"Next": "Next",
"Edit BucketClass Resource": "Edit BucketClass Resource",
"{{storeType}} represents a storage target to be used as the underlying storage for the data in Multicloud Object Gateway buckets.": "{{storeType}} represents a storage target to be used as the underlying storage for the data in Multicloud Object Gateway buckets.",
"What is a BackingStore?": "What is a BackingStore?",
Expand Down
10 changes: 5 additions & 5 deletions packages/mco/components/mco-dashboard/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import {
USED_CAPACITY_FILE_BLOCK_METRIC,
SYSTEM_HEALTH_METRIC,
} from '@odf/shared/queries';
import {
DRPC_OBJECT_TYPE,
HUB_CLUSTER_NAME,
RAMEN_HUB_OPERATOR_METRICS_SERVICE,
} from '../../constants';
import { HUB_CLUSTER_NAME } from '../../constants';

export const RAMEN_HUB_OPERATOR_METRICS_SERVICE =
'job="ramen-hub-operator-metrics-service"';
export const DRPC_OBJECT_TYPE = 'obj_type="DRPlacementControl"';

export enum StorageDashboard {
USED_CAPACITY_FILE_BLOCK = 'USED_CAPACITY_FILE_BLOCK',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react';
import { StatusBox } from '@odf/shared/generic/status-box';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { TFunction } from 'i18next';
import { Modal, ModalVariant } from '@patternfly/react-core';
import { AssignPolicyView } from './assign-policy-view';
import { PolicyConfigView } from './policy-config-view';
import { PolicyListView } from './policy-list-view';
import {
Expand All @@ -14,11 +16,34 @@ import {
managePolicyStateReducer,
ManagePolicyState,
} from './utils/reducer';
import { ApplicationInfoType, ApplicationType } from './utils/types';
import {
ApplicationInfoType,
ApplicationType,
DataPolicyType,
} from './utils/types';

const getModalTitle = (modalViewContext: ModalViewContext, t: TFunction) => {
if (modalViewContext === ModalViewContext.ASSIGN_POLICY_VIEW) {
return {
title: t('Assign policy'),
description: t(
'Secure your application by assigning a policy from the available policy templates.'
),
};
} else {
return {
title: t('Manage data policy'),
description: t(
'Assign policy to protect the application and ensure quick recovery. Unassign policy from an application when they no longer require to be managed.'
),
};
}
};

export const ModalContextViewer: React.FC<ModalContextViewerProps> = ({
applicaitonInfo,
state,
matchingPolicies,
dispatch,
}) => {
const setModalContext = React.useCallback(
Expand Down Expand Up @@ -71,12 +96,24 @@ export const ModalContextViewer: React.FC<ModalContextViewerProps> = ({
setModalContext={setModalContext}
/>
)}
{state.modalViewContext === ModalViewContext.ASSIGN_POLICY_VIEW && (
<AssignPolicyView
applicaitonInfo={applicaitonInfo}
matchingPolicies={matchingPolicies}
state={state.assignPolicyView}
dispatch={dispatch}
setModalContext={setModalContext}
setModalActionContext={setModalActionContext}
setMessage={setMessage}
/>
)}
</>
);
};

export const AppManagePoliciesModal: React.FC<AppManagePoliciesModalProps> = ({
applicaitonInfo,
matchingPolicies,
loaded,
loadError,
isOpen,
Expand All @@ -87,13 +124,12 @@ export const AppManagePoliciesModal: React.FC<AppManagePoliciesModalProps> = ({
initialPolicyState
);
const { t } = useCustomTranslation();
const modalTitle = getModalTitle(state.modalViewContext, t);

return (
<Modal
title={t('Manage data policy')}
description={t(
'Assign policy to protect the application and ensure quick recovery. Unassign policy from an application when they no longer require to be managed.'
)}
title={modalTitle.title}
description={modalTitle.description}
variant={ModalVariant.large}
isOpen={isOpen}
aria-label="Manage policy modal"
Expand All @@ -103,6 +139,7 @@ export const AppManagePoliciesModal: React.FC<AppManagePoliciesModalProps> = ({
{loaded && !loadError ? (
<ModalContextViewer
applicaitonInfo={applicaitonInfo as ApplicationType}
matchingPolicies={matchingPolicies}
state={state}
dispatch={dispatch}
/>
Expand All @@ -115,6 +152,7 @@ export const AppManagePoliciesModal: React.FC<AppManagePoliciesModalProps> = ({

type AppManagePoliciesModalProps = {
applicaitonInfo: ApplicationInfoType;
matchingPolicies: DataPolicyType[];
loaded: boolean;
loadError: any;
isOpen: boolean;
Expand All @@ -124,5 +162,6 @@ type AppManagePoliciesModalProps = {
type ModalContextViewerProps = {
state: ManagePolicyState;
applicaitonInfo: ApplicationType;
matchingPolicies: DataPolicyType[];
dispatch: React.Dispatch<ManagePolicyStateAction>;
};
Loading

0 comments on commit e40d0bf

Please sign in to comment.