/******************************************************************************** * Copyright (c) 2019 TypeFox and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 ********************************************************************************/ import { FunctionComponent, useContext, useEffect, useState, useRef } from 'react'; import { Box, Divider, Typography } from '@mui/material'; import { MainContext } from '../../context'; import { SanitizedMarkdown } from '../../components/sanitized-markdown'; import { DelayedLoadIndicator } from '../../components/delayed-load-indicator'; import { Extension } from '../../extension-registry-types'; export const ExtensionDetailChanges: FunctionComponent = props => { const [changelog, setChangelog] = useState(); const [loading, setLoading] = useState(true); const context = useContext(MainContext); const abortController = useRef(new AbortController()); useEffect(() => { setLoading(true); updateChanges(); return () => abortController.current.abort(); }, [props.extension.namespace, props.extension.name, props.extension.version]); const updateChanges = async (): Promise => { if (props.extension.files.changelog) { try { const changelog = await context.service.getExtensionChangelog(abortController.current, props.extension); setChangelog(changelog); } catch (err) { context.handleError(err); setChangelog(undefined); } } else { setChangelog(''); } setLoading(false); }; if (typeof changelog === 'undefined') { return ; } if (changelog.length === 0) { return <> div:first-of-type': { marginBottom: '1rem' }, '& button': { maxWidth: '12rem', } } }} > Changelog No changelog available ; } return ; }; export interface ExtensionDetailChangesProps { extension: Extension; }