Skip to content

Commit

Permalink
Prettier.
Browse files Browse the repository at this point in the history
No-Issue

Signed-off-by: James Tanner <tanner.jc@gmail.com>
  • Loading branch information
jctanner committed Sep 21, 2023
1 parent d348c4e commit f7eb2ba
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 62 deletions.
4 changes: 2 additions & 2 deletions src/api/response-types/legacy-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export class LegacyNamespaceListType {
url: string;
summary_fields: {
owners?: { username: string }[];
providers?: { id: number, name: string, pulp_href: string}[];
providers?: { id: number; name: string; pulp_href: string }[];
};
created: string;
modified: string;
Expand All @@ -18,7 +18,7 @@ export class LegacyNamespaceDetailType {
url: string;
summary_fields: {
owners?: { username: string }[];
providers?: { id: number, name: string, pulp_href: string}[];
providers?: { id: number; name: string; pulp_href: string }[];
};
created: string;
modified: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { LegacyNamespaceDetailType } from 'src/api';
import { Logo, StatefulDropdown } from 'src/components';
import { AppContext } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';
import './legacy-namespace-item.scss';
import { getProviderInfo } from 'src/utilities/legacy-namespace';
import './legacy-namespace-item.scss';

interface LegacyNamespaceProps {
namespace: LegacyNamespaceDetailType;
Expand Down
51 changes: 20 additions & 31 deletions src/components/legacy-namespace-list/legacy-namespace-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
import React from 'react';
import {
Text,
TextContent,
TextVariants
} from '@patternfly/react-core';
import { Trans } from '@lingui/macro';
import { Text, TextContent, TextVariants } from '@patternfly/react-core';
import React from 'react';
import { Link } from 'react-router-dom';


interface IProps {
id: number;
name: string;
url: string;
id: number;
name: string;
url: string;
}

export class ProviderLink extends React.Component<IProps> {
constructor(props) {
super(props);
}

constructor(props) {
super(props);
}

render () {

const {
id,
name,
url,
} = this.props;
render() {
const { id, name, url } = this.props;

Check failure on line 18 in src/components/legacy-namespace-list/legacy-namespace-provider.tsx

View workflow job for this annotation

GitHub Actions / pr-checks

'id' is assigned a value but never used

return (
<TextContent>
<Text component={TextVariants.small}>
<Trans>
Provided by <Link to={url}>{name}</Link>
</Trans>
</Text>
</TextContent>
)
}
return (
<TextContent>
<Text component={TextVariants.small}>
<Trans>
Provided by <Link to={url}>{name}</Link>
</Trans>
</Text>
</TextContent>
);
}
}
10 changes: 8 additions & 2 deletions src/components/legacy-role-list/legacy-role-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import React from 'react';
import { Link } from 'react-router-dom';
import { LegacyRoleDetailType } from 'src/api';
import { DateComponent, DownloadCount, Logo, Tag } from 'src/components';
import { ProviderLink } from 'src/components/legacy-namespace-list/legacy-namespace-provider';
import { Paths, formatPath } from 'src/paths';
import { chipGroupProps } from 'src/utilities';
import { getProviderInfo } from 'src/utilities/legacy-namespace';
import { ProviderLink } from 'src/components/legacy-namespace-list/legacy-namespace-provider';
import './legacy-role-item.scss';

interface LegacyRoleProps {
Expand Down Expand Up @@ -92,7 +92,13 @@ export class LegacyRoleListItem extends React.Component<LegacyRoleProps> {
</Text>
</TextContent>
*/}
<ProviderLink id={provider.id} name={provider.name} url={provider.url}>{provider.name}</ProviderLink>
<ProviderLink
id={provider.id}
name={provider.name}
url={provider.url}
>
{provider.name}
</ProviderLink>
</div>
<div className='hub-entry'>{role.description}</div>
<div className='hub-entry'>
Expand Down
11 changes: 8 additions & 3 deletions src/containers/legacy-namespaces/legacy-namespace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import {
WisdomModal,
closeAlertMixin,
} from 'src/components';
import { ProviderLink } from 'src/components/legacy-namespace-list/legacy-namespace-provider';
import { AppContext } from 'src/loaders/app-context';
import { Paths, formatPath } from 'src/paths';
import { RouteProps, withRouter } from 'src/utilities';
import { getProviderInfo } from 'src/utilities/legacy-namespace';
import { ProviderLink } from 'src/components/legacy-namespace-list/legacy-namespace-provider';
import './legacy-namespace.scss';

interface LegacyNamespaceRolesProps {
Expand Down Expand Up @@ -189,7 +189,6 @@ interface LegacyNamespaceProps {
alerts: AlertType[];
}


class LegacyNamespace extends React.Component<
RouteProps,
LegacyNamespaceProps
Expand Down Expand Up @@ -259,7 +258,13 @@ class LegacyNamespace extends React.Component<
width='90px'
/>
<Link to={namespace_url}>{this.state.namespace.name}</Link>
<ProviderLink id={provider.id} name={provider.name} url={provider.url}>{provider.name}</ProviderLink>
<ProviderLink
id={provider.id}
name={provider.name}
url={provider.url}
>
{provider.name}
</ProviderLink>
</DataListCell>,
);

Expand Down
45 changes: 22 additions & 23 deletions src/utilities/legacy-namespace.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
export function getProviderInfo(data) {
console.log('DATA', data);

console.log('DATA', data);
let provider = null;

let provider = null;
if (data.summary_fields.hasOwnProperty('provider_namespace')) {

Check failure on line 6 in src/utilities/legacy-namespace.ts

View workflow job for this annotation

GitHub Actions / pr-checks

Do not access Object.prototype method 'hasOwnProperty' from target object
// role summary
provider = data.summary_fields.provider_namespace;
} else if (data.summary_fields.hasOwnProperty('provider_namespaces')) {

Check failure on line 9 in src/utilities/legacy-namespace.ts

View workflow job for this annotation

GitHub Actions / pr-checks

Do not access Object.prototype method 'hasOwnProperty' from target object
// legacy namespace summary
provider = data.summary_fields.provider_namespaces[0];
}

if (data.summary_fields.hasOwnProperty('provider_namespace')) {
// role summary
provider = data.summary_fields.provider_namespace;
} else if (data.summary_fields.hasOwnProperty('provider_namespaces')) {
// legacy namespace summary
provider = data.summary_fields.provider_namespaces[0];
}

console.log('FINAL PROVIDER', provider);

if (provider === null || provider === undefined) {
return {
'id': null,
'name': null,
'url': null,
}
}
console.log('FINAL PROVIDER', provider);

if (provider === null || provider === undefined) {
return {
'id': provider.id,
'name': provider.name,
'url': `/namespaces/${provider.name}`
}
id: null,
name: null,
url: null,
};
}

return {
id: provider.id,
name: provider.name,
url: `/namespaces/${provider.name}`,
};
}

0 comments on commit f7eb2ba

Please sign in to comment.