diff --git a/packages/oui-modal/README.md b/packages/oui-modal/README.md
index 6cc3d121..ab008655 100644
--- a/packages/oui-modal/README.md
+++ b/packages/oui-modal/README.md
@@ -44,11 +44,10 @@
@@ -61,17 +60,29 @@
### Warning modal
```html:preview
-
Modal content
-
+```
+
+### Disabled buttons
+
+```html:preview
+
+ You shall not pass!
+
```
## API
@@ -83,8 +94,10 @@
| `loading` | boolean | | no | `true`, `false` | `false` | display loader flag
| `primary-label` | string | @? | yes | n/a | n/a | confirmation label
| `primary-action` | function | & | no | n/a | n/a | confirmation callback
+| `primary-disabled` | boolean | | no | `true`, `false` | `false` | disable the primary button
| `secondary-label` | string | @? | yes | n/a | n/a | cancellation label
| `secondary-action` | function | & | no | n/a | n/a | cancellation callback
+| `secondary-disabled` | boolean | | no | `true`, `false` | `false` | disable the secondary button
| `on-dismiss` | function | & | no | n/a | n/a | dismiss callback
#### Deprecated
diff --git a/packages/oui-modal/src/index.spec.js b/packages/oui-modal/src/index.spec.js
index e14f68c9..7c4c63dc 100644
--- a/packages/oui-modal/src/index.spec.js
+++ b/packages/oui-modal/src/index.spec.js
@@ -177,6 +177,35 @@ describe("ouiModal", () => {
expect($secondaryButton.attr("disabled")).toBe("disabled");
});
+ it("should disable buttons when the conditions are met", () => {
+ const primaryDisabled = true;
+ const secondaryDisabled = true;
+
+ const element = TestUtils.compileTemplate(`
+
+
+ `, {
+ primaryLabel,
+ secondaryLabel,
+ primaryDisabled,
+ secondaryDisabled
+ });
+
+ const $footer = getFooter(element);
+ const $primaryButton = getPrimaryButton($footer);
+ const $secondaryButton = getSecondaryButton($footer);
+
+ expect($primaryButton).toBeDefined();
+ expect($primaryButton.attr("disabled")).toBe("disabled");
+ expect($secondaryButton).toBeDefined();
+ expect($secondaryButton.attr("disabled")).toBe("disabled");
+ });
+
it("should trigger secondary action", () => {
const secondarySpy = jasmine.createSpy("secondaryClick");
const element = TestUtils.compileTemplate(`
diff --git a/packages/oui-modal/src/modal.component.js b/packages/oui-modal/src/modal.component.js
index 5a656647..2576c362 100644
--- a/packages/oui-modal/src/modal.component.js
+++ b/packages/oui-modal/src/modal.component.js
@@ -11,8 +11,10 @@ export default {
loading: "",
primaryLabel: "@?",
primaryAction: "&",
+ primaryDisabled: "",
secondaryLabel: "@?",
secondaryAction: "&",
+ secondaryDisabled: "",
onDismiss: "&"
},
transclude: true
diff --git a/packages/oui-modal/src/modal.controller.js b/packages/oui-modal/src/modal.controller.js
index 465b3686..eaecd8ba 100644
--- a/packages/oui-modal/src/modal.controller.js
+++ b/packages/oui-modal/src/modal.controller.js
@@ -11,6 +11,8 @@ export default class {
$onInit () {
addBooleanParameter(this, "loading");
+ addBooleanParameter(this, "primaryDisabled");
+ addBooleanParameter(this, "secondaryDisabled");
// Deprecated: Support for 'title' attribute
if (!!this.$attrs.title && !this.$attrs.heading) {
diff --git a/packages/oui-modal/src/modal.html b/packages/oui-modal/src/modal.html
index f374c115..8baee373 100644
--- a/packages/oui-modal/src/modal.html
+++ b/packages/oui-modal/src/modal.html
@@ -28,13 +28,13 @@
ng-if="$ctrl.secondaryLabel"
ng-bind="$ctrl.secondaryLabel"
ng-click="$ctrl.secondaryAction()"
- ng-disabled="$ctrl.loading">
+ ng-disabled="$ctrl.loading || $ctrl.secondaryDisabled">