@finos/legend-application-marketplace
Version:
Legend Marketplace application core
85 lines • 5.27 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, 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 { DataGrid, } from '@finos/legend-lego/data-grid';
import { Box } from '@mui/material';
import { GraphManagerState, } from '@finos/legend-graph';
import { useMemo, useRef, useState } from 'react';
import { useAuth } from 'react-oidc-context';
import { DataAccessRequestViewer, DataContractViewerState, } from '@finos/legend-extension-dsl-data-product';
import { generateContractPagePath, generateLakehouseDataProductPath, } from '../../../__lib__/LegendMarketplaceNavigation.js';
export const LakehouseAdminContractsDashboard = observer((props) => {
const { adminStore } = props;
const auth = useAuth();
// Keep the latest access token in a ref so the grid datasource always reads
// the freshest token without being recreated on every token rotation
// (which would otherwise cause the grid to reset and refetch).
const tokenRef = useRef(auth.user?.access_token);
tokenRef.current = auth.user?.access_token;
const [selectedContract, setSelectedContract] = useState();
const handleRowClicked = (event) => {
setSelectedContract(event.data);
};
const datasource = useMemo(() => adminStore.createContractsServerSideDatasource(() => tokenRef.current), [adminStore]);
return (_jsxs(_Fragment, { children: [_jsx(Box, { className: "marketplace-lakehouse-admin__contracts__grid ag-theme-balham", children: _jsx(DataGrid, { rowModelType: "serverSide", serverSideDatasource: datasource, suppressFieldDotNotation: true, suppressContextMenu: false, onRowClicked: handleRowClicked, onGridReady: (params) => {
adminStore.setContractsGridApi(params.api);
}, columnDefs: [
{
minWidth: 50,
resizable: true,
headerName: 'Contract Id',
valueGetter: (p) => p.data?.guid,
flex: 2,
},
{
minWidth: 50,
resizable: true,
headerName: 'Contract Description',
valueGetter: (p) => p.data?.description,
flex: 2,
},
{
minWidth: 10,
resizable: true,
headerName: 'Version',
valueGetter: (p) => p.data?.version,
flex: 1,
},
{
minWidth: 50,
resizable: true,
headerName: 'State',
valueGetter: (p) => p.data?.state,
flex: 2,
},
{
minWidth: 50,
resizable: true,
headerName: 'Members',
valueGetter: (p) => p.data?.members.map((m) => m.user),
flex: 1,
},
{
minWidth: 50,
resizable: true,
headerName: 'Created By',
valueGetter: (p) => p.data?.createdBy,
flex: 1,
},
] }) }), selectedContract !== undefined && (_jsx(DataAccessRequestViewer, { open: true, onClose: () => setSelectedContract(undefined), viewerState: new DataContractViewerState(selectedContract, (contractId, taskId) => adminStore.legendMarketplaceBaseStore.applicationStore.navigationService.navigator.generateAddress(generateContractPagePath(contractId, taskId)), undefined, adminStore.legendMarketplaceBaseStore.applicationStore, adminStore.legendMarketplaceBaseStore.lakehouseContractServerClient, new GraphManagerState(adminStore.legendMarketplaceBaseStore.applicationStore.pluginManager, adminStore.legendMarketplaceBaseStore.applicationStore.logService), adminStore.legendMarketplaceBaseStore.userSearchService), onRefresh: () => adminStore.refresh(), getDataProductUrl: (dataProductId, deploymentId) => adminStore.legendMarketplaceBaseStore.applicationStore.navigationService.navigator.generateAddress(generateLakehouseDataProductPath(dataProductId, deploymentId)) }))] }));
});
//# sourceMappingURL=LakehouseAdminContractsDashboard.js.map