@finos/legend-application-marketplace
Version:
Legend Marketplace application core
77 lines • 5.45 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { observer } from 'mobx-react-lite';
import { useEffect, useRef } from 'react';
import { DATA_PRODUCT_VIEWER_ACTIVITY_MODE, generateAnchorForActivity, } from '../../../stores/lakehouse/DataProductViewerNavigation.js';
import { AnchorLinkIcon, MarkdownTextViewer } from '@finos/legend-art';
import { prettyCONSTName } from '@finos/legend-shared';
import { DataProducteDataAccess } from './DataProductDataAccess.js';
export const DataproducteWikiPlaceholder = (props) => (_jsx("div", { className: "data-space__viewer__wiki__placeholder", children: props.message }));
export const DataProductWikiPlaceHolder = observer((props) => {
const { dataProductViewerState, mode } = props;
const sectionRef = useRef(null);
const anchor = generateAnchorForActivity(mode);
useEffect(() => {
if (sectionRef.current) {
dataProductViewerState.layoutState.setWikiPageAnchor(anchor, sectionRef.current);
}
return () => dataProductViewerState.layoutState.unsetWikiPageAnchor(anchor);
}, [dataProductViewerState, anchor]);
return (_jsxs("div", { ref: sectionRef, className: "data-space__viewer__wiki__section", children: [_jsx("div", { className: "data-space__viewer__wiki__section__header", children: _jsxs("div", { className: "data-space__viewer__wiki__section__header__label", children: [prettyCONSTName(mode), _jsx("button", { className: "data-space__viewer__wiki__section__header__anchor", tabIndex: -1, onClick: () => dataProductViewerState.changeZone(anchor, true), children: _jsx(AnchorLinkIcon, {}) })] }) }), _jsx("div", { className: "data-space__viewer__wiki__section__content", children: _jsx(DataproducteWikiPlaceholder, { message: "(not specified)" }) })] }));
});
export const DataProductDescription = observer((props) => {
const { dataProductViewerState } = props;
const sectionRef = useRef(null);
const anchor = generateAnchorForActivity(DATA_PRODUCT_VIEWER_ACTIVITY_MODE.DESCRIPTION);
useEffect(() => {
if (sectionRef.current) {
dataProductViewerState.layoutState.setWikiPageAnchor(anchor, sectionRef.current);
}
return () => dataProductViewerState.layoutState.unsetWikiPageAnchor(anchor);
}, [dataProductViewerState, anchor]);
return (_jsxs("div", { ref: sectionRef, className: "data-space__viewer__wiki__section", children: [_jsx("div", { className: "data-space__viewer__wiki__section__header", children: _jsxs("div", { className: "data-space__viewer__wiki__section__header__label", children: [prettyCONSTName(DATA_PRODUCT_VIEWER_ACTIVITY_MODE.DESCRIPTION), _jsx("button", { className: "data-space__viewer__wiki__section__header__anchor", tabIndex: -1, onClick: () => dataProductViewerState.changeZone(anchor, true), children: _jsx(AnchorLinkIcon, {}) })] }) }), _jsx("div", { className: "data-space__viewer__wiki__section__content", children: dataProductViewerState.product.description !== undefined ? (_jsx("div", { className: "data-space__viewer__description", children: _jsx("div", { className: "data-space__viewer__description__content", children: _jsx(MarkdownTextViewer, { className: "data-space__viewer__markdown-text-viewer", value: {
value: dataProductViewerState.product.description,
}, components: {
h1: 'h2',
h2: 'h3',
h3: 'h4',
} }) }) })) : (_jsx(DataproducteWikiPlaceholder, { message: "(not specified)" })) })] }));
});
export const DataProductWiki = observer((props) => {
const { dataProductViewerState } = props;
useEffect(() => {
if (dataProductViewerState.layoutState.wikiPageNavigationCommand &&
dataProductViewerState.layoutState.isWikiPageFullyRendered) {
dataProductViewerState.layoutState.navigateWikiPageAnchor();
}
}, [
dataProductViewerState,
dataProductViewerState.layoutState.wikiPageNavigationCommand,
dataProductViewerState.layoutState.isWikiPageFullyRendered,
]);
useEffect(() => {
if (dataProductViewerState.layoutState.isWikiPageFullyRendered) {
dataProductViewerState.layoutState.registerWikiPageScrollObserver();
}
return () => dataProductViewerState.layoutState.unregisterWikiPageScrollObserver();
}, [
dataProductViewerState,
dataProductViewerState.layoutState.isWikiPageFullyRendered,
]);
return (_jsxs("div", { className: "data-space__viewer__wiki", children: [_jsx(DataProductDescription, { dataProductViewerState: dataProductViewerState }), _jsx(DataProducteDataAccess, { dataProductViewerState: dataProductViewerState })] }));
});
//# sourceMappingURL=DataProductWiki.js.map