Skip to content
Draft
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
8 changes: 7 additions & 1 deletion src/api/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,18 @@ export class API extends HubAPI {
);
}

getContent(namespace, name, version) {
getContent(namespace, name, version, includeDocs = false) {
// pulp_ansible 0.28.3+ excludes large fields (docs_blob, contents, files, manifest)
// by default to prevent OOM. We only request docs_blob and contents when needed (on docs page).
const baseFields = 'description,tags,authors,license,homepage,documentation,issues,repository,dependencies,requires_ansible';
const fields = includeDocs ? `docs_blob,contents,${baseFields}` : baseFields;

return super.list(
{
namespace,
name,
version,
fields,
},
`pulp/api/v3/content/ansible/collection_versions/`,
);
Expand Down
23 changes: 22 additions & 1 deletion src/containers/collection-detail/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ export interface IBaseCollectionState {
};
}

interface LoadCollectionParams {
forceReload: boolean;
matchParams: any;
navigate: any;
setCollection: (
collections: CollectionVersionSearch[],
collection: CollectionVersionSearch,
content: CollectionVersionContentType,
collectionsCount: number,
actuallyCollection: CollectionDetailType,
) => void;
stateParams: {
version?: string;
showing?: string;
keywords?: string;
};
includeDocs?: boolean; // Whether to load docs_blob field (for docs page)
}

// Caches the collection data when matching, prevents redundant fetches between collection detail tabs
const cache = {
repository: null,
Expand All @@ -44,7 +63,8 @@ export function loadCollection({
navigate,
setCollection,
stateParams,
}) {
includeDocs = false,
}: LoadCollectionParams) {
const { version } = stateParams;
const { collection: name, namespace, repo } = matchParams;

Expand Down Expand Up @@ -84,6 +104,7 @@ export function loadCollection({
namespace,
name,
collection.collection_version.version,
includeDocs,
),
)
.then(({ data: { results } }) => results[0])
Expand Down
1 change: 1 addition & 0 deletions src/containers/collection-detail/collection-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class CollectionContent extends Component<RouteProps, IBaseCollectionState> {
forceReload,
matchParams: this.props.routeParams,
navigate: this.props.navigate,
includeDocs: true, // Load contents field for the content list page
setCollection: (
collections,
collection,
Expand Down
1 change: 1 addition & 0 deletions src/containers/collection-detail/collection-docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ class CollectionDocs extends Component<RouteProps, IBaseCollectionState> {
forceReload,
matchParams: this.props.routeParams,
navigate: this.props.navigate,
includeDocs: true, // Load docs_blob for the docs page
setCollection: (
collections,
collection,
Expand Down
Loading