Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/components/BrewPushModal/BrewPushModalButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import { Build, GroupBuild } from 'common/pnc-api-types-ts';

import { ProtectedButton } from 'components/Button/Button';

import { BREW } from 'utils/features';

interface IBrewPushModalButtonProps {
toggleModal: () => void;
build: Build | GroupBuild;
}

export const BrewPushModalButton = ({ toggleModal, build }: IBrewPushModalButtonProps) => {
const disabledButtonReason = build.status !== 'SUCCESS' ? 'Build was not successful.' : '';
const disabledButtonReason = !BREW.isEnabled
? BREW.disabledReason
: build.status !== 'SUCCESS'
? 'Build was not successful.'
: '';

return (
<ProtectedButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import * as projectApi from 'services/projectApi';
import * as scmRepositoryApi from 'services/scmRepositoryApi';
import { uiLogger } from 'services/uiLogger';

import { SERVICE_BUILD_CATEGORY } from 'utils/features';
import { BREW, SERVICE_BUILD_CATEGORY } from 'utils/features';
import { maxLengthValidator, validateBuildScript, validateScmUrl } from 'utils/formValidationHelpers';
import { createSafePatch } from 'utils/patchHelper';
import { generatePageTitle } from 'utils/titleHelper';
Expand Down Expand Up @@ -351,7 +351,7 @@ export const BuildConfigCreateEditPage = ({ isEditPage = false }: IBuildConfigCr
environment: { id: selectedEnvironment!.id },
buildType: data.buildType,
buildScript: data.buildScript,
brewPullActive: data.brewPullActive,
brewPullActive: BREW.isEnabled ? data.brewPullActive : undefined,
scmRevision: data.scmRevision,
productVersion: selectedProductVersion ? { id: selectedProductVersion.id } : undefined,
parameters: Object.fromEntries(Object.entries(buildParamData).map(([k, v]) => [k, v.value])),
Expand Down Expand Up @@ -408,7 +408,8 @@ export const BuildConfigCreateEditPage = ({ isEditPage = false }: IBuildConfigCr
environment: selectedEnvironment ? { id: selectedEnvironment.id } : undefined,
buildType: data.buildType,
buildScript: data.buildScript,
brewPullActive: data.buildType !== buildTypeData.NPM.id && !!data.brewPullActive,
// not sent when Brew is disabled, original value is kept
brewPullActive: BREW.isEnabled ? data.buildType !== buildTypeData.NPM.id && !!data.brewPullActive : undefined,
scmRepository: selectedScmRepository ? { id: selectedScmRepository.id } : undefined,
scmRevision: data.scmRevision,
productVersion: selectedProductVersion ? { id: selectedProductVersion.id } : undefined,
Expand Down Expand Up @@ -710,10 +711,19 @@ export const BuildConfigCreateEditPage = ({ isEditPage = false }: IBuildConfigCr
<FormInput<boolean>
{...register<boolean>(buildConfigEntityAttributes.brewPullActive.id, fieldConfigs.brewPullActive)}
render={({ value, onChange, onBlur }) => {
const isDisabled = getFieldValue(buildConfigEntityAttributes.buildType.id) === buildTypeData.NPM.id;
const isNpmBuildType = getFieldValue(buildConfigEntityAttributes.buildType.id) === buildTypeData.NPM.id;
const isDisabled = !BREW.isEnabled || isNpmBuildType;

return (
<TooltipWrapper tooltip={isDisabled ? 'Cannot set Brew pull active for the NPM build type.' : undefined}>
<TooltipWrapper
tooltip={
!BREW.isEnabled
? BREW.disabledReason
: isNpmBuildType
? 'Cannot set Brew pull active for the NPM build type.'
: undefined
}
>
<Switch
id={buildConfigEntityAttributes.brewPullActive.id}
name={buildConfigEntityAttributes.brewPullActive.id}
Expand Down
21 changes: 20 additions & 1 deletion src/components/BuildConfigDetailPage/BuildConfigDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CodeBlock, CodeBlockCode, Grid, GridItem } from '@patternfly/react-core';
import { InfoCircleIcon } from '@patternfly/react-icons';
import { useState } from 'react';
import { Link } from 'react-router';

Expand All @@ -23,10 +24,13 @@ import { ScmRepositoryLink } from 'components/ScmRepositoryLink/ScmRepositoryLin
import { ServiceContainerLoading } from 'components/ServiceContainers/ServiceContainerLoading';
import { Toolbar } from 'components/Toolbar/Toolbar';
import { ToolbarItem } from 'components/Toolbar/ToolbarItem';
import { TooltipWrapper } from 'components/TooltipWrapper/TooltipWrapper';
import { UpgradeEnvironmentModal } from 'components/UpgradeEnvironmentModal/UpgradeEnvironmentModal';
import { UpgradeEnvironmentModalButton } from 'components/UpgradeEnvironmentModal/UpgradeEnvironmentModalButton';
import { WarningLabel } from 'components/WarningLabel/WarningLabel';

import { BREW } from 'utils/features';

interface IBuildConfigDetailProps {
serviceContainerBuildConfig: IServiceContainerState<BuildConfiguration | BuildConfigurationRevision>;
serviceContainerProductVersion?: IServiceContainerState<ProductVersion>;
Expand Down Expand Up @@ -135,7 +139,22 @@ export const BuildConfigDetail = ({
)}
</AttributesItem>
<AttributesItem title={buildConfigEntityAttributes.brewPullActive.title}>
{serviceContainerBuildConfig.data?.brewPullActive + ''}
{BREW.isEnabled ? (
serviceContainerBuildConfig.data?.brewPullActive?.toString()
) : (
<TooltipWrapper tooltip={BREW.disabledReason}>
<span>
<InfoCircleIcon />{' '}
<EmptyStateSymbol
text={`Disabled${
serviceContainerBuildConfig.data?.brewPullActive !== undefined
? ` (original value: ${serviceContainerBuildConfig.data.brewPullActive})`
: ''
}`}
/>
</span>
</TooltipWrapper>
)}
</AttributesItem>
{serviceContainerProductVersion && (
<AttributesItem title={buildConfigEntityAttributes.productVersion.title}>
Expand Down
21 changes: 19 additions & 2 deletions src/components/BuildDetailPage/BuildDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CodeBlock, CodeBlockCode, Grid, GridItem } from '@patternfly/react-core';
import { ExclamationTriangleIcon } from '@patternfly/react-icons';
import { ExclamationTriangleIcon, InfoCircleIcon } from '@patternfly/react-icons';
import { PropsWithChildren, useCallback, useEffect } from 'react';

import { buildEntityAttributes } from 'common/buildEntityAttributes';
Expand Down Expand Up @@ -32,11 +32,13 @@ import { ScmRepositoryUrl } from 'components/ScmRepositoryUrl/ScmRepositoryUrl';
import { ServiceContainerLoading } from 'components/ServiceContainers/ServiceContainerLoading';
import { Toolbar } from 'components/Toolbar/Toolbar';
import { ToolbarItem } from 'components/Toolbar/ToolbarItem';
import { TooltipWrapper } from 'components/TooltipWrapper/TooltipWrapper';
import { Username } from 'components/Username/Username';

import * as buildApi from 'services/buildApi';
import * as webConfigService from 'services/webConfigService';

import { BREW } from 'utils/features';
import { calculateDuration } from 'utils/utils';

interface INotAvailableBasedOnProps {
Expand Down Expand Up @@ -333,7 +335,22 @@ export const BuildDetailPage = () => {
</AttributesItem>

<AttributesItem title={buildEntityAttributes['buildConfigRevision.brewPullActive'].title}>
{serviceContainerBuild.data?.buildConfigRevision?.brewPullActive ? 'enabled' : 'disabled'}
{BREW.isEnabled ? (
serviceContainerBuild.data?.buildConfigRevision?.brewPullActive?.toString()
) : (
<TooltipWrapper tooltip={BREW.disabledReason}>
<span>
<InfoCircleIcon />{' '}
<EmptyStateSymbol
text={`Disabled${
serviceContainerBuild.data?.buildConfigRevision?.brewPullActive !== undefined
? ` (original value: ${serviceContainerBuild.data.buildConfigRevision.brewPullActive})`
: ''
}`}
/>
</span>
</TooltipWrapper>
)}
</AttributesItem>
</Attributes>
</ContentBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { TooltipWrapper } from 'components/TooltipWrapper/TooltipWrapper';

import * as productMilestoneApi from 'services/productMilestoneApi';

import { BREW } from 'utils/features';

const fieldConfigs = {
skipBrewPush: {
value: false,
value: !BREW.isEnabled,
},
} satisfies IFieldConfigs;

Expand All @@ -31,7 +33,7 @@ export const ProductMilestoneCloseModal = ({ isModalOpen, toggleModal, productMi

const confirmModal = (data: IFieldValues) => {
return serviceContainerProductMilestoneClose.run({
serviceData: { id: productMilestone.id, data: { skipBrewPush: data.skipBrewPush } },
serviceData: { id: productMilestone.id, data: { skipBrewPush: !BREW.isEnabled || data.skipBrewPush } },
onError: () => console.error('Failed to close Product Milestone.'),
});
};
Expand Down Expand Up @@ -61,13 +63,16 @@ export const ProductMilestoneCloseModal = ({ isModalOpen, toggleModal, productMi
<FormInput<boolean>
{...register<boolean>(productMilestoneCloseRequestEntityAttributes.skipBrewPush.id, fieldConfigs.skipBrewPush)}
render={({ value, ...rest }) => (
<Switch
id={productMilestoneCloseRequestEntityAttributes.skipBrewPush.id}
name={productMilestoneCloseRequestEntityAttributes.skipBrewPush.id}
label="Enabled"
isChecked={value}
{...rest}
/>
<TooltipWrapper tooltip={!BREW.isEnabled ? BREW.disabledReason : undefined}>
<Switch
id={productMilestoneCloseRequestEntityAttributes.skipBrewPush.id}
name={productMilestoneCloseRequestEntityAttributes.skipBrewPush.id}
label="Enabled"
isChecked={value}
isDisabled={!BREW.isEnabled}
{...rest}
/>
</TooltipWrapper>
)}
/>
</FormGroup>
Expand All @@ -78,17 +83,19 @@ export const ProductMilestoneCloseModal = ({ isModalOpen, toggleModal, productMi
title="Milestone end date will be set. If the Milestone is marked as current, the current status will be removed. No more Builds will be added to the Milestone."
/>
</FormAlert>
<FormAlert>
<Alert
variant={getFieldValue(productMilestoneCloseRequestEntityAttributes.skipBrewPush.id) ? 'warning' : 'info'}
isInline
title={
getFieldValue(productMilestoneCloseRequestEntityAttributes.skipBrewPush.id)
? 'No Build Push will be performed.'
: 'New Brew Push will be performed for each successful Build in the Milestone.'
}
/>
</FormAlert>
{BREW.isEnabled && (
<FormAlert>
<Alert
variant={getFieldValue(productMilestoneCloseRequestEntityAttributes.skipBrewPush.id) ? 'warning' : 'info'}
isInline
title={
getFieldValue(productMilestoneCloseRequestEntityAttributes.skipBrewPush.id)
? 'No Build Push will be performed.'
: 'New Brew Push will be performed for each successful Build in the Milestone.'
}
/>
</FormAlert>
)}
</Form>
</ActionModal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ServiceContainerLoading } from 'components/ServiceContainers/ServiceCon
import * as productApi from 'services/productApi';
import * as productVersionApi from 'services/productVersionApi';

import { BREW } from 'utils/features';
import { maxLengthValidator, validateProductVersionName } from 'utils/formValidationHelpers';
import { createSafePatch } from 'utils/patchHelper';
import { generatePageTitle } from 'utils/titleHelper';
Expand All @@ -38,7 +39,7 @@ const fieldConfigs = {
],
},
'attributes.brewTagPrefix': {
isRequired: true,
isRequired: BREW.isEnabled,
validators: [maxLengthValidator(255)],
},
} satisfies IFieldConfigs;
Expand Down Expand Up @@ -97,7 +98,7 @@ export const ProductVersionCreateEditPage = ({ isEditPage = false }: IProductVer
const submitEdit = (data: IFieldValues) => {
const patchData = createSafePatch(serviceContainerEditPageGet.data!, {
version: data.version,
attributes: { BREW_TAG_PREFIX: data['attributes.brewTagPrefix'] },
attributes: BREW.isEnabled ? { BREW_TAG_PREFIX: data['attributes.brewTagPrefix'] } : undefined,
});

return serviceContainerEditPagePatch.run({
Expand Down Expand Up @@ -146,12 +147,13 @@ export const ProductVersionCreateEditPage = ({ isEditPage = false }: IProductVer
</FormGroup>
{isEditPage && (
<FormGroup
isRequired
isRequired={BREW.isEnabled}
label={productVersionEntityAttributes['attributes.brewTagPrefix'].title}
fieldId={productVersionEntityAttributes['attributes.brewTagPrefix'].id}
>
<TextInput
isRequired
isRequired={BREW.isEnabled}
isDisabled={!BREW.isEnabled}
type="text"
id={productVersionEntityAttributes['attributes.brewTagPrefix'].id}
name={productVersionEntityAttributes['attributes.brewTagPrefix'].id}
Expand All @@ -161,6 +163,9 @@ export const ProductVersionCreateEditPage = ({ isEditPage = false }: IProductVer
fieldConfigs['attributes.brewTagPrefix']
)}
/>
<FormInputHelperText variant="default" isHidden={BREW.isEnabled}>
{BREW.disabledReason}
</FormInputHelperText>
<FormInputHelperText variant="error">
{getFieldErrors(productVersionEntityAttributes['attributes.brewTagPrefix'].id)}
</FormInputHelperText>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Grid, GridItem } from '@patternfly/react-core';
import { InfoCircleIcon } from '@patternfly/react-icons';
import { useCallback, useEffect, useMemo } from 'react';
import { Link } from 'react-router';

Expand All @@ -18,17 +19,20 @@ import { CardTitle } from 'components/CardFlex/CardTitle';
import { CardValue } from 'components/CardFlex/CardValue';
import { StackedBarChart } from 'components/Charts/StackedBarChart';
import { ContentBox } from 'components/ContentBox/ContentBox';
import { EmptyStateSymbol } from 'components/EmptyStateSymbol/EmptyStateSymbol';
import { PageSectionHeader } from 'components/PageSectionHeader/PageSectionHeader';
import { Pagination } from 'components/Pagination/Pagination';
import { ProductMilestoneReleaseLabel } from 'components/ProductMilestoneReleaseLabel/ProductMilestoneReleaseLabel';
import { useServiceContainerProductVersion } from 'components/ProductVersionPages/ProductVersionPages';
import { ServiceContainerLoading } from 'components/ServiceContainers/ServiceContainerLoading';
import { Toolbar } from 'components/Toolbar/Toolbar';
import { ToolbarItem } from 'components/Toolbar/ToolbarItem';
import { TooltipWrapper } from 'components/TooltipWrapper/TooltipWrapper';

import * as productVersionApi from 'services/productVersionApi';

import { stackedBarChartDataTransform, stackedBarChartHeight, stackedBarChartLabelTransform } from 'utils/dataTransformHelper';
import { BREW } from 'utils/features';

export const ProductVersionDetailPage = () => {
const { productVersionId } = useParamsRequired();
Expand Down Expand Up @@ -124,7 +128,22 @@ export const ProductVersionDetailPage = () => {
{serviceContainerProductVersion.data?.product?.description}
</AttributesItem>
<AttributesItem title={productVersionEntityAttributes['attributes.brewTagPrefix'].title}>
{serviceContainerProductVersion.data?.attributes?.BREW_TAG_PREFIX}
{BREW.isEnabled ? (
serviceContainerProductVersion.data?.attributes?.BREW_TAG_PREFIX
) : (
<TooltipWrapper tooltip={BREW.disabledReason}>
<span>
<InfoCircleIcon />{' '}
<EmptyStateSymbol
text={`Disabled${
serviceContainerProductVersion.data?.attributes?.BREW_TAG_PREFIX
? ` (original value: ${serviceContainerProductVersion.data.attributes.BREW_TAG_PREFIX})`
: ''
}`}
/>
</span>
</TooltipWrapper>
)}
</AttributesItem>
<AttributesItem title={productVersionEntityAttributes.currentProductMilestone.title}>
{serviceContainerProductVersion.data?.currentProductMilestone?.id && (
Expand Down
8 changes: 8 additions & 0 deletions src/utils/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ export const SERVICE_BUILD_CATEGORY = {
isEnabled: import.meta.env.VITE_PNC_INSTANCE !== 'primary',
disabledReason: 'SERVICE Build Category is not supported.',
};

/**
* Whether Brew can be used, to push (Group) Builds to Brew, or to activate Brew Pull in Build Configs.
*/
export const BREW = {
isEnabled: import.meta.env.VITE_PNC_INSTANCE !== 'primary',
disabledReason: 'Brew is not supported.',
};
Loading