Skip to content
Open
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
1 change: 0 additions & 1 deletion backend/config/enhancedPlacement

This file was deleted.

8 changes: 1 addition & 7 deletions frontend/public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
" No status: ": " No status: ",
" No violations: ": " No violations: ",
" Violations: ": " Violations: ",
"\"{{name}}\" is not an existing Ansible job": "\"{{name}}\" is not an existing Ansible job",
"\"{{name}}\" is not an existing Ansible workflow": "\"{{name}}\" is not an existing Ansible workflow",
"\"{{testSecret}}\" is not an existing Ansible credential": "\"{{testSecret}}\" is not an existing Ansible credential",
Expand Down Expand Up @@ -1313,7 +1310,6 @@
"Displays the namespace of the application resource, which by default is where the application deploys other resources. For Argo applications, this is the destination namespace.": "Displays the namespace of the application resource, which by default is where the application deploys other resources. For Argo applications, this is the destination namespace.",
"Displays the number of applications using the subscription. Click to search for all related applications.": "Displays the number of applications using the subscription. Click to search for all related applications.",
"Displays the number of local subscriptions using the channel. Click to search for all related subscriptions.": "Displays the number of local subscriptions using the channel. Click to search for all related subscriptions.",
"Displays the number of remote and local clusters where resources are deployed because of the placement.": "Displays the number of remote and local clusters where resources are deployed because of the placement.",
"Displays the number of remote and local clusters where resources for the subscription are deployed. Click to search for all related clusters.": "Displays the number of remote and local clusters where resources for the subscription are deployed. Click to search for all related clusters.",
"Displays the number of remote and local clusters where resources from the channel are deployed.": "Displays the number of remote and local clusters where resources from the channel are deployed.",
"Displays the type of the application. ": "Displays the type of the application. ",
Expand Down Expand Up @@ -2167,7 +2163,7 @@
"No permissions found": "No permissions found",
"No placement": "No placement",
"No placement decisions": "No placement decisions",
"No placement selectors found": "No placement selectors found",
"No placements found": "No placements found",
"No pods found": "No pods found",
"No polices found": "No polices found",
"No policies available for selection.": "No policies available for selection.",
Expand Down Expand Up @@ -2383,7 +2379,6 @@
"Placement YAML": "Placement YAML",
"PlacementDecisions": "PlacementDecisions",
"Placements": "Placements",
"Placements define the target clusters that must subscribe to a ClusterSet where subscriptions and application sets are delivered. This is done by cluster name, cluster resource annotation(s), or cluster resource label(s).": "Placements define the target clusters that must subscribe to a ClusterSet where subscriptions and application sets are delivered. This is done by cluster name, cluster resource annotation(s), or cluster resource label(s).",
"Platform specific data for the add node pool form will no longer automatically populate after the last node pool is removed.": "Platform specific data for the add node pool form will no longer automatically populate after the last node pool is removed.",
"Plugin requeue time in seconds": "Plugin requeue time in seconds",
"Plus": "Plus",
Expand Down Expand Up @@ -3753,7 +3748,6 @@
"You don't have any credentials yet": "You don't have any credentials yet",
"You don't have any discovered clusters yet": "You don't have any discovered clusters yet",
"You don't have any node pools yet": "You don't have any node pools yet",
"You don't have any placements": "You don't have any placements",
"You don't have any placements yet": "You don't have any placements yet",
"You don't have any policies yet": "You don't have any policies yet",
"You don't have any policies.": "You don't have any policies.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export interface Settings {
ansibleIntegration?: 'enabled' | 'disabled'
singleNodeOpenshift?: 'enabled' | 'disabled'
awsPrivateWizardStep?: 'enabled' | 'disabled'
enhancedPlacement?: 'enabled' | 'disabled'

globalSearchFeatureFlag?: 'enabled' | 'disabled'

APP_ARGO_SEARCH_RESULT_LIMIT?: string
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/lib/nock-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,14 @@ export function nockIgnoreOperatorCheck(noAnsible?: boolean) {
.reply(200, noAnsible ? mockOperatorCheckResponseNoAnsible : mockOperatorCheckResponse)
}

export function nockIgnorePlacementDebug() {
return nocked(process.env.JEST_DEFAULT_HOST as string)
.persist()
.post('/placement-debug')
.optionally()
.reply(200, { aggregatedScores: [], filteredPipelineResults: [] })
Comment thread
fxiang1 marked this conversation as resolved.
}

export function nockIgnoreClusterVersion(version = '4.20.0') {
return nocked(process.env.JEST_DEFAULT_HOST as string)
.persist()
Expand Down
31 changes: 1 addition & 30 deletions frontend/src/routes/Applications/AdvancedConfiguration.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
namespacesState,
placementDecisionsState,
placementsState,
settingsState,
subscriptionsState,
} from '../../atoms'
import { nockIgnoreApiPaths, nockIgnoreRBAC, nockSearch } from '../../lib/nock-util'
Expand Down Expand Up @@ -272,13 +271,7 @@ describe('advanced configuration page', () => {

test('should render deprecation Alert', async () => {
render(
<RecoilRoot
initializeState={(snapshot) => {
snapshot.set(settingsState, {
enhancedPlacement: 'enabled',
})
}}
>
<RecoilRoot>
<MemoryRouter initialEntries={[NavigationPath.advancedConfiguration]}>
<AdvancedConfiguration />
</MemoryRouter>
Expand All @@ -298,11 +291,6 @@ describe('advanced configuration page', () => {
render(<TestAdvancedConfigurationPage />)
await clickByTestId('channels')
})

test('should click placement option', async () => {
render(<TestAdvancedConfigurationPage />)
await clickByTestId('placements')
})
})

describe('getPlacementDecisionClusterCount', () => {
Expand Down Expand Up @@ -424,21 +412,4 @@ describe('Export from application tables', () => {
/^applicationadvancedconfiguration-channels-[\d]+\.csv$/
)
})

test('export button should produce a file for download for placements', async () => {
render(<TestAdvancedConfigurationPage defaultToggleOption="placements" />)
const { blobConstructorSpy, createElementSpy } = getCSVExportSpies()

//download for placements
await clickByLabel('export-search-result')
await clickByText('Export all to CSV')

expect(blobConstructorSpy).toHaveBeenCalledWith(
['Name,Namespace,Clusters,Created\n"test-placement","default","None","2024-06-28T03:18:48.000Z"'],
{ type: 'text/csv' }
)
expect(getCSVDownloadLink(createElementSpy)?.value.download).toMatch(
/^applicationadvancedconfiguration-placements-[\d]+\.csv$/
)
})
})
136 changes: 17 additions & 119 deletions frontend/src/routes/Applications/AdvancedConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import {
ChannelDefinition,
ChannelKind,
IResource,
PlacementApiVersionBeta,
PlacementDecision,
PlacementDefinition,
PlacementKind,
Subscription,
SubscriptionApiVersion,
Expand Down Expand Up @@ -56,21 +54,12 @@ export interface AdvancedConfigurationPageProps {

export default function AdvancedConfiguration(props: AdvancedConfigurationPageProps) {
const { t } = useTranslation()
const {
applicationsState,
channelsState,
placementsState,
placementDecisionsState,
subscriptionsState,
settingsState,
} = useSharedAtoms()
const { applicationsState, channelsState, placementDecisionsState, subscriptionsState } = useSharedAtoms()

const applications = useRecoilValue(applicationsState)
const channels = useRecoilValue(channelsState)
const placements = useRecoilValue(placementsState)
const placementDecisions = useRecoilValue(placementDecisionsState)
const subscriptions = useRecoilValue(subscriptionsState)
const settings = useRecoilValue(settingsState)

const subscriptionsWithoutLocal = subscriptions.filter((subscription) => {
return !_.endsWith(subscription.metadata.name, '-local')
Expand All @@ -81,10 +70,8 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
const navigate = useNavigate()
const [canDeleteSubscription, setCanDeleteSubscription] = useState<boolean>(false)
const [canDeleteChannel, setCanDeleteChannel] = useState<boolean>(false)
const [canDeletePlacement, setCanDeletePlacement] = useState<boolean>(false)
const ChanneltableItems: IResource[] = []
const SubscriptiontableItems: IResource[] = []
const PlacementTableItems: IResource[] = []

const localHubName = useLocalHubName()

Expand All @@ -104,14 +91,6 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
return () => canDeleteChannelPromise.abort()
}, [])

useEffect(() => {
const canDeletePlacementPromise = canUser('delete', PlacementDefinition)
canDeletePlacementPromise.promise
.then((result) => setCanDeletePlacement(result.status?.allowed!))
.catch((err) => console.error(err))
return () => canDeletePlacementPromise.abort()
}, [])

const editLink = useCallback(
function editLink(params: { resource: any; kind: string; apiversion: string }) {
const { resource, kind, apiversion } = params
Expand Down Expand Up @@ -187,7 +166,7 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
const transformedObject = {
transformed: {},
}
let clusterCount = {
const clusterCount = {
localPlacement: false,
remoteCount: 0,
}
Expand Down Expand Up @@ -249,12 +228,6 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
}
break
}
case 'Placement': {
clusterCount = getPlacementDecisionClusterCount(tableItem, clusterCount, placementDecisions, localHubName)
const clusterString = getClusterCountString(t, clusterCount)
_.set(transformedObject.transformed, 'clusterCount', clusterString)
break
}
}
// Cannot add properties directly to objects in typescript
return { ...tableItem, ...transformedObject }
Expand All @@ -266,7 +239,6 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
subscriptionsWithoutLocal.forEach((subscription) => {
SubscriptiontableItems.push(generateTransformData(subscription))
})
placements.forEach((placement) => PlacementTableItems.push(generateTransformData(placement)))

const getRowActionResolver = (item: IResource) => {
const kind = _.get(item, 'kind').toLowerCase()
Expand All @@ -290,12 +262,6 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
searchActionLabel = t('Search channel')
deleteActionLabel = t('Delete channel')
break
case PlacementKind:
canDeleteResource = canDeletePlacement
editActionLabel = t('Edit placement')
searchActionLabel = t('Search placement')
deleteActionLabel = t('Delete placement')
break
}

// edit
Expand Down Expand Up @@ -372,55 +338,6 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
return ''
}

const placementColumns = useMemo<IAcmTableColumn<IResource>[]>(
() => [
{
header: t('Name'),
cell: (resource) => {
return editLink({
resource,
kind: 'Placement',
apiversion: _.get(resource, 'apiVersion') || PlacementApiVersionBeta,
})
},
sort: 'metadata.name',
search: 'metadata.name',
exportContent: (resource) => resource.metadata?.name,
},
{
header: t('Namespace'),
cell: 'metadata.namespace',
sort: 'metadata.namespace',
exportContent: (resource) => resource.metadata?.namespace,
},
{
header: t('Clusters'),
cell: 'transformed.clusterCount',
sort: 'transformed.clusterCount',
tooltip: t(
'Displays the number of remote and local clusters where resources are deployed because of the placement.'
),
exportContent: (resource) => {
const clusters = _.get(resource, 'transformed.clusterCount')
return clusters
},
},
{
header: t('Created'),
cell: (resource) => {
return <span>{getResourceTimestamp(resource, 'metadata.creationTimestamp')}</span>
},
sort: 'metadata.creationTimestamp',
exportContent: (resource) => {
if (resource.metadata?.creationTimestamp) {
return getISOStringTimestamp(resource.metadata?.creationTimestamp)
}
},
},
],
[t, editLink]
)

const table = {
subscriptions: {
columns: useMemo<IAcmTableColumn<IResource>[]>(
Expand Down Expand Up @@ -692,15 +609,6 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
items: ChanneltableItems,
rowActionResolver: getRowActionResolver,
},
...(settings.enhancedPlacement !== 'enabled'
? {
placements: {
columns: placementColumns,
items: PlacementTableItems,
rowActionResolver: getRowActionResolver,
},
}
: {}),
}

const keyFn = useCallback(
Expand Down Expand Up @@ -733,14 +641,6 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
'Channels point to repositories where Kubernetes resources are stored, such as Git, Helm chart, or object storage repositories. Channels support multiple subscriptions from multiple targets.'
)}
/>
{settings.enhancedPlacement !== 'enabled' && (
<TerminologyCard
title={t('Placements')}
description={t(
'Placements define the target clusters that must subscribe to a ClusterSet where subscriptions and application sets are delivered. This is done by cluster name, cluster resource annotation(s), or cluster resource label(s).'
)}
/>
)}
</Split>
<Content>
<Content
Expand All @@ -761,23 +661,21 @@ export default function AdvancedConfiguration(props: AdvancedConfigurationPagePr
return (
<PageSection hasBodyWrapper={false}>
<Stack hasGutter>
{settings.enhancedPlacement === 'enabled' && (
<Alert
title={t('Page deprecation')}
isInline
variant="warning"
actionLinks={
<AlertActionLink component="a" target="_blank" rel="noreferrer" href={DOC_LINKS.DEPRECATIONS_ACM}>
{t('Learn more')}
</AlertActionLink>
}
>
<Trans
i18nKey="<bold>Deprecated:</bold> Placements are managed from the <italic>Placements</italic> tab of the <italic>Infrastructure</italic> page. Select <bold>Infrastructure</bold> > <bold>Clusters</bold> > <bold>Placements</bold>. You can also view placement details directly within individual applications or policies."
components={{ bold: <strong />, italic: <em /> }}
/>
</Alert>
)}
<Alert
title={t('Page deprecation')}
isInline
variant="warning"
actionLinks={
<AlertActionLink component="a" target="_blank" rel="noreferrer" href={DOC_LINKS.DEPRECATIONS_ACM}>
{t('Learn more')}
</AlertActionLink>
}
>
<Trans
i18nKey="<bold>Deprecated:</bold> Placements are managed from the <italic>Placements</italic> tab of the <italic>Infrastructure</italic> page. Select <bold>Infrastructure</bold> > <bold>Clusters</bold> > <bold>Placements</bold>. You can also view placement details directly within individual applications or policies."
components={{ bold: <strong />, italic: <em /> }}
/>
</Alert>
<StackItem>
<ApplicationDeploymentHighlights />
</StackItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
import { render } from '@testing-library/react'
import { MemoryRouter, Outlet, Route, Routes } from 'react-router-dom-v5-compat'
import { RecoilRoot } from 'recoil'
import {
channelsState,
managedClustersState,
namespacesState,
settingsState,
subscriptionsState,
} from '../../../../atoms'
import { channelsState, managedClustersState, namespacesState, subscriptionsState } from '../../../../atoms'
import { nockIgnoreApiPaths, nockIgnoreRBAC, nockRBAC } from '../../../../lib/nock-util'
import { clickByText, waitForNock, waitForText } from '../../../../lib/test-util'

Expand Down Expand Up @@ -657,9 +651,6 @@ describe('Overview Tab', () => {
snapshot.set(subscriptionsState, mockSubscriptions)
snapshot.set(channelsState, mockChannels)
snapshot.set(managedClustersState, mockManagedClusters)
snapshot.set(settingsState, {
enhancedPlacement: 'enabled',
})
}}
>
<MemoryRouter>
Expand Down
Loading