/** * 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 { BlankPanelContent, GitBranchIcon, clsx } from '@finos/legend-art'; import { observer, useLocalObservable } from 'mobx-react-lite'; import { useApplicationStore } from '@finos/legend-application'; import { useParams } from '@finos/legend-application/browser'; import { ActivityBarMenu, LEGEND_STUDIO_TEST_ID, useLegendStudioApplicationStore, useLegendStudioBaseStore, } from '@finos/legend-application-studio'; import { createContext, useContext } from 'react'; import { guaranteeNonNullable } from '@finos/legend-shared'; import { flowResult } from 'mobx'; import { DocumentationLink } from '@finos/legend-lego/application'; import { DATA_SPACE_TEMPLATE_QUERY_PROMOTION_ROUTE_PATTERN_TOKEN, type DataSpaceTemplateQueryPromotionReviewerPathParams, } from '@finos/legend-extension-dsl-data-space/application'; import { DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY } from '../__lib__/DSL_DataSpace_LegendStudioDocumentation.js'; import { DataSpaceTemplateQueryPromotionReviewerStore } from '../stores/DataSpaceTemplateQueryPromotionReviewerStore.js'; const TemplateQueryPromotionReviewerStoreContext = createContext< DataSpaceTemplateQueryPromotionReviewerStore | undefined >(undefined); const DataSpaceTemplateQueryPromotionReviewerStoreProvider: React.FC<{ children: React.ReactNode; dataSpacePath: string; queryId: string; }> = ({ children, dataSpacePath, queryId }) => { const applicationStore = useLegendStudioApplicationStore(); const baseStore = useLegendStudioBaseStore(); const store = useLocalObservable( () => new DataSpaceTemplateQueryPromotionReviewerStore( applicationStore, baseStore.sdlcServerClient, baseStore.depotServerClient, ), ); store.initialize(queryId, dataSpacePath); return ( {children} ); }; const useTemplateQueryPromotionReviewerStore = (): DataSpaceTemplateQueryPromotionReviewerStore => guaranteeNonNullable( useContext(TemplateQueryPromotionReviewerStoreContext), `Can't find query productionizer store in context`, ); const TemplateQueryPromotionReviewerContent = observer(() => { const applicationStore = useApplicationStore(); const queryPromotionReviewerStore = useTemplateQueryPromotionReviewerStore(); const isLoadingEditor = !queryPromotionReviewerStore.initState.hasCompleted; // workspace name const changeWorkspaceName: React.ChangeEventHandler = ( event, ) => queryPromotionReviewerStore.setWorkspaceName(event.target.value); // template query const onChangeTemplateQueryId: React.ChangeEventHandler = ( event, ) => queryPromotionReviewerStore.setTemplateQueryId(event.target.value); const onChangeTemplateQueryTitle: React.ChangeEventHandler< HTMLInputElement > = (event) => queryPromotionReviewerStore.setTemplateQueryTitle(event.target.value); const onChangeTemplateQueryDescription: React.ChangeEventHandler< HTMLInputElement > = (event) => queryPromotionReviewerStore.setTemplateQueryDescription(event.target.value); // actions const promoteTemplateQuery = (): void => { flowResult(queryPromotionReviewerStore.promoteAsTemplateQuery()).catch( applicationStore.alertUnhandledError, ); }; return (
{isLoadingEditor && ( {queryPromotionReviewerStore.initState.message ?? queryPromotionReviewerStore.editorStore.graphManagerState .systemBuildState.message ?? queryPromotionReviewerStore.editorStore.graphManagerState .dependenciesBuildState.message ?? queryPromotionReviewerStore.editorStore.graphManagerState .generationsBuildState.message ?? queryPromotionReviewerStore.editorStore.graphManagerState .graphBuildState.message} )}
Promote as Curated Template Query
We will promote this query as a curated template query in data product. This automated process will generate a code review and workspace. Please get the generated code review reviewed and approved.
workspace
{!queryPromotionReviewerStore.isWorkspaceNameValid && (
Workspace already existed
)}
template query
id
{!queryPromotionReviewerStore.isTemplateQueryIdValid && (
Invalid template query id
)}
title
description
); }); export const DataSpaceTemplateQueryPromotionReviewer = observer(() => { const parameters = useParams(); const dataSpacePath = guaranteeNonNullable( parameters[ DATA_SPACE_TEMPLATE_QUERY_PROMOTION_ROUTE_PATTERN_TOKEN.DATA_SPACE_PATH ], ); const queryId = guaranteeNonNullable( parameters[ DATA_SPACE_TEMPLATE_QUERY_PROMOTION_ROUTE_PATTERN_TOKEN.QUERY_ID ], ); return ( ); });