@finos/legend-studio
Version:
96 lines • 4.55 kB
JavaScript
import { jsx as _jsx } 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 { returnUndefOnError } from '@finos/legend-shared';
import { Class, Enumeration, Measure, Unit, PrimitiveType, } from '@finos/legend-graph';
import { PURE_ClassIcon, PURE_PrimitiveTypeIcon, PURE_EnumerationIcon, PURE_MeasureIcon, PURE_AssociationIcon, PURE_ProfileIcon, PURE_MappingIcon, PURE_RuntimeIcon, PURE_ServiceIcon, PURE_ConnectionIcon, PURE_FunctionIcon, PURE_DatabaseIcon, PURE_FlatDataStoreIcon, PURE_FileGenerationIcon, PURE_GenerationSpecificationIcon, PURE_UnknownElementTypeIcon, PURE_UnitIcon, PURE_PackageIcon, PURE_DataIcon, } from '@finos/legend-art';
import { PACKAGEABLE_ELEMENT_TYPE } from '../../stores/shared/ModelUtil.js';
export const getClassPropertyIcon = (type) => {
if (type instanceof PrimitiveType) {
return _jsx(PURE_PrimitiveTypeIcon, {});
}
else if (type instanceof Class) {
return _jsx(PURE_ClassIcon, {});
}
else if (type instanceof Enumeration) {
return _jsx(PURE_EnumerationIcon, {});
}
else if (type instanceof Measure) {
return _jsx(PURE_MeasureIcon, {});
}
else if (type instanceof Unit) {
return _jsx(PURE_UnitIcon, {});
}
return _jsx(PURE_UnknownElementTypeIcon, {});
};
export const getElementTypeIcon = (editorStore, type) => {
switch (type) {
case PACKAGEABLE_ELEMENT_TYPE.PRIMITIVE:
return _jsx(PURE_PrimitiveTypeIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.PACKAGE:
return _jsx(PURE_PackageIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.CLASS:
return _jsx(PURE_ClassIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.ASSOCIATION:
return _jsx(PURE_AssociationIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.ENUMERATION:
return _jsx(PURE_EnumerationIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.MEASURE:
return _jsx(PURE_MeasureIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.UNIT:
return _jsx(PURE_UnitIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.PROFILE:
return _jsx(PURE_ProfileIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.FUNCTION:
return _jsx(PURE_FunctionIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.FLAT_DATA_STORE:
return _jsx(PURE_FlatDataStoreIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.DATABASE:
return _jsx(PURE_DatabaseIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.MAPPING:
return _jsx(PURE_MappingIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.SERVICE:
return _jsx(PURE_ServiceIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.CONNECTION:
return _jsx(PURE_ConnectionIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.RUNTIME:
return _jsx(PURE_RuntimeIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.FILE_GENERATION:
return _jsx(PURE_FileGenerationIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.DATA:
return _jsx(PURE_DataIcon, {});
case PACKAGEABLE_ELEMENT_TYPE.GENERATION_SPECIFICATION:
return _jsx(PURE_GenerationSpecificationIcon, {});
default: {
if (type) {
const extraElementIconGetters = editorStore.pluginManager
.getApplicationPlugins()
.flatMap((plugin) => plugin.getExtraElementIconGetters?.() ?? []);
for (const iconGetter of extraElementIconGetters) {
const elementIcon = iconGetter(type);
if (elementIcon) {
return elementIcon;
}
}
}
return _jsx(PURE_UnknownElementTypeIcon, {});
}
}
};
export const getElementIcon = (editorStore, element) => getElementTypeIcon(editorStore, element
? returnUndefOnError(() => editorStore.graphState.getPackageableElementType(element))
: undefined);
//# sourceMappingURL=ElementIconUtils.js.map