Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
b9f9e6fa
Commit
b9f9e6fa
authored
Mar 07, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes UJS from reset cache button
Uses loading button for better UX
parent
2b8e9add
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
26 deletions
+73
-26
app/assets/javascripts/pipelines/components/nav_controls.vue
app/assets/javascripts/pipelines/components/nav_controls.vue
+21
-6
app/assets/javascripts/pipelines/components/pipelines.vue
app/assets/javascripts/pipelines/components/pipelines.vue
+21
-0
app/assets/javascripts/pipelines/mixins/pipelines.js
app/assets/javascripts/pipelines/mixins/pipelines.js
+2
-4
spec/features/projects/pipelines/pipelines_spec.rb
spec/features/projects/pipelines/pipelines_spec.rb
+5
-3
spec/javascripts/pipelines/nav_controls_spec.js
spec/javascripts/pipelines/nav_controls_spec.js
+24
-13
No files found.
app/assets/javascripts/pipelines/components/nav_controls.vue
View file @
b9f9e6fa
<
script
>
<
script
>
import
LoadingButton
from
'
../../vue_shared/components/loading_button.vue
'
;
export
default
{
export
default
{
name
:
'
PipelineNavControls
'
,
name
:
'
PipelineNavControls
'
,
components
:
{
LoadingButton
,
},
props
:
{
props
:
{
newPipelinePath
:
{
newPipelinePath
:
{
type
:
String
,
type
:
String
,
...
@@ -19,6 +24,17 @@
...
@@ -19,6 +24,17 @@
required
:
false
,
required
:
false
,
default
:
null
,
default
:
null
,
},
},
isResetCacheButtonLoading
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
methods
:
{
onClickResetCache
()
{
this
.
$emit
(
'
resetRunnersCache
'
,
this
.
resetCachePath
);
},
},
},
};
};
</
script
>
</
script
>
...
@@ -32,14 +48,13 @@
...
@@ -32,14 +48,13 @@
{{
s__
(
'
Pipelines|Run Pipeline
'
)
}}
{{
s__
(
'
Pipelines|Run Pipeline
'
)
}}
</a>
</a>
<
a
<
loading-button
v-if=
"resetCachePath"
v-if=
"resetCachePath"
data-method=
"post
"
@
click=
"onClickResetCache
"
:
href=
"resetCachePath
"
:
loading=
"isResetCacheButtonLoading
"
class=
"btn btn-default js-clear-cache"
class=
"btn btn-default js-clear-cache"
>
:label=
"s__('Pipelines|Clear Runner Caches')"
{{
s__
(
'
Pipelines|Clear Runner Caches
'
)
}}
/>
</a>
<a
<a
v-if=
"ciLintPath"
v-if=
"ciLintPath"
...
...
app/assets/javascripts/pipelines/components/pipelines.vue
View file @
b9f9e6fa
<
script
>
<
script
>
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
{
__
,
sprintf
,
s__
}
from
'
../../locale
'
;
import
{
__
,
sprintf
,
s__
}
from
'
../../locale
'
;
import
createFlash
from
'
../../flash
'
;
import
PipelinesService
from
'
../services/pipelines_service
'
;
import
PipelinesService
from
'
../services/pipelines_service
'
;
import
pipelinesMixin
from
'
../mixins/pipelines
'
;
import
pipelinesMixin
from
'
../mixins/pipelines
'
;
import
TablePagination
from
'
../../vue_shared/components/table_pagination.vue
'
;
import
TablePagination
from
'
../../vue_shared/components/table_pagination.vue
'
;
...
@@ -92,6 +93,7 @@
...
@@ -92,6 +93,7 @@
scope
:
getParameterByName
(
'
scope
'
)
||
'
all
'
,
scope
:
getParameterByName
(
'
scope
'
)
||
'
all
'
,
page
:
getParameterByName
(
'
page
'
)
||
'
1
'
,
page
:
getParameterByName
(
'
page
'
)
||
'
1
'
,
requestData
:
{},
requestData
:
{},
isResetCacheButtonLoading
:
false
,
};
};
},
},
stateMap
:
{
stateMap
:
{
...
@@ -265,6 +267,23 @@
...
@@ -265,6 +267,23 @@
this
.
poll
.
restart
({
data
:
this
.
requestData
});
this
.
poll
.
restart
({
data
:
this
.
requestData
});
});
});
},
},
handleResetRunnersCache
(
endpoint
)
{
this
.
isResetCacheButtonLoading
=
true
;
this
.
service
.
postAction
(
endpoint
)
.
then
(()
=>
{
this
.
isResetCacheButtonLoading
=
false
;
createFlash
(
s__
(
'
Pipelines|Project cache successfully reset.
'
),
'
notice
'
,
);
})
.
catch
(()
=>
{
this
.
isResetCacheButtonLoading
=
false
;
createFlash
(
s__
(
'
Pipelines|Something went wrong while cleaning runners cache.
'
));
});
},
},
},
};
};
</
script
>
</
script
>
...
@@ -301,6 +320,8 @@
...
@@ -301,6 +320,8 @@
:new-pipeline-path=
"newPipelinePath"
:new-pipeline-path=
"newPipelinePath"
:reset-cache-path=
"resetCachePath"
:reset-cache-path=
"resetCachePath"
:ci-lint-path=
"ciLintPath"
:ci-lint-path=
"ciLintPath"
@
resetRunnersCache=
"handleResetRunnersCache"
:is-reset-cache-button-loading=
"isResetCacheButtonLoading"
/>
/>
</div>
</div>
...
...
app/assets/javascripts/pipelines/mixins/pipelines.js
View file @
b9f9e6fa
...
@@ -51,12 +51,10 @@ export default {
...
@@ -51,12 +51,10 @@ export default {
}
}
});
});
eventHub
.
$on
(
'
refreshPipelines
'
,
this
.
fetchPipelines
);
eventHub
.
$on
(
'
postAction
'
,
this
.
postAction
);
eventHub
.
$on
(
'
postAction
'
,
this
.
postAction
);
},
},
beforeDestroy
()
{
beforeDestroy
()
{
eventHub
.
$off
(
'
refreshPipelines
'
);
eventHub
.
$off
(
'
postAction
'
,
this
.
postAction
);
eventHub
.
$on
(
'
postAction
'
,
this
.
postAction
);
},
},
destroyed
()
{
destroyed
()
{
this
.
poll
.
stop
();
this
.
poll
.
stop
();
...
@@ -92,7 +90,7 @@ export default {
...
@@ -92,7 +90,7 @@ export default {
},
},
postAction
(
endpoint
)
{
postAction
(
endpoint
)
{
this
.
service
.
postAction
(
endpoint
)
this
.
service
.
postAction
(
endpoint
)
.
then
(()
=>
eventHub
.
$emit
(
'
refreshPipelines
'
))
.
then
(()
=>
this
.
fetchPipelines
(
))
.
catch
(()
=>
Flash
(
__
(
'
An error occurred while making the request.
'
)));
.
catch
(()
=>
Flash
(
__
(
'
An error occurred while making the request.
'
)));
},
},
},
},
...
...
spec/features/projects/pipelines/pipelines_spec.rb
View file @
b9f9e6fa
...
@@ -557,7 +557,7 @@ describe 'Pipelines', :js do
...
@@ -557,7 +557,7 @@ describe 'Pipelines', :js do
end
end
it
'has a clear caches button'
do
it
'has a clear caches button'
do
expect
(
page
).
to
have_
link
'Clear Runner Caches'
expect
(
page
).
to
have_
button
'Clear Runner Caches'
end
end
describe
'user clicks the button'
do
describe
'user clicks the button'
do
...
@@ -567,14 +567,16 @@ describe 'Pipelines', :js do
...
@@ -567,14 +567,16 @@ describe 'Pipelines', :js do
end
end
it
'increments jobs_cache_index'
do
it
'increments jobs_cache_index'
do
click_link
'Clear Runner Caches'
click_button
'Clear Runner Caches'
wait_for_requests
expect
(
page
.
find
(
'.flash-notice'
)).
to
have_content
'Project cache successfully reset.'
expect
(
page
.
find
(
'.flash-notice'
)).
to
have_content
'Project cache successfully reset.'
end
end
end
end
context
'when project does not have jobs_cache_index'
do
context
'when project does not have jobs_cache_index'
do
it
'sets jobs_cache_index to 1'
do
it
'sets jobs_cache_index to 1'
do
click_link
'Clear Runner Caches'
click_button
'Clear Runner Caches'
wait_for_requests
expect
(
page
.
find
(
'.flash-notice'
)).
to
have_content
'Project cache successfully reset.'
expect
(
page
.
find
(
'.flash-notice'
)).
to
have_content
'Project cache successfully reset.'
end
end
end
end
...
...
spec/javascripts/pipelines/nav_controls_spec.js
View file @
b9f9e6fa
...
@@ -39,30 +39,41 @@ describe('Pipelines Nav Controls', () => {
...
@@ -39,30 +39,41 @@ describe('Pipelines Nav Controls', () => {
expect
(
component
.
$el
.
querySelector
(
'
.js-run-pipeline
'
)).
toEqual
(
null
);
expect
(
component
.
$el
.
querySelector
(
'
.js-run-pipeline
'
)).
toEqual
(
null
);
});
});
it
(
'
should render link for
resetting runner caches
'
,
()
=>
{
it
(
'
should render link for
CI lint
'
,
()
=>
{
const
mockData
=
{
const
mockData
=
{
newPipelinePath
:
'
foo
'
,
newPipelinePath
:
'
foo
'
,
helpPagePath
:
'
foo
'
,
ciLintPath
:
'
foo
'
,
ciLintPath
:
'
foo
'
,
resetCachePath
:
'
foo
'
,
resetCachePath
:
'
foo
'
,
};
};
component
=
mountComponent
(
NavControlsComponent
,
mockData
);
component
=
mountComponent
(
NavControlsComponent
,
mockData
);
expect
(
component
.
$el
.
querySelector
(
'
.js-c
lear-cache
'
).
textContent
.
trim
()).
toContain
(
'
Clear Runner Caches
'
);
expect
(
component
.
$el
.
querySelector
(
'
.js-c
i-lint
'
).
textContent
.
trim
()).
toContain
(
'
CI Lint
'
);
expect
(
component
.
$el
.
querySelector
(
'
.js-c
lear-cache
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mockData
.
resetCache
Path
);
expect
(
component
.
$el
.
querySelector
(
'
.js-c
i-lint
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mockData
.
ciLint
Path
);
});
});
it
(
'
should render link for CI lint
'
,
()
=>
{
describe
(
'
Reset Runners Cache
'
,
()
=>
{
beforeEach
(()
=>
{
const
mockData
=
{
const
mockData
=
{
newPipelinePath
:
'
foo
'
,
newPipelinePath
:
'
foo
'
,
helpPagePath
:
'
foo
'
,
ciLintPath
:
'
foo
'
,
ciLintPath
:
'
foo
'
,
resetCachePath
:
'
foo
'
,
resetCachePath
:
'
foo
'
,
};
};
component
=
mountComponent
(
NavControlsComponent
,
mockData
);
component
=
mountComponent
(
NavControlsComponent
,
mockData
);
});
expect
(
component
.
$el
.
querySelector
(
'
.js-ci-lint
'
).
textContent
.
trim
()).
toContain
(
'
CI Lint
'
);
it
(
'
should render button for resetting runner caches
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-ci-lint
'
).
getAttribute
(
'
href
'
)).
toEqual
(
mockData
.
ciLintPath
);
expect
(
component
.
$el
.
querySelector
(
'
.js-clear-cache
'
).
textContent
.
trim
()).
toContain
(
'
Clear Runner Caches
'
);
});
it
(
'
should emit postAction event when reset runner cache button is clicked
'
,
()
=>
{
spyOn
(
component
,
'
$on
'
);
component
.
$el
.
querySelector
(
'
.js-clear-cache
'
).
click
();
expect
(
component
.
$on
).
toHaveBeenCalledWith
(
'
postAction
'
,
'
foo
'
);
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment