Skip to content

Commit

Permalink
Namespace - show name, not company (outside insights)
Browse files Browse the repository at this point in the history
for non-insights mode, just show namespace name always, instead of preferring namespace.company for the title

Affects collection header (logo alt), collection list item, collection card, namespace header and namespace card.

Issue: AAH-2722
  • Loading branch information
himdel committed Sep 26, 2023
1 parent a7e781b commit cee366e
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGES/2722.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show namespace name, not company
10 changes: 6 additions & 4 deletions src/components/cards/collection-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { CollectionNumericLabel, Logo, SignatureBadge } from 'src/components';
import { Constants } from 'src/constants';
import { useContext } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';
import { convertContentSummaryCounts } from 'src/utilities';
import { convertContentSummaryCounts, namespaceTitle } from 'src/utilities';

interface IProps extends CollectionVersionSearch {
className?: string;
Expand All @@ -40,14 +40,16 @@ export const CollectionCard = ({
const { featureFlags } = useContext();
const MAX_DESCRIPTION_LENGTH = 60;

const company = namespace?.company || collection_version.namespace;
const nsTitle = namespaceTitle(
namespace || { name: collection_version.namespace },
);
const contentSummary = convertContentSummaryCounts(collection_version);

return (
<Card className={cx('hub-c-card-collection-container ', className)}>
<CardHeader className='logo-row'>
<Logo
alt={t`${company} logo`}
alt={t`${nsTitle} logo`}
fallbackToDefault
image={namespace?.avatar_url}
size='40px'
Expand Down Expand Up @@ -103,7 +105,7 @@ export const CollectionCard = ({
namespace: collection_version.namespace,
})}
>
{company}
{nsTitle}
</Link>
</Trans>
</Text>
Expand Down
35 changes: 18 additions & 17 deletions src/components/cards/namespace-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,46 @@ import {
import React from 'react';
import { Link } from 'react-router-dom';
import { Logo } from 'src/components';
import { namespaceTitle } from 'src/utilities';
import './cards.scss';

// Use snake case to match field types provided py python API so that the
// spread operator can be used.
interface IProps {
avatar_url: string;
name: string;
company: string;
namespace: {
avatar_url: string;
name: string;
company: string;
};
namespaceURL?: string;
}

export const NamespaceCard = ({
avatar_url,
name,
company,
namespaceURL,
}: IProps) => {
export const NamespaceCard = ({ namespace, namespaceURL }: IProps) => {
const { avatar_url, name } = namespace;
const title = namespaceTitle(namespace);

const MAX_DESCRIPTION_LENGTH = 26;
return (
<Card className='hub-c-card-ns-container'>
<CardHeader>
<CardHeaderMain>
<Logo
alt={t`${company} logo`}
alt={t`${title} logo`}
fallbackToDefault
image={avatar_url}
size='40px'
unlockWidth
/>
</CardHeaderMain>
</CardHeader>
<Tooltip content={company || name}>
<CardTitle>
{getDescription(company || name, MAX_DESCRIPTION_LENGTH)}
</CardTitle>
</Tooltip>
<Tooltip content={name}>
<CardBody>{getDescription(name, MAX_DESCRIPTION_LENGTH)}</CardBody>
<Tooltip content={title}>
<CardTitle>{getDescription(title, MAX_DESCRIPTION_LENGTH)}</CardTitle>
</Tooltip>
{title !== name ? (
<Tooltip content={name}>
<CardBody>{getDescription(name, MAX_DESCRIPTION_LENGTH)}</CardBody>
</Tooltip>
) : null}

{namespaceURL && (
<CardFooter>
Expand Down
14 changes: 10 additions & 4 deletions src/components/collection-list/collection-list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import {
} from 'src/components';
import { useContext } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';
import { chipGroupProps, convertContentSummaryCounts } from 'src/utilities';
import {
chipGroupProps,
convertContentSummaryCounts,
namespaceTitle,
} from 'src/utilities';
import { SignatureBadge } from '../signing';
import './list-item.scss';

Expand Down Expand Up @@ -54,13 +58,15 @@ export const CollectionListItem = ({
const { featureFlags } = useContext();
const cells = [];

const company = namespace?.company || collection_version.namespace;
const nsTitle = namespaceTitle(
namespace || { name: collection_version.namespace },
);

if (showNamespace) {
cells.push(
<DataListCell isFilled={false} alignRight={false} key='ns'>
<Logo
alt={t`${company} logo`}
alt={t`${nsTitle} logo`}
fallbackToDefault
image={namespace?.avatar_url}
size='130px'
Expand Down Expand Up @@ -97,7 +103,7 @@ export const CollectionListItem = ({
namespace: collection_version.namespace,
})}
>
{company}
{nsTitle}
</Link>
</Trans>
</Text>
Expand Down
7 changes: 5 additions & 2 deletions src/components/headers/collection-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
ParamHelper,
canSignNamespace,
errorMessage,
namespaceTitle,
parsePulpIDFromURL,
repositoryRemoveCollection,
waitForTask,
Expand Down Expand Up @@ -225,7 +226,9 @@ export class CollectionHeader extends React.Component<IProps, IState> {
const { collection_version, namespace_metadata: namespace } = collection;
const { name: collectionName, version } = collection_version;

const company = namespace?.company || collection_version.namespace;
const nsTitle = namespaceTitle(
namespace || { name: collection_version.namespace },
);

if (redirect) {
return <Navigate to={redirect} />;
Expand Down Expand Up @@ -465,7 +468,7 @@ export class CollectionHeader extends React.Component<IProps, IState> {
logo={
namespace?.avatar_url && (
<Logo
alt={t`${company} logo`}
alt={t`${nsTitle} logo`}
className='image'
fallbackToDefault
image={namespace.avatar_url}
Expand Down
7 changes: 4 additions & 3 deletions src/components/headers/partner-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Tabs,
TabsType,
} from 'src/components';
import { namespaceTitle } from 'src/utilities';

interface IProps {
namespace: NamespaceType;
Expand All @@ -34,15 +35,15 @@ export class PartnerHeader extends React.Component<IProps> {
updateParams,
} = this.props;

const company = namespace.company || namespace.name;
const title = namespaceTitle(namespace);

return (
<BaseHeader
title={company}
title={title}
logo={
namespace.avatar_url && (
<Logo
alt={t`${company} logo`}
alt={t`${title} logo`}
className='image'
fallbackToDefault
image={namespace.avatar_url}
Expand Down
2 changes: 1 addition & 1 deletion src/components/namespace-form/namespace-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class NamespaceForm extends React.Component<IProps> {
</FormGroup>
</div>
<div className='card'>
<NamespaceCard {...namespace} />
<NamespaceCard namespace={namespace} />
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/containers/namespace-list/namespace-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export class NamespaceList extends React.Component<IProps, IState> {
namespace: ns.name,
})}
key={i}
{...ns}
namespace={ns}
/>
</div>
))}
Expand Down
1 change: 1 addition & 0 deletions src/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
mapErrorMessages,
} from './map-error-messages';
export { mapNetworkErrors, validateInput } from './map-role-errors';
export { namespaceTitle } from './namespace-title';
export { ParamHelper, type ParamType } from './param-helper';
export { parsePulpIDFromURL } from './parse-pulp-id';
export { RepoSigningUtils } from './repo-signing';
Expand Down
13 changes: 13 additions & 0 deletions src/utilities/namespace-title.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Constants } from 'src/constants';

export function namespaceTitle({
name,
company,
}: {
name: string;
company?: string;
}): string {
return DEPLOYMENT_MODE === Constants.INSIGHTS_DEPLOYMENT_MODE
? company || name
: name;
}

0 comments on commit cee366e

Please sign in to comment.