-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11036 from jmchilton/workflow_message_modal
Vue-ify Workflow State Upgrade Message Modal
- Loading branch information
Showing
7 changed files
with
255 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
client/src/components/Workflow/Editor/StateUpgradeModal.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { shallowMount, createLocalVue } from "@vue/test-utils"; | ||
import StateUpgradeModal from "./StateUpgradeModal"; | ||
|
||
const localVue = createLocalVue(); | ||
|
||
describe("StateUpgradeModal.vue", () => { | ||
let wrapper; | ||
|
||
async function mountWith(stateMessages) { | ||
wrapper = shallowMount(StateUpgradeModal, { | ||
propsData: { | ||
stateMessages, | ||
}, | ||
localVue, | ||
}); | ||
await wrapper.vm.$nextTick(); | ||
} | ||
|
||
it("should not render if there are no messages", async () => { | ||
const stateMessages = []; | ||
await mountWith(stateMessages); | ||
expect(wrapper.vm.show).toBeFalsy(); | ||
}); | ||
|
||
it("should render if there are messages", async () => { | ||
const stateMessages = [ | ||
{ | ||
stepIndex: 2, | ||
stepName: "step name", | ||
details: ["my message 1", "my message 2"], | ||
}, | ||
]; | ||
await mountWith(stateMessages); | ||
expect(wrapper.vm.show).toBeTruthy(); | ||
}); | ||
|
||
async function mountSomeInitialMessagesAndDismiss() { | ||
const stateMessages = [ | ||
{ | ||
stepIndex: 2, | ||
stepName: "step name", | ||
details: ["my message 1", "my message 2"], | ||
}, | ||
]; | ||
await mountWith(stateMessages); | ||
wrapper.vm.show = false; | ||
await wrapper.vm.$nextTick(); | ||
expect(wrapper.vm.show).toBeFalsy(); | ||
} | ||
|
||
it("should re-render when passed new messages", async () => { | ||
await mountSomeInitialMessagesAndDismiss(); | ||
const stateMessagesNew = [ | ||
{ | ||
stepIndex: 3, | ||
stepName: "step name", | ||
details: ["my message 1", "my message 2"], | ||
}, | ||
]; | ||
await wrapper.setProps({ | ||
stateMessages: stateMessagesNew, | ||
}); | ||
expect(wrapper.vm.show).toBeTruthy(); | ||
}); | ||
|
||
it("should not re-render if sent empty messages", async () => { | ||
await mountSomeInitialMessagesAndDismiss(); | ||
const stateMessagesNew = []; | ||
await wrapper.setProps({ | ||
stateMessages: stateMessagesNew, | ||
}); | ||
expect(wrapper.vm.show).toBeFalsy(); | ||
}); | ||
}); |
76 changes: 76 additions & 0 deletions
76
client/src/components/Workflow/Editor/StateUpgradeModal.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<template> | ||
<b-modal v-model="show" title="Issues loading this workflow" scrollable ok-only ok-title="Continue"> | ||
<div class="state-upgrade-modal"> | ||
Please review the following issues, possibly resulting from tool upgrades or changes. | ||
<ul class="workflow-state-upgrade-step-summaries"> | ||
<li v-for="(stateMessage, index) in stateMessages" :key="index"> | ||
<b> | ||
<i :class="iconClass(stateMessage)" /> | ||
Step {{ humanIndex(stateMessage) }}: {{ title(stateMessage) }} | ||
</b> | ||
<ul class="workflow-state-upgrade-step-details"> | ||
<li v-for="(detail, detailIndex) in stateMessage.details" :key="detailIndex"> | ||
- <span v-html="detail" /> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</div> | ||
</b-modal> | ||
</template> | ||
|
||
<script> | ||
import { BModal } from "bootstrap-vue"; | ||
export default { | ||
components: { BModal }, | ||
props: { | ||
stateMessages: { | ||
type: Array, | ||
requierd: true, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
show: this.stateMessages.length > 0, | ||
}; | ||
}, | ||
methods: { | ||
humanIndex(stateMessage) { | ||
return `${parseInt(stateMessage.stepIndex, 10) + 1}`; | ||
}, | ||
title(stateMessage) { | ||
return stateMessage.label ? stateMessage.label : stateMessage.name; | ||
}, | ||
iconClass(stateMessage) { | ||
let iconClassStr = ""; | ||
if (stateMessage.iconType) { | ||
// stolen from Node.vue. | ||
iconClassStr = `icon fa fa-fw ${stateMessage.iconType}`; | ||
} | ||
return iconClassStr; | ||
}, | ||
}, | ||
watch: { | ||
stateMessages() { | ||
if (this.stateMessages.length > 0) { | ||
this.show = true; | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
/* scoped styles not working because of modal, using long names instead. */ | ||
ul.workflow-state-upgrade-step-summaries { | ||
margin-top: 10px; | ||
padding: 10px; | ||
} | ||
ul.workflow-state-upgrade-step-details { | ||
list-style-type: square !important; | ||
} | ||
ul.workflow-state-upgrade-step-details li { | ||
padding-left: 5px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters