Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
lerouxb committed Sep 26, 2024
1 parent 815d8d9 commit 665eada
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ const ttlTooltip = (expireAfterSeconds: string) => {
};

export const getPropertyTooltip = (
property?: string,
extra?: RegularIndex['extra']
property: string,
extra: RegularIndex['extra']
): string | null => {
if (property === 'ttl' && extra?.expireAfterSeconds !== undefined) {
if (property === 'ttl' && extra.expireAfterSeconds !== undefined) {
return ttlTooltip(extra.expireAfterSeconds as unknown as string);
}

if (property === 'partial' && extra?.partialFilterExpression !== undefined) {
if (property === 'partial' && extra.partialFilterExpression !== undefined) {
return partialTooltip(extra.partialFilterExpression);
}

Expand Down Expand Up @@ -99,16 +99,17 @@ const PropertyField: React.FunctionComponent<PropertyFieldProps> = ({

return (
<div className={containerStyles}>
{properties?.map((property) => {
return (
<PropertyBadgeWithTooltip
key={property}
text={property}
link={getIndexHelpLink(property) ?? '#'}
tooltip={getPropertyTooltip(property, extra)}
/>
);
})}
{extra &&
properties?.map((property) => {
return (
<PropertyBadgeWithTooltip
key={property}
text={property}
link={getIndexHelpLink(property) ?? '#'}
tooltip={getPropertyTooltip(property, extra)}
/>
);
})}
{cardinality === 'compound' && (
<PropertyBadgeWithTooltip
text={cardinality}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ type IndexInfo = {
};

function mergedIndexPropertyValue(index: MergedIndex): string {
// TODO: right now only regular indexes have properties & cardinality
if (index.compassIndexType !== 'regular-index') {
// TODO
return '';
}

return index.cardinality === 'compound'
? 'compound'
: index.properties?.[0] || '';
Expand All @@ -88,16 +89,19 @@ function mergedIndexFieldValue(
field: SortableField
): string | number | undefined {
if (index.compassIndexType === 'in-progress-index') {
if (field === 'type' || field === 'size' || field === 'usageCount') {
// TODO: type should be supported
return undefined;
if (field === 'type') {
// TODO: type should be supported by in-progress-index
return 'unknown';
}
if (field === 'size' || field === 'usageCount') {
return 0;
}
return (index as InProgressIndex)[field];
}

if (index.compassIndexType === 'rolling-index') {
if (field === 'size' || field === 'usageCount') {
return undefined;
return 0;
}
if (field === 'name') {
return index.indexName;
Expand Down Expand Up @@ -362,7 +366,7 @@ export const RegularIndexesTable: React.FunctionComponent<

// eslint-disable-next-line react/display-name
renderExpandedContent: () => (
// TODO: we should support badges for other rolling indexes too
// TODO: we should support IndexKeysBadge for rolling indexes too
<IndexKeysBadge
keys={
index.compassIndexType !== 'rolling-index' ? index.fields : []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const canRenderTooltip = (type: string) => {
};

type TypeFieldProps = {
// TODO: we can remove unknown once we support type on in-progress indexes
type: RegularIndex['type'] | 'unknown';
extra?: RegularIndex['extra'];
};
Expand Down

0 comments on commit 665eada

Please sign in to comment.