@finos/legend-application-studio
Version:
Legend Studio application core
46 lines • 4.11 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { ArrowCircleRightIcon, clsx, ExclamationCircleIcon, getSelectorInputOptionEmbeddedButtonProps, } from '@finos/legend-art';
import { generateViewProjectRoute } from '../../__lib__/LegendStudioNavigation.js';
export const buildProjectOption = (project) => ({
label: project.name,
value: project,
});
export const getProjectOptionLabelFormatter = (applicationStore, projectConfigurationStatus) => function ProjectOptionLabel(option) {
const viewProject = () => applicationStore.navigationService.navigator.visitAddress(applicationStore.navigationService.navigator.generateAddress(generateViewProjectRoute(option.value.projectId)));
const configure = () => {
if (projectConfigurationStatus?.reviewUrl) {
applicationStore.navigationService.navigator.visitAddress(projectConfigurationStatus.reviewUrl);
}
else {
applicationStore.notificationService.notifyWarning(`Can't find project configuration review: opening the project web page...`);
applicationStore.navigationService.navigator.visitAddress(option.value.webUrl);
}
};
return (_jsxs("div", { className: "project-selector__option", children: [_jsx("div", { className: clsx('project-selector__option__label', {
'project-selector__option__label--selected': projectConfigurationStatus &&
option.value.projectId === projectConfigurationStatus.projectId &&
projectConfigurationStatus.isConfigured,
'project-selector__option__label--not-configured': projectConfigurationStatus &&
option.value.projectId === projectConfigurationStatus.projectId &&
!projectConfigurationStatus.isConfigured,
}), children: _jsx("div", { className: "project-selector__option__label__name", children: option.label }) }), projectConfigurationStatus &&
option.value.projectId === projectConfigurationStatus.projectId && (_jsxs(_Fragment, { children: [projectConfigurationStatus.isConfigured && (_jsxs("button", { type: "button" // prevent this toggler being activated on form submission
, className: "project-selector__option__visit-btn", tabIndex: -1, onClick: viewProject, ...getSelectorInputOptionEmbeddedButtonProps(), children: [_jsx("div", { className: "project-selector__option__visit-btn__label", children: "view" }), _jsx("div", { className: "project-selector__option__visit-btn__icon", children: _jsx(ArrowCircleRightIcon, {}) })] })), !projectConfigurationStatus.isConfigured && (_jsxs("button", { className: "project-selector__option__configure-btn", type: "button" // prevent this toggler being activated on form submission
, tabIndex: -1, onClick: configure, ...getSelectorInputOptionEmbeddedButtonProps(), title: "The project has not been configured properly. Click to see the review and commit it to get complete the configuration.", children: [_jsx("div", { className: "project-selector__option__configure-btn__warning-icon", children: _jsx(ExclamationCircleIcon, {}) }), _jsx("div", { className: "project-selector__option__configure-btn__label", children: "configure" }), _jsx("div", { className: "project-selector__option__configure-btn__icon", children: _jsx(ArrowCircleRightIcon, {}) })] }))] }))] }));
};
//# sourceMappingURL=ProjectSelectorUtils.js.map