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
33 changes: 26 additions & 7 deletions core/frontend/src/components/kraken/KrakenManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ export async function fetchManifestSource(identifier: string, data = true): Prom
return response.data as Manifest
}

function withCompatibility(extension: ExtensionData): ExtensionData {
return {
...extension,
is_compatible: Object.values(extension.versions).some(
(version) => version.images.some((image) => image.compatible),
),
}
}

/**
* Fetch all manifests from kraken in a single merged representation, repeated entries will be excluded, only the one
* present in the manifest wth higher priority will be kept, uses API v2
Expand All @@ -66,15 +75,24 @@ export async function fetchConsolidatedManifests(): Promise<ExtensionData[]> {
const response = await back_axios({
method: 'get',
url: `${KRAKEN_API_V2_URL}/manifest/consolidated`,
timeout: 25000,
timeout: 60000,
})

return (response.data as ExtensionData[]).map((extension: ExtensionData) => ({
...extension,
is_compatible: Object.values(extension.versions).some(
(version) => version.images.some((image) => image.compatible),
),
}))
return (response.data as ExtensionData[]).map(withCompatibility)
}

/**
* Fetch one catalog entry including per-version readme/docs, uses API v2
* @param {string} identifier The extension identifier
*/
export async function fetchCatalogExtension(identifier: string): Promise<ExtensionData> {
const response = await back_axios({
method: 'get',
url: `${KRAKEN_API_V2_URL}/manifest/consolidated/${encodeURIComponent(identifier)}`,
timeout: 60000,
})

return withCompatibility(response.data as ExtensionData)
}

/**
Expand Down Expand Up @@ -187,6 +205,7 @@ export default {
fetchManifestSources,
fetchManifestSource,
fetchConsolidatedManifests,
fetchCatalogExtension,
fetchInstalledExtensions,
addManifestSource,
updateManifestSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export default Vue.extend({
},
},
watch: {
extension() {
'extension.identifier'() {
this.selected_version = this.getLatestTag()
this.editing_permissions = this.getVersionPermissions()
this.custom_permissions = {}
Expand Down
10 changes: 9 additions & 1 deletion core/frontend/src/views/ExtensionManagerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,17 @@ export default Vue.extend({
const file = new File([this.log_output ?? ''], `${this.log_container_name}.log`, { type: 'text/plain' })
saveAs(file)
},
showModal(extension: ExtensionData) {
async showModal(extension: ExtensionData) {
this.show_dialog = true
this.selected_extension = extension
try {
const full = await kraken.fetchCatalogExtension(extension.identifier)
if (this.selected_extension?.identifier === full.identifier) {
this.selected_extension = full
}
} catch {
// Compact catalog entry is enough to install; readme stays empty.
}
},
async install(
identifier: string,
Expand Down
2 changes: 1 addition & 1 deletion core/services/kraken/api/v1/routers/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@index_router_v1.get("/extensions_manifest", status_code=status.HTTP_200_OK)
@manifest_to_http_exception
async def fetch_manifest() -> list[RepositoryEntry]:
return await manifest_manager.fetch_consolidated()
return [entry.without_readme() for entry in await manifest_manager.fetch_consolidated()]


@index_router_v1.get("/installed_extensions", status_code=status.HTTP_200_OK)
Expand Down
16 changes: 15 additions & 1 deletion core/services/kraken/api/v2/routers/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,22 @@ async def fetch_consolidated() -> list[RepositoryEntry]:
"""
List a consolidation of all repository entries from all manifest sources merged by its sorted priority, if a
repository entry is duplicated, the one with the highest priority will be kept.

Per-version readme/docs are omitted so the store list stays small.
"""
return [entry.without_readme() for entry in await manifest_manager.fetch_consolidated()]


@manifest_router_v2.get("/consolidated/{extension_identifier}", status_code=status.HTTP_200_OK)
@manifest_to_http_exception
async def fetch_consolidated_extension(extension_identifier: str) -> RepositoryEntry:
"""
return await manifest_manager.fetch_consolidated()
Get one catalog entry from the consolidated manifests, including readme and docs.
"""
ext = await manifest_manager.fetch_extension(extension_identifier)
if not ext:
raise ExtensionEntryNotFound(f"Extension {extension_identifier} not found")
return ext


@manifest_router_v2.get("/tags/{manifest_identifier}/{extension_identifier}/", status_code=status.HTTP_200_OK)
Expand Down
10 changes: 10 additions & 0 deletions core/services/kraken/manifest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ class ExtensionMetadata(BaseModel):
class RepositoryEntry(ExtensionMetadata):
versions: Dict[str, ExtensionVersion] = Field(default_factory=dict)

def without_readme(self) -> "RepositoryEntry":
"""Shallow copy with per-version readme/docs cleared for catalog list payloads."""
return self.copy(
update={
"versions": {
tag: version.copy(update={"readme": None, "docs": None}) for tag, version in self.versions.items()
}
}
)


# Local Manifest models

Expand Down
Loading