@finos/legend-extension-dsl-data-space-studio
Version:
Legend extension for Data Space DSL - Studio
81 lines • 10.5 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 { 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, } 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(undefined);
const DataSpaceTemplateQueryPromotionReviewerStoreProvider = ({ children, dataSpacePath, queryId }) => {
const applicationStore = useLegendStudioApplicationStore();
const baseStore = useLegendStudioBaseStore();
const store = useLocalObservable(() => new DataSpaceTemplateQueryPromotionReviewerStore(applicationStore, baseStore.sdlcServerClient, baseStore.depotServerClient));
store.initialize(queryId, dataSpacePath);
return (_jsx(TemplateQueryPromotionReviewerStoreContext.Provider, { value: store, children: children }));
};
const useTemplateQueryPromotionReviewerStore = () => 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 = (event) => queryPromotionReviewerStore.setWorkspaceName(event.target.value);
// template query
const onChangeTemplateQueryId = (event) => queryPromotionReviewerStore.setTemplateQueryId(event.target.value);
const onChangeTemplateQueryTitle = (event) => queryPromotionReviewerStore.setTemplateQueryTitle(event.target.value);
const onChangeTemplateQueryDescription = (event) => queryPromotionReviewerStore.setTemplateQueryDescription(event.target.value);
// actions
const promoteTemplateQuery = () => {
flowResult(queryPromotionReviewerStore.promoteAsTemplateQuery()).catch(applicationStore.alertUnhandledError);
};
return (_jsxs("div", { className: "app__page", children: [isLoadingEditor && (_jsx(BlankPanelContent, { children: queryPromotionReviewerStore.initState.message ??
queryPromotionReviewerStore.editorStore.graphManagerState
.systemBuildState.message ??
queryPromotionReviewerStore.editorStore.graphManagerState
.dependenciesBuildState.message ??
queryPromotionReviewerStore.editorStore.graphManagerState
.generationsBuildState.message ??
queryPromotionReviewerStore.editorStore.graphManagerState
.graphBuildState.message })), _jsxs("div", { className: "template-query-promotor", children: [_jsxs("div", { className: "template-query-promotor__body", children: [_jsx("div", { className: "activity-bar", children: _jsx(ActivityBarMenu, {}) }), _jsx("div", { className: "template-query-promotor__content", "data-testid": LEGEND_STUDIO_TEST_ID.SETUP__CONTENT, children: _jsxs("div", { className: "template-query-promotor__content__main", children: [_jsxs("div", { className: "template-query-promotor__title", children: ["Promote as Curated Template Query", _jsx(DocumentationLink, { documentationKey: DSL_DATA_SPACE_LEGEND_STUDIO_DOCUMENTATION_KEY.CURATED_TEMPLATE_QUERY })] }), _jsx("div", { className: "template-query-promotor__title__prompt", children: "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." }), _jsxs("div", { className: "template-query-promotor__group template-query-promotor__group--workspace", children: [_jsx("div", { className: "template-query-promotor__group__header", children: "workspace" }), _jsx("div", { className: "template-query-promotor__group__content", children: _jsxs("div", { className: "template-query-promotor__input", children: [_jsx("div", { className: "template-query-promotor__input__icon", title: "workspace", children: _jsx(GitBranchIcon, { className: "template-query-promotor__input__icon--workspce" }) }), _jsxs("div", { className: "input-group template-query-promotor__input__input", children: [_jsx("input", { className: clsx('input input--dark input-group__input', {
'input-group__input--error': !queryPromotionReviewerStore.isWorkspaceNameValid,
}), spellCheck: false, value: queryPromotionReviewerStore.workspaceName, placeholder: "Enter a name for your workspace", onChange: changeWorkspaceName }), !queryPromotionReviewerStore.isWorkspaceNameValid && (_jsx("div", { className: "input-group__error-message", children: "Workspace already existed" }))] })] }) })] }), _jsxs("div", { className: "template-query-promotor__group template-query-promotor__group--template", children: [_jsx("div", { className: "template-query-promotor__group__header", children: "template query" }), _jsxs("div", { className: "template-query-promotor__group__content", children: [_jsxs("div", { className: "template-query-promotor__input", children: [_jsx("div", { className: "template-query-promotor__input__label", children: "id" }), _jsxs("div", { className: "input-group template-query-promotor__input__input", children: [_jsx("input", { className: clsx('input input--dark input-group__input', {
'input-group__input--error': !queryPromotionReviewerStore.isTemplateQueryIdValid,
}), spellCheck: false, placeholder: "Create an id for your template query", value: queryPromotionReviewerStore.templateQueryId, onChange: onChangeTemplateQueryId }), !queryPromotionReviewerStore.isTemplateQueryIdValid && (_jsx("div", { className: "input-group__error-message", children: "Invalid template query id" }))] })] }), _jsxs("div", { className: "template-query-promotor__input", children: [_jsx("div", { className: "template-query-promotor__input__label", children: "title" }), _jsx("div", { className: "input-group template-query-promotor__input__input", children: _jsx("input", { className: "input input--dark input-group__input", spellCheck: false, placeholder: "Create a title for your template query", value: queryPromotionReviewerStore.templateQueryTitle, onChange: onChangeTemplateQueryTitle }) })] }), _jsxs("div", { className: "template-query-promotor__input", children: [_jsx("div", { className: "template-query-promotor__input__label", children: "description" }), _jsx("div", { className: "input-group template-query-promotor__input__input", children: _jsx("input", { className: "input input--dark input-group__input", spellCheck: false, placeholder: "Add some descriptions for your template query", value: queryPromotionReviewerStore.templateQueryDescription, onChange: onChangeTemplateQueryDescription }) })] })] })] }), _jsx("div", { className: "template-query-promotor__actions", children: _jsx("button", { className: "template-query-promotor__next-btn btn--dark", onClick: promoteTemplateQuery, disabled: queryPromotionReviewerStore.promoteState.isInProgress ||
!queryPromotionReviewerStore.currentQuery ||
!queryPromotionReviewerStore.currentQueryInfo ||
!queryPromotionReviewerStore.currentProject ||
!queryPromotionReviewerStore
.currentProjectConfigurationStatus?.isConfigured ||
!queryPromotionReviewerStore.workspaceName ||
!queryPromotionReviewerStore.templateQueryTitle ||
!queryPromotionReviewerStore.isWorkspaceNameValid ||
!queryPromotionReviewerStore.isTemplateQueryIdValid, children: "Promote Query" }) })] }) })] }), _jsx("div", { "data-testid": LEGEND_STUDIO_TEST_ID.STATUS_BAR, className: "editor__status-bar" })] })] }));
});
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 (_jsx(DataSpaceTemplateQueryPromotionReviewerStoreProvider, { dataSpacePath: dataSpacePath, queryId: queryId, children: _jsx(TemplateQueryPromotionReviewerContent, {}) }));
});
//# sourceMappingURL=DataSpaceTemplateQueryPromoteReview.js.map