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

ACM-15806 Fix missed hardcoded local-cluster in App UI #4102

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function ApplicationOverviewPageContent() {
const namespaces = useRecoilValue(namespacesState)

const managedClusters = useAllClusters(true)
const localCluster = managedClusters.find((cls) => cls.name === localClusterStr)
const localCluster = managedClusters.find((cls) => cls.labels && cls.labels[localClusterStr] === 'true')
const [modalProps, setModalProps] = useState<ISyncResourceModalProps | { open: false }>({
open: false,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class ArgoAppDetailsContainer extends Component {
},
},
}
const editLink = createEditLink(searchResultToNode)
const editLink = createEditLink(searchResultToNode, this.props.hubClusterName)
const appResourceYaml = {
action: 'show_resource_yaml',
editLink,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('ArgoAppDetailsContainer with no apps', () => {
argoAppList={mockData.argoAppList}
t={t}
argoAppDetailsContainerControl={mockData.argoAppDetailsContainerControl}
hubClusterName="local-cluster"
/>
))

Expand Down Expand Up @@ -83,6 +84,7 @@ describe('ArgoAppDetailsContainer with no apps', () => {
argoAppList={mockData.argoAppList}
t={t}
argoAppDetailsContainerControl={mockData.argoAppDetailsContainerControl}
hubClusterName="local-cluster"
/>
))

Expand Down Expand Up @@ -139,6 +141,7 @@ describe('ArgoAppDetailsContainer test functions', () => {
ref={(node) => {
instance = node
}}
hubClusterName="local-cluster"
/>
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,14 @@ class DetailsView extends Component {
}

renderRelatedArgoAppDetails({ relatedargoappsdata }, t) {
const { argoAppDetailsContainerControl } = this.props
const { argoAppDetailsContainerControl, hubClusterName } = this.props
return (
<div className="sectionContent" key={Math.random()}>
<ArgoAppDetailsContainer
argoAppList={relatedargoappsdata.argoAppList}
t={t}
argoAppDetailsContainerControl={argoAppDetailsContainerControl}
hubClusterName={hubClusterName}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const addPropertyToList = (list, data) => {
return list
}

export const createEditLink = (node, overrideKind, overrideCluster, overrideApiVersion) => {
export const createEditLink = (node, hubClusterName, overrideKind, overrideCluster, overrideApiVersion) => {
let kind = overrideKind || _.get(node, 'specs.raw.kind') || _.get(node, 'kind')
const apigroup = _.get(node, 'apigroup')
const apiversion = _.get(node, 'apiversion')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ describe('createEditLink subscriptionstatus', () => {
const apiversion = 'apps.open-cluster-management.io/v1alpha1'

it('returns subscriptionstatus link', () => {
expect(createEditLink(node, kind, cluster, apiversion)).toEqual(
expect(createEditLink(node, 'local-cluster', kind, cluster, apiversion)).toEqual(
'/multicloud/search/resources/yaml?apiversion=apps.open-cluster-management.io%2Fv1alpha1&cluster=local-cluster&kind=SubscriptionStatus&name=feng-wordpress-subscription-1&namespace=feng-wordpress'
)
})
Expand All @@ -1866,7 +1866,7 @@ describe('createEditLink deployment', () => {
namespace: 'default',
}
it('returns deployment link', () => {
expect(createEditLink(node)).toEqual(
expect(createEditLink(node, 'local-cluster')).toEqual(
'/multicloud/search/resources/yaml?apiversion=apps%2Fv1&cluster=local-cluster&kind=deployment&name=mydeploy&namespace=default'
)
})
Expand All @@ -1881,7 +1881,7 @@ describe('createEditLink kind undefined', () => {
namespace: 'default',
}
it('returns non-working link', () => {
expect(createEditLink(node)).toEqual(
expect(createEditLink(node, 'local-cluster')).toEqual(
'/multicloud/search/resources/yaml?apiversion=apps%2Fv1&cluster=local-cluster&name=mydeploy&namespace=default'
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

import queryString from 'query-string'

export const getEditLink = ({ name, namespace, kind, apiVersion, cluster = 'local-cluster' }) => {
export const getEditLink = ({ name, namespace, kind, apiVersion, cluster }, hubClusterName) => {
const cls = cluster ? cluster : hubClusterName
return `/multicloud/search/resources/yaml?${queryString.stringify({
cluster,
cluster: cls,
name,
namespace,
kind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ export const setSubscriptionDeployStatus = (node, details, activeFilters, t, hub
})
const subscriptionStatusLink = createEditLink(
node,
hubClusterName,
'SubscriptionStatus',
subsCluster,
'apps.open-cluster-management.io/v1alpha1'
Expand Down Expand Up @@ -1202,7 +1203,7 @@ export const setPodDeployStatus = (node, details, activeFilters, t, hubClusterNa
data: {
action: showResourceYaml,
cluster: pod.cluster,
editLink: createEditLink(pod),
editLink: createEditLink(pod, hubClusterName),
},
},
indent: true,
Expand Down Expand Up @@ -1339,7 +1340,7 @@ export const setResourceDeployStatus = (node, details, activeFilters, t, hubClus
data: {
action: showResourceYaml,
cluster: res.cluster,
editLink: createEditLink(res),
editLink: createEditLink(res, hubClusterName),
},
},
indent: true,
Expand Down Expand Up @@ -1438,7 +1439,7 @@ export const setResourceDeployStatus = (node, details, activeFilters, t, hubClus
data: {
action: showResourceYaml,
cluster: res.cluster,
editLink: createEditLink(res),
editLink: createEditLink(res, hubClusterName),
},
},
indent: true,
Expand Down