Skip to content

Commit 1f494a9

Browse files
committed
turns out that the regular or search indexes table readOnly prop is not used
1 parent d5eb87e commit 1f494a9

File tree

6 files changed

+15
-45
lines changed

6 files changed

+15
-45
lines changed

packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ describe('IndexesToolbar Component', function () {
2222
hasTooManyIndexes={false}
2323
errorMessage={null}
2424
isReadonlyView={false}
25-
readOnly={false}
2625
isWritable={true}
2726
writeStateDescription={undefined}
2827
onRefreshIndexes={() => {}}

packages/compass-indexes/src/components/indexes-toolbar/indexes-toolbar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ type IndexesToolbarProps = {
8484
writeStateDescription?: string;
8585
isSearchIndexesSupported: boolean;
8686
// via withPreferences:
87-
readOnly?: boolean;
8887
collectionStats: CollectionStats;
8988
};
9089

packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.spec.tsx

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ const renderIndexList = (
164164
rollingIndexes={[]}
165165
serverVersion="4.4.0"
166166
isWritable={true}
167-
readOnly={false}
168167
onHideIndexClick={() => {}}
169168
onUnhideIndexClick={() => {}}
170169
onDeleteIndexClick={() => {}}
@@ -190,7 +189,7 @@ describe('RegularIndexesTable Component', function () {
190189
afterEach(cleanup);
191190

192191
it('renders regular indexes', function () {
193-
renderIndexList({ isWritable: true, readOnly: false, indexes: indexes });
192+
renderIndexList({ isWritable: true, indexes: indexes });
194193

195194
const indexesList = screen.getByTestId('indexes-list');
196195
expect(indexesList).to.exist;
@@ -202,19 +201,7 @@ describe('RegularIndexesTable Component', function () {
202201

203202
// Renders index fields (table cells)
204203
for (const indexCell of indexFields) {
205-
let mustExist = true;
206-
207-
// For _id index we always hide hide/drop index field buttons
208-
if (index.name === '_id_' && indexCell === 'indexes-actions-field') {
209-
mustExist = false;
210-
}
211-
212-
if (mustExist) {
213-
expect(within(indexRow).getByTestId(indexCell)).to.exist;
214-
} else {
215-
// TODO
216-
//expect(within(indexRow).queryByTestId(indexCell)).to.not.exist;
217-
}
204+
expect(within(indexRow).getByTestId(indexCell)).to.exist;
218205
}
219206

220207
if (index.name === '_id_') {
@@ -260,7 +247,6 @@ describe('RegularIndexesTable Component', function () {
260247
it('renders in-progress indexes', function () {
261248
renderIndexList({
262249
isWritable: true,
263-
readOnly: false,
264250
inProgressIndexes: inProgressIndexes,
265251
});
266252

@@ -287,7 +273,6 @@ describe('RegularIndexesTable Component', function () {
287273
it('renders rolling indexes', function () {
288274
renderIndexList({
289275
isWritable: true,
290-
readOnly: false,
291276
rollingIndexes: rollingIndexes,
292277
});
293278

@@ -342,7 +327,6 @@ describe('RegularIndexesTable Component', function () {
342327
// index if it didn't also exist as a rolling index
343328
renderIndexList({
344329
isWritable: true,
345-
readOnly: false,
346330
indexes: indexesWithRollingIndex,
347331
});
348332

@@ -358,7 +342,6 @@ describe('RegularIndexesTable Component', function () {
358342
// up as a regular index too
359343
renderIndexList({
360344
isWritable: true,
361-
readOnly: false,
362345
indexes: indexesWithRollingIndex,
363346
rollingIndexes,
364347
});
@@ -371,7 +354,6 @@ describe('RegularIndexesTable Component', function () {
371354
it('does not render the list if there is an error', function () {
372355
renderIndexList({
373356
isWritable: true,
374-
readOnly: false,
375357
indexes: indexes,
376358
error: 'moo',
377359
});
@@ -382,39 +364,32 @@ describe('RegularIndexesTable Component', function () {
382364
});
383365

384366
it('renders the delete and hide/unhide button when a user can modify indexes', function () {
385-
renderIndexList({ isWritable: true, readOnly: false, indexes: indexes });
367+
renderIndexList({ isWritable: true, indexes: indexes });
386368
const indexesList = screen.getByTestId('indexes-list');
387369
expect(indexesList).to.exist;
388370
indexes.forEach((index) => {
389371
const indexRow = screen.getByTestId(`indexes-row-${index.name}`);
390-
expect(within(indexRow).getByTestId('indexes-actions-field')).to.exist;
372+
const buttons = within(indexRow)
373+
.getByTestId('indexes-actions-field')
374+
.querySelectorAll('button');
375+
if (index.name === '_id_') {
376+
// you can't delete or hide the _id index
377+
expect(buttons).to.be.empty;
378+
} else {
379+
expect(buttons).to.not.be.empty;
380+
}
391381
});
392382
});
393383

394384
it('does not render delete and hide/unhide button when a user can not modify indexes (!isWritable)', function () {
395-
renderIndexList({ isWritable: false, readOnly: false, indexes: indexes });
396-
const indexesList = screen.getByTestId('indexes-list');
397-
expect(indexesList).to.exist;
398-
// TODO
399-
/*
400-
indexes.forEach((index) => {
401-
const indexRow = screen.getByTestId(`indexes-row-${index.name}`);
402-
expect(within(indexRow).queryByTestId('indexes-actions-field')).to.not.exist;
403-
});
404-
*/
405-
});
406-
407-
it('does not render delete and hide/unhide button when a user can not modify indexes (isWritable, readOnly)', function () {
408-
renderIndexList({ isWritable: true, readOnly: true, indexes: indexes });
385+
renderIndexList({ isWritable: false, indexes: indexes });
409386
const indexesList = screen.getByTestId('indexes-list');
410387
expect(indexesList).to.exist;
411-
// TODO
412-
/*
413388
indexes.forEach((index) => {
414389
const indexRow = screen.getByTestId(`indexes-row-${index.name}`);
415-
expect(within(indexRow).queryByTestId('indexes-actions-field')).to.not.exist;
390+
expect(within(indexRow).queryByTestId('indexes-actions-field')).to.not
391+
.exist;
416392
});
417-
*/
418393
});
419394

420395
describe('sorting', function () {

packages/compass-indexes/src/components/regular-indexes-table/regular-indexes-table.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ type RegularIndexesTableProps = {
4444
onUnhideIndexClick: (name: string) => void;
4545
onDeleteIndexClick: (name: string) => void;
4646
onDeleteFailedIndexClick: (name: string) => void;
47-
readOnly?: boolean;
4847
error?: string | null;
4948
onRegularIndexesOpened: (tabId: string) => void;
5049
onRegularIndexesClosed: (tabId: string) => void;

packages/compass-indexes/src/components/search-indexes-table/search-indexes-table.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const renderIndexList = (
2828
indexes={indexes}
2929
status="READY"
3030
isWritable={true}
31-
readOnly={false}
3231
isReadonlyView={false}
3332
onDropIndexClick={noop}
3433
onEditIndexClick={noop}

packages/compass-indexes/src/components/search-indexes-table/search-indexes-table.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ type SearchIndexesTableProps = {
4646
namespace: string;
4747
indexes: SearchIndex[];
4848
isWritable?: boolean;
49-
readOnly?: boolean;
5049
isReadonlyView: boolean;
5150
collectionStats?: CollectionStats;
5251
status: FetchStatus;

0 commit comments

Comments
 (0)