fix(editor): allow removing data source trait

This commit is contained in:
Bowen Tan 2023-01-09 15:53:03 +08:00
parent 851481f13b
commit 71df7cd9c2
3 changed files with 4 additions and 4 deletions

View File

@ -39,7 +39,7 @@ export const GeneralTraitForm: React.FC<Props> = props => {
<VStack key={trait.type} className={formWrapperCSS}>
<HStack width="full" justifyContent="space-between">
<strong>{trait.type}</strong>
{!tImpl.metadata.isDataSource && onRemove ? (
{onRemove ? (
<IconButton
aria-label="remove trait"
variant="ghost"

View File

@ -82,7 +82,7 @@ export const DataSourceGroup: React.FC<Props> = props => {
<AccordionButton justifyContent="space-between">
<HStack>
{type === 'component' ? <Tag colorScheme="blue">C</Tag> : undefined}
<Text fontWeight="bold">{title}</Text>
<Text fontWeight="bold">{title || 'Unknown'}</Text>
</HStack>
<AccordionIcon />
</AccordionButton>

View File

@ -33,7 +33,7 @@ export const DataSourceList: React.FC<Props> = props => {
const tDataSources = dataSources.filter(ds => ds.type === 'core/v1/dummy');
const cDataSources = dataSources.filter(ds => ds.type !== 'core/v1/dummy');
const cdsMap = groupBy(cDataSources, c => c.type);
const tdsMap = groupBy(tDataSources, c => c.traits[0]?.type);
const tdsMap = groupBy(tDataSources, c => c.traits[0]?.type || '');
const cdsGroups = Object.keys(cdsMap).map(type => {
return {
title: type,
@ -44,7 +44,7 @@ export const DataSourceList: React.FC<Props> = props => {
const tdsGroups = Object.keys(tdsMap).map(type => {
return {
title: type,
dataSources: tdsMap[type],
dataSources: tdsMap[type] || [],
type: 'trait',
};
});