diff --git a/managed/ui/src/components/universes/UniverseDetail/UniverseDetail.js b/managed/ui/src/components/universes/UniverseDetail/UniverseDetail.js index 3d8d38c921f5..b041891199a9 100644 --- a/managed/ui/src/components/universes/UniverseDetail/UniverseDetail.js +++ b/managed/ui/src/components/universes/UniverseDetail/UniverseDetail.js @@ -75,7 +75,7 @@ import { RuntimeConfigKey, UNIVERSE_TASKS } from '../../../redesign/helpers/cons import { isActionFrozen } from '../../../redesign/helpers/utils'; import { getCurrentVersion, - isVerionPGSupported + isVersionPGSupported } from '../../../redesign/features/universe/universe-form/utils/helpers'; //icons @@ -504,7 +504,7 @@ class UniverseDetail extends Component { const isDeleteUniverseDisabled = isActionFrozen(allowedTasks, UNIVERSE_TASKS.DELETE_UNIVERSE) || isK8ActionsDisabled; - const isPGCompatibilitySupported = isVerionPGSupported( + const isPGCompatibilitySupported = isVersionPGSupported( getCurrentVersion(currentUniverse.data.universeDetails) ); @@ -1123,11 +1123,18 @@ class UniverseDetail extends Component { - + Edit Postgres Compatibility @@ -1138,11 +1145,18 @@ class UniverseDetail extends Component { - + Edit YSQL Configuration @@ -1153,11 +1167,18 @@ class UniverseDetail extends Component { - + Edit YCQL Configuration diff --git a/managed/ui/src/redesign/features/universe/universe-actions/edit-gflags/EditGflags.tsx b/managed/ui/src/redesign/features/universe/universe-actions/edit-gflags/EditGflags.tsx index 37e7be64da73..e265ac899b9e 100644 --- a/managed/ui/src/redesign/features/universe/universe-actions/edit-gflags/EditGflags.tsx +++ b/managed/ui/src/redesign/features/universe/universe-actions/edit-gflags/EditGflags.tsx @@ -145,6 +145,7 @@ export const EditGflagsModal: FC = ({ if (primaryCluster && !_.isEmpty(primaryCluster)) { const { masterGFlags, tserverGFlags } = transformFlagArrayToObject(gFlags); primaryCluster.userIntent.specificGFlags = { + ...primaryCluster.userIntent.specificGFlags, inheritFromPrimary: false, perProcessFlags: { value: { @@ -160,12 +161,14 @@ export const EditGflagsModal: FC = ({ if (asyncCluster && !_.isEmpty(asyncCluster)) { if (inheritFlagsFromPrimary) { asyncCluster.userIntent.specificGFlags = { + ...asyncCluster.userIntent.specificGFlags, inheritFromPrimary: true, perProcessFlags: {} }; } else { const { tserverGFlags } = transformFlagArrayToObject(asyncGflags); asyncCluster.userIntent.specificGFlags = { + ...asyncCluster.userIntent.specificGFlags, inheritFromPrimary: false, perProcessFlags: { value: { diff --git a/managed/ui/src/redesign/features/universe/universe-actions/edit-pg-compatibility/EditPGCompatibilityModal.tsx b/managed/ui/src/redesign/features/universe/universe-actions/edit-pg-compatibility/EditPGCompatibilityModal.tsx index fe94ad694904..4650a0541e9b 100644 --- a/managed/ui/src/redesign/features/universe/universe-actions/edit-pg-compatibility/EditPGCompatibilityModal.tsx +++ b/managed/ui/src/redesign/features/universe/universe-actions/edit-pg-compatibility/EditPGCompatibilityModal.tsx @@ -1,5 +1,5 @@ import { FC } from 'react'; -import _ from 'lodash'; +import { get, cloneDeep } from 'lodash'; import { toast } from 'react-toastify'; import { useForm } from 'react-hook-form'; import { useMutation } from 'react-query'; @@ -15,6 +15,9 @@ import { import { api } from '../../universe-form/utils/api'; import { EditGflagPayload, UpgradeOptions } from '../edit-gflags/GflagHelper'; import { isPGEnabledFromIntent } from '../../universe-form/utils/helpers'; +import { RBAC_ERR_MSG_NO_PERM } from '../../../rbac/common/validator/ValidatorUtils'; +import { hasNecessaryPerm } from '../../../rbac/common/RbacApiPermValidator'; +import { ApiPermissionMap } from '../../../rbac/ApiAndUserPermMapping'; import { Universe } from '../../universe-form/utils/dto'; import { DEFAULT_SLEEP_INTERVAL_IN_MS } from '../../universe-form/utils/constants'; import { GFLAG_GROUPS } from '../../../../helpers/constants'; @@ -93,11 +96,10 @@ export const EditPGCompatibilityModal: FC = ({ const classes = useStyles(); const { universeDetails, universeUUID } = universeData; const { nodePrefix } = universeDetails; - let primaryCluster = _.cloneDeep(getPrimaryCluster(universeDetails)); - const universeName = _.get(primaryCluster, 'userIntent.universeName'); + let primaryCluster = cloneDeep(getPrimaryCluster(universeDetails)); + const universeName = get(primaryCluster, 'userIntent.universeName'); const isPGEnabled = primaryCluster ? isPGEnabledFromIntent(primaryCluster?.userIntent) : false; - console.log(universeDetails); const { control, handleSubmit, watch } = useForm({ defaultValues: { enablePGCompatibitilty: isPGEnabled ? true : false @@ -110,7 +112,6 @@ export const EditPGCompatibilityModal: FC = ({ }, { onSuccess: () => { - toast.success('Upgrade Gflags in progress'); onClose(); }, onError: (error) => { @@ -127,12 +128,12 @@ export const EditPGCompatibilityModal: FC = ({ const payload: EditGflagPayload = { nodePrefix, universeUUID, - sleepAfterMasterRestartMillis: _.get( + sleepAfterMasterRestartMillis: get( universeDetails, 'sleepAfterMasterRestartMillis', DEFAULT_SLEEP_INTERVAL_IN_MS ), - sleepAfterTServerRestartMillis: _.get( + sleepAfterTServerRestartMillis: get( universeDetails, 'sleepAfterTServerRestartMillis', DEFAULT_SLEEP_INTERVAL_IN_MS @@ -165,6 +166,11 @@ export const EditPGCompatibilityModal: FC = ({ } }); + const canEditGFlags = hasNecessaryPerm({ + onResource: universeUUID, + ...ApiPermissionMap.UPGRADE_UNIVERSE_GFLAGS + }); + return ( = ({ overrideWidth={'600px'} submitTestId="EditPGCompatibilityModal-Submit" cancelTestId="EditPGCompatibilityModal-Cancel" + buttonProps={{ + primary: { + disabled: !canEditGFlags + } + }} + submitButtonTooltip={!canEditGFlags ? RBAC_ERR_MSG_NO_PERM : ''} > ({ })); export const PGCompatibiltyField: FC = ({ disabled }) => { - const { control } = useFormContext(); + const { control, setValue } = useFormContext(); const classes = useStyles(); const { t } = useTranslation(); //watchers const dbVersionValue = useWatch({ name: SOFTWARE_VERSION_FIELD }); - const isPGSupported = isVerionPGSupported(dbVersionValue); + const isPGSupported = isVersionPGSupported(dbVersionValue); + + useUpdateEffect(() => { + //set toggle to false if unsupported db version is selected + if (!isVersionPGSupported(dbVersionValue)) setValue(PG_COMPATIBILITY_FIELD, false); + }, [dbVersionValue]); return ( diff --git a/managed/ui/src/redesign/features/universe/universe-form/utils/helpers.ts b/managed/ui/src/redesign/features/universe/universe-form/utils/helpers.ts index 3a9ada27e8fc..88f6ffe9642a 100644 --- a/managed/ui/src/redesign/features/universe/universe-form/utils/helpers.ts +++ b/managed/ui/src/redesign/features/universe/universe-form/utils/helpers.ts @@ -399,7 +399,6 @@ export const createUniverse = async ({ //patch - end // now everything is ready to create universe - console.log(finalPayload, 'Final'); const response = await api.createUniverse(finalPayload); //redirect to task page @@ -511,7 +510,7 @@ export const getKubernetesDiffClusterData = ( }; }; -export const isVerionPGSupported = (dbVersion: string) => { +export const isVersionPGSupported = (dbVersion: string) => { return ( compareYBSoftwareVersions({ versionA: dbVersion,