[] = [];
- const buildProgress = index.buildProgress;
- const isBuilding = buildProgress > 0 && buildProgress < 1;
-
- if (isBuilding) {
- // partially built
- actions.push({
- action: 'delete',
- label: `Cancel Index ${index.name}`,
- icon: 'XWithCircle',
- variant: 'destructive',
- });
- } else {
- // completed
- if (serverSupportsHideIndex(serverVersion)) {
- actions.push(
- index.extra?.hidden
- ? {
- action: 'unhide',
- label: `Unhide Index ${index.name}`,
- tooltip: `Unhide Index`,
- icon: 'Visibility',
- }
- : {
- action: 'hide',
- label: `Hide Index ${index.name}`,
- tooltip: `Hide Index`,
- icon: 'VisibilityOff',
- }
- );
- }
-
- actions.push({
- action: 'delete',
- label: `Drop Index ${index.name}`,
- icon: 'Trash',
- });
- }
-
- return actions;
- }, [index.name, index.extra?.hidden, index.buildProgress, serverVersion]);
-
- const onAction = useCallback(
- (action: IndexAction) => {
- if (action === 'delete') {
- onDeleteIndexClick(index.name);
- } else if (action === 'hide') {
- onHideIndexClick(index.name);
- } else if (action === 'unhide') {
- onUnhideIndexClick(index.name);
- }
- },
- [onDeleteIndexClick, onHideIndexClick, onUnhideIndexClick, index]
- );
-
- const buildProgress = index.buildProgress;
- if (buildProgress > 0 && buildProgress < 1) {
- return (
-
- Building... {Math.trunc(buildProgress * 100)}%
-
-
- data-testid="index-actions"
- actions={indexActions}
- onAction={onAction}
- />
-
- );
- }
-
- return (
-
- data-testid="index-actions"
- className={styles}
- actions={indexActions}
- onAction={onAction}
- />
- );
-};
-
-export default IndexActions;
diff --git a/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.spec.tsx b/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.spec.tsx
index 63ac2278aa5..e97c9ba4c76 100644
--- a/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.spec.tsx
+++ b/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.spec.tsx
@@ -121,7 +121,7 @@ const inProgressIndexes: InProgressIndex[] = [
value: -1,
},
],
- status: 'inprogress',
+ status: 'creating',
buildProgress: 0,
},
{
@@ -133,7 +133,7 @@ const inProgressIndexes: InProgressIndex[] = [
value: 'text',
},
],
- status: 'inprogress',
+ status: 'creating',
error: 'this is an error',
buildProgress: 0,
},
@@ -274,7 +274,7 @@ describe('RegularIndexesTable Component', function () {
expect(() => within(indexRow).getByTestId('index-actions-hide-action')).to
.throw;
- if (index.status === 'inprogress') {
+ if (index.status === 'creating') {
expect(() =>
within(indexRow).getByTestId('index-actions-delete-action')
).to.throw;
diff --git a/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.tsx b/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.tsx
index 565d122d0c6..5400668417c 100644
--- a/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.tsx
+++ b/packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.tsx
@@ -16,8 +16,7 @@ import SizeField from './size-field';
import UsageField from './usage-field';
import PropertyField from './property-field';
import StatusField from './status-field';
-import RegularIndexActions from './regular-index-actions';
-import InProgressIndexActions from './in-progress-index-actions';
+import IndexActions from './index-actions';
import { IndexesTable } from '../indexes-table';
import {
@@ -122,7 +121,7 @@ function mergedIndexFieldValue(
}
if (field === 'status') {
- return 'ready';
+ return determineRegularIndexStatus(index);
}
return index[field];
@@ -282,6 +281,21 @@ function mergeIndexes(
type CommonIndexInfo = Omit;
+/**
+ * Determines the display status for a regular index based on its build progress
+ */
+function determineRegularIndexStatus(
+ index: RegularIndex
+): 'inprogress' | 'ready' {
+ // Build progress determines building vs ready
+ if (index.buildProgress > 0 && index.buildProgress < 1) {
+ return 'inprogress';
+ }
+
+ // Default to ready for completed indexes (buildProgress = 0 or 1)
+ return 'ready';
+}
+
function getInProgressIndexInfo(
index: MappedInProgressIndex,
{
@@ -301,10 +315,10 @@ function getInProgressIndexInfo(
properties: null,
status: ,
actions: (
-
+ />
),
};
}
@@ -321,7 +335,7 @@ function getRollingIndexInfo(index: MappedRollingIndex): CommonIndexInfo {
// TODO(COMPASS-7589): add properties for rolling indexes
properties: null,
status: ,
- actions: null,
+ actions: null, // Rolling indexes don't have actions
};
}
@@ -339,6 +353,8 @@ function getRegularIndexInfo(
onDeleteIndexClick: (indexName: string) => void;
}
): CommonIndexInfo {
+ const status = determineRegularIndexStatus(index);
+
return {
id: index.name,
name: index.name,
@@ -355,23 +371,15 @@ function getRegularIndexInfo(
properties={index.properties}
/>
),
- status: (
- 0 && index.buildProgress < 1
- ? 'inprogress'
- : 'ready'
- }
- />
- ),
+ status: ,
actions: index.name !== '_id_' && (
-
+ />
),
};
}
diff --git a/packages/compass-indexes/src/components/regular-indexes-table/status-field.tsx b/packages/compass-indexes/src/components/regular-indexes-table/status-field.tsx
index 0fd5c75e1c1..fd8187c88dc 100644
--- a/packages/compass-indexes/src/components/regular-indexes-table/status-field.tsx
+++ b/packages/compass-indexes/src/components/regular-indexes-table/status-field.tsx
@@ -53,7 +53,7 @@ const BadgeWithTooltip: React.FunctionComponent<{
};
type StatusFieldProps = {
- status: InProgressIndex['status'] | 'ready' | 'building';
+ status: InProgressIndex['status'] | 'ready' | 'building' | 'inprogress';
error?: InProgressIndex['error'];
};
@@ -87,6 +87,12 @@ const StatusField: React.FunctionComponent = ({
)}
+ {status === 'creating' && (
+
+ Creating
+
+ )}
+
{status === 'failed' && (
&
export type InProgressIndex = Pick & {
id: string;
- status: 'inprogress' | 'failed';
+ status: 'creating' | 'failed';
error?: string;
buildProgress: number;
};
@@ -82,7 +82,7 @@ export const prepareInProgressIndex = (
id,
// TODO(COMPASS-8335): we need the type because it shows in the table
// TODO(COMPASS-8335): the table can also use cardinality
- status: 'inprogress',
+ status: 'creating',
fields: inProgressIndexFields,
name: inProgressIndexName,
buildProgress: 0,
diff --git a/packages/compass-indexes/test/fixtures/regular-indexes.ts b/packages/compass-indexes/test/fixtures/regular-indexes.ts
index 2e4218d2d10..dc880db665d 100644
--- a/packages/compass-indexes/test/fixtures/regular-indexes.ts
+++ b/packages/compass-indexes/test/fixtures/regular-indexes.ts
@@ -254,7 +254,7 @@ export const inProgressIndexes: InProgressIndex[] = [
name: 'AAAA',
//version: 2,
fields: [],
- status: 'inprogress',
+ status: 'creating',
buildProgress: 0,
},
{
@@ -266,7 +266,7 @@ export const inProgressIndexes: InProgressIndex[] = [
value: 1,
},
],
- status: 'inprogress',
+ status: 'creating',
buildProgress: 0,
},
];