Skip to content

Commit

Permalink
fix: ControlledBy link for all namespaces (#3130)
Browse files Browse the repository at this point in the history
* fix: controlledby link for all namespaces

* fix: controlledby link for all resources
  • Loading branch information
chriskari authored Aug 20, 2024
1 parent 8fb0252 commit 0cda124
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/resources/ConfigMaps/ConfigMapDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function ConfigMapDetails(props) {
{
header: t('common.headers.owner'),
value: secret => (
<ControlledBy ownerReferences={secret.metadata.ownerReferences} />
<ControlledBy
ownerReferences={secret.metadata.ownerReferences}
namespace={secret.metadata.namespace}
/>
),
},
];
Expand Down
5 changes: 4 additions & 1 deletion src/resources/DaemonSets/DaemonSetDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export function DaemonSetDetails(props) {
{
header: t('common.headers.owner'),
value: resource => (
<ControlledBy ownerReferences={resource.metadata.ownerReferences} />
<ControlledBy
ownerReferences={resource.metadata.ownerReferences}
namespace={resource.metadata.namespace}
/>
),
},
];
Expand Down
5 changes: 4 additions & 1 deletion src/resources/Deployments/DeploymentDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export function DeploymentDetails(props) {
{
header: t('common.headers.owner'),
value: deployment => (
<ControlledBy ownerReferences={deployment.metadata.ownerReferences} />
<ControlledBy
ownerReferences={deployment.metadata.ownerReferences}
namespace={deployment.metadata.namespace}
/>
),
},
];
Expand Down
5 changes: 4 additions & 1 deletion src/resources/Jobs/JobDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export function JobDetails(props) {
{
header: t('common.headers.owner'),
value: job => (
<ControlledBy ownerReferences={job.metadata.ownerReferences} />
<ControlledBy
ownerReferences={job.metadata.ownerReferences}
namespace={job.metadata.namespace}
/>
),
},
];
Expand Down
5 changes: 4 additions & 1 deletion src/resources/Jobs/JobList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export const JobList = props => {
{
header: t('common.headers.owner'),
value: job => (
<ControlledBy ownerReferences={job.metadata.ownerReferences} />
<ControlledBy
ownerReferences={job.metadata.ownerReferences}
namespace={job.metadata.namespace}
/>
),
},
];
Expand Down
5 changes: 4 additions & 1 deletion src/resources/Pods/PodDetails.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/resources/ReplicaSets/ReplicaSetDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export function ReplicaSetsDetails(props) {
{
header: t('common.headers.owner'),
value: resource => (
<ControlledBy ownerReferences={resource.metadata.ownerReferences} />
<ControlledBy
ownerReferences={resource.metadata.ownerReferences}
namespace={resource.metadata.namespace}
/>
),
},
{
Expand Down
5 changes: 4 additions & 1 deletion src/resources/Secrets/SecretDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export function SecretDetails(props) {
{
header: t('common.headers.owner'),
value: secret => (
<ControlledBy ownerReferences={secret.metadata.ownerReferences} />
<ControlledBy
ownerReferences={secret.metadata.ownerReferences}
namespace={secret.metadata.namespace}
/>
),
},
];
Expand Down
5 changes: 4 additions & 1 deletion src/resources/StatefulSets/StatefulSetDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export function StatefulSetDetails(props) {
{
header: t('common.headers.owner'),
value: set => (
<ControlledBy ownerReferences={set.metadata.ownerReferences} />
<ControlledBy
ownerReferences={set.metadata.ownerReferences}
namespace={set.metadata.namespace}
/>
),
},
];
Expand Down
17 changes: 12 additions & 5 deletions src/shared/components/ControlledBy/ControlledBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import { useUrl } from 'hooks/useUrl';
import { getExtensibilityPath } from 'components/Extensibility/helpers/getExtensibilityPath';
import { Link } from '../Link/Link';

export const GoToDetailsLink = ({ kind, name, noBrackets = false }) => {
export const GoToDetailsLink = ({
kind,
name,
namespace,
noBrackets = false,
}) => {
const extensions = useRecoilValue(extensionsState);
const { namespaceUrl, clusterUrl } = useUrl();

Expand All @@ -22,14 +27,14 @@ export const GoToDetailsLink = ({ kind, name, noBrackets = false }) => {
if (resource) {
const partialPath = pluralize(kind || '')?.toLowerCase();
if (resource.namespaced) {
path = namespaceUrl(`${partialPath}/${name}`);
path = namespaceUrl(`${partialPath}/${name}`, { namespace });
} else {
path = clusterUrl(`${partialPath}/${name}`);
}
} else if (extResource) {
const partialPath = getExtensibilityPath(extResource.general);
if (extResource.general.scope === 'namespace') {
path = namespaceUrl(`${partialPath}/${name}`);
path = namespaceUrl(`${partialPath}/${name}`, { namespace });
} else {
path = clusterUrl(`${partialPath}/${name}`);
}
Expand All @@ -48,6 +53,7 @@ export const GoToDetailsLink = ({ kind, name, noBrackets = false }) => {

export const ControlledBy = ({
ownerReferences,
namespace,
kindOnly,
placeholder = EMPTY_TEXT_PLACEHOLDER,
}) => {
Expand All @@ -57,9 +63,9 @@ export const ControlledBy = ({
)
return placeholder;

const OwnerRef = ({ owner, className }) => {
const OwnerRef = ({ owner }) => {
return (
<div key={owner.name} className={className}>
<div key={owner.name}>
{owner.kind}
{!kindOnly && (
<>
Expand All @@ -68,6 +74,7 @@ export const ControlledBy = ({
kind={owner.kind}
apiVersion={owner.apiVersion}
name={owner.name}
namespace={namespace}
/>
</>
)}
Expand Down

0 comments on commit 0cda124

Please sign in to comment.