Skip to content

Commit d17d4d2

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

File tree

7 files changed

+16
-36
lines changed

7 files changed

+16
-36
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 & 28 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={() => {}}
@@ -185,12 +184,12 @@ const indexFields = [
185184
'indexes-actions-field',
186185
];
187186

188-
describe('RegularIndexesTable Component', function () {
187+
describe.only('RegularIndexesTable Component', function () {
189188
before(cleanup);
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;
@@ -260,7 +259,6 @@ describe('RegularIndexesTable Component', function () {
260259
it('renders in-progress indexes', function () {
261260
renderIndexList({
262261
isWritable: true,
263-
readOnly: false,
264262
inProgressIndexes: inProgressIndexes,
265263
});
266264

@@ -287,7 +285,6 @@ describe('RegularIndexesTable Component', function () {
287285
it('renders rolling indexes', function () {
288286
renderIndexList({
289287
isWritable: true,
290-
readOnly: false,
291288
rollingIndexes: rollingIndexes,
292289
});
293290

@@ -342,7 +339,6 @@ describe('RegularIndexesTable Component', function () {
342339
// index if it didn't also exist as a rolling index
343340
renderIndexList({
344341
isWritable: true,
345-
readOnly: false,
346342
indexes: indexesWithRollingIndex,
347343
});
348344

@@ -358,7 +354,6 @@ describe('RegularIndexesTable Component', function () {
358354
// up as a regular index too
359355
renderIndexList({
360356
isWritable: true,
361-
readOnly: false,
362357
indexes: indexesWithRollingIndex,
363358
rollingIndexes,
364359
});
@@ -371,7 +366,6 @@ describe('RegularIndexesTable Component', function () {
371366
it('does not render the list if there is an error', function () {
372367
renderIndexList({
373368
isWritable: true,
374-
readOnly: false,
375369
indexes: indexes,
376370
error: 'moo',
377371
});
@@ -382,39 +376,32 @@ describe('RegularIndexesTable Component', function () {
382376
});
383377

384378
it('renders the delete and hide/unhide button when a user can modify indexes', function () {
385-
renderIndexList({ isWritable: true, readOnly: false, indexes: indexes });
379+
renderIndexList({ isWritable: true, indexes: indexes });
386380
const indexesList = screen.getByTestId('indexes-list');
387381
expect(indexesList).to.exist;
388382
indexes.forEach((index) => {
389383
const indexRow = screen.getByTestId(`indexes-row-${index.name}`);
390-
expect(within(indexRow).getByTestId('indexes-actions-field')).to.exist;
384+
const buttons = within(indexRow)
385+
.getByTestId('indexes-actions-field')
386+
.querySelectorAll('button');
387+
if (index.name === '_id_') {
388+
// you can't delete or hide the _id index
389+
expect(buttons).to.be.empty;
390+
} else {
391+
expect(buttons).to.not.be.empty;
392+
}
391393
});
392394
});
393395

394396
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 });
397+
renderIndexList({ isWritable: false, indexes: indexes });
409398
const indexesList = screen.getByTestId('indexes-list');
410399
expect(indexesList).to.exist;
411-
// TODO
412-
/*
413400
indexes.forEach((index) => {
414401
const indexRow = screen.getByTestId(`indexes-row-${index.name}`);
415-
expect(within(indexRow).queryByTestId('indexes-actions-field')).to.not.exist;
402+
expect(within(indexRow).queryByTestId('indexes-actions-field')).to.not
403+
.exist;
416404
});
417-
*/
418405
});
419406

420407
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;

packages/compass-indexes/src/modules/regular-indexes.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ describe('regular-indexes module', function () {
126126
it('sets indexes to empty array for views', async function () {
127127
const indexesStub = sinon.stub().resolves([]);
128128
const store = setupStore(
129-
{
130-
isReadonly: true,
131-
},
129+
{},
132130
{
133131
indexes: indexesStub,
134132
}

0 commit comments

Comments
 (0)