diff --git a/src/components/record/related-table-actions.tsx b/src/components/record/related-table-actions.tsx
index 6e6fa3cf7..b73f87e81 100644
--- a/src/components/record/related-table-actions.tsx
+++ b/src/components/record/related-table-actions.tsx
@@ -699,6 +699,23 @@ const RelatedTableActions = ({
);
};
+
+ const renderBulkEditBtnTooltip = () => {
+ if (relatedModel.recordsetState.page?.length < 1) {
+ return(
+
+ Unable to edit {currentTable} records until some are created.
+
+ )
+ }
+
+ return(
+
+ Edit this page of {currentTable} records related to this {mainTable}.
+
+ )
+ }
+
/*
* This function is to render each button. We call the renderButton function with button text,
* inner element classname and boolean flag to show tertiary class(for the dropdown buttons) or not
@@ -715,8 +732,12 @@ const RelatedTableActions = ({
{relatedModel.isPureBinary && relatedModel.canDelete && renderButton('Unlink records', false)}
{allowCustomModeRelated(relatedModel) && renderCustomModeBtn()}
-
- {relatedModel.canEdit && renderButton('Bulk Edit', false)}
+ {/*
+ * if user can edit, also check for create permission
+ * - if they can't create, allow edit if there are some rows set
+ * - disable button if can create but no rows
+ */}
+ {relatedModel.canEdit && (relatedModel.canCreate || relatedModel.recordsetState.page?.length > 0) && renderButton('Bulk Edit', false)}
{renderButton('Explore', false)}
@@ -754,21 +775,20 @@ const RelatedTableActions = ({
);
case 'Bulk Edit':
+ const disableBulkEdit = relatedModel.recordsetState.page?.length < 1;
return (
- Edit this page of {currentTable} records related to this {mainTable}.
-
- }
+ tooltip={renderBulkEditBtnTooltip()}
>
Bulk Edit
diff --git a/test/e2e/specs/all-features-confirmation/record/presentation.spec.js b/test/e2e/specs/all-features-confirmation/record/presentation.spec.js
index 256246822..e3987396a 100644
--- a/test/e2e/specs/all-features-confirmation/record/presentation.spec.js
+++ b/test/e2e/specs/all-features-confirmation/record/presentation.spec.js
@@ -280,6 +280,18 @@ describe('View existing record,', function() {
expect(chaisePage.recordPage.getRelatedTables().count()).not.toBe(testParams.no_related_data.tables_order.length, "The full set of related tables were not properly hidden");
})
});
+
+ it('should have "booking" related table with bulk edit disabled when no rows', () => {
+ const btn = chaisePage.recordPage.getBulkEditLink('booking', true);
+
+ expect(btn.isPresent()).toBeTruthy();
+ expect(btn.getAttribute('class')).toContain('disabled', 'Bulk edit is not disabled');
+ });
+
+ it('should have "accommodation_collections" related table with bulk edit removed when the user cannot create and there are no rows present', () => {
+ const btn = chaisePage.recordPage.getBulkEditLink('accommodation_collections', true);
+ expect(btn.isPresent()).not.toBeTruthy();
+ });
});
describe("For side panel table of contents in Record App", function() {