Skip to content

Commit 1fe5fe2

Browse files
Add Plugin progress indicator
1 parent db824dd commit 1fe5fe2

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

cypress/e2e/plugins/plugin-utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const managePluginsPagePath = '/manage-prototype/plugins'
99
const panelProcessingQuery = '[aria-live="polite"] #panel-processing'
1010
const panelCompleteQuery = '[aria-live="polite"] #panel-complete'
1111
const panelErrorQuery = '[aria-live="polite"] #panel-error'
12+
const processingIndicatorQuery = '#manage-plugin-progress-indicator'
1213

1314
function getTemplateLink (type, packageName, path) {
1415
const queryString = `?package=${urlencode(packageName)}&template=${urlencode(path)}`
@@ -38,6 +39,8 @@ function performPluginAction (action, plugin, pluginName) {
3839
.should('not.be.visible')
3940
cy.get(panelErrorQuery)
4041
.should('not.be.visible')
42+
cy.get(processingIndicatorQuery)
43+
.should('be.visible')
4144
cy.get(panelProcessingQuery)
4245
.should('be.visible')
4346
.contains(capitalize(processingText))
@@ -46,6 +49,8 @@ function performPluginAction (action, plugin, pluginName) {
4649

4750
cy.get(panelProcessingQuery, { timeout: 20000 })
4851
.should('not.be.visible')
52+
cy.get(processingIndicatorQuery)
53+
.should('not.be.visible')
4954
cy.get(panelErrorQuery)
5055
.should('not.be.visible')
5156
cy.get(panelCompleteQuery)
@@ -70,12 +75,16 @@ function failAction (action) {
7075
.should('not.be.visible')
7176
cy.get(panelErrorQuery)
7277
.should('not.be.visible')
78+
cy.get(processingIndicatorQuery)
79+
.should('be.visible')
7380
cy.get(panelProcessingQuery)
7481
.should('be.visible')
7582
.contains(`${capitalize(action === 'upgrade' ? 'Upgrad' : action)}ing ...`)
7683

7784
cy.get(panelProcessingQuery, { timeout: 40000 })
7885
.should('not.be.visible')
86+
cy.get(processingIndicatorQuery)
87+
.should('not.be.visible')
7988
cy.get(panelCompleteQuery)
8089
.should('not.be.visible')
8190
cy.get(panelErrorQuery)

lib/assets/javascripts/manage-prototype/manage-plugins.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,42 @@
1010
let timedOut = false
1111
let kitIsRestarting = false
1212
let actionTimeoutId
13-
13+
let indicatorIntervalId
1414
const show = (id) => {
1515
const element = document.getElementById(id)
1616
element.hidden = false
1717
}
1818

19-
const hide = (id) => {
19+
const hide = (id, clearContents = false) => {
2020
const element = document.getElementById(id)
2121
element.hidden = true
22+
if (clearContents) {
23+
element.innerHTML = ''
24+
}
25+
}
26+
27+
const startProcessing = () => {
28+
const element = document.getElementById('manage-plugin-progress-indicator')
29+
const updateProgressIndicator = () => {
30+
element.innerHTML += '. '
31+
}
32+
indicatorIntervalId = setInterval(updateProgressIndicator, 1000)
33+
show('panel-processing')
34+
show('manage-plugin-progress-indicator')
35+
updateProgressIndicator()
36+
}
37+
38+
const stopProcessing = () => {
39+
clearInterval(indicatorIntervalId)
40+
hide('manage-plugin-progress-indicator', true)
41+
hide('panel-processing')
2242
}
2343

2444
const showCompleteStatus = () => {
2545
if (actionTimeoutId) {
2646
clearTimeout(actionTimeoutId)
2747
}
28-
hide('panel-processing')
48+
stopProcessing()
2949
show('panel-complete')
3050
show('instructions-complete')
3151
}
@@ -34,7 +54,7 @@
3454
if (actionTimeoutId) {
3555
clearTimeout(actionTimeoutId)
3656
}
37-
hide('panel-processing')
57+
stopProcessing()
3858
show('panel-error')
3959
}
4060

@@ -114,7 +134,7 @@
114134
hide('plugin-action-confirmation')
115135
}
116136

117-
show('panel-processing')
137+
startProcessing()
118138

119139
return postRequest(`/manage-prototype/plugins/${mode}`)
120140
.then(data => {

lib/assets/javascripts/manage-prototype/manage-plugins.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const loadedHTML = `
1212
<div>
1313
<div id="panel-manual-instructions"></div>
1414
<div id="panel-processing" hidden=""></div>
15+
<div id="manage-plugin-progress-indicator" hidden=""></div>
1516
<div id="panel-complete" hidden=""></div>
1617
<div id="panel-error" hidden=""></div>
1718
<div id="instructions-complete" hidden=""></div>
@@ -22,6 +23,7 @@ const processingHTML = `
2223
<div>
2324
<div id="panel-manual-instructions" hidden=""></div>
2425
<div id="panel-processing"></div>
26+
<div id="manage-plugin-progress-indicator"></div>
2527
<div id="panel-complete" hidden=""></div>
2628
<div id="panel-error" hidden=""></div>
2729
<div id="instructions-complete" hidden=""></div>
@@ -32,6 +34,7 @@ const completedHTML = `
3234
<div>
3335
<div id="panel-manual-instructions" hidden=""></div>
3436
<div id="panel-processing" hidden=""></div>
37+
<div id="manage-plugin-progress-indicator" hidden=""></div>
3538
<div id="panel-complete"></div>
3639
<div id="panel-error" hidden=""></div>
3740
<div id="instructions-complete"></div>
@@ -42,6 +45,7 @@ const errorHTML = `
4245
<div>
4346
<div id="panel-manual-instructions" hidden=""></div>
4447
<div id="panel-processing" hidden=""></div>
48+
<div id="manage-plugin-progress-indicator" hidden=""></div>
4549
<div id="panel-complete" hidden=""></div>
4650
<div id="panel-error"></div>
4751
<div id="instructions-complete" hidden=""></div>

lib/nunjucks/views/manage-prototype/plugin-install-or-uninstall.njk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979

8080
</div>
8181

82+
<div hidden id="manage-plugin-progress-indicator" class="js-visible govuk-!-font-size-27"></div>
83+
8284
</div>
8385
</div>
8486
{% endblock %}

0 commit comments

Comments
 (0)