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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a527c9b9
Commit
a527c9b9
authored
Apr 20, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix disabled state while making a request
Provide props down instead of an event
parent
44a222ad
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
94 deletions
+159
-94
app/assets/javascripts/pipelines/components/graph/action_component.vue
...vascripts/pipelines/components/graph/action_component.vue
+19
-6
app/assets/javascripts/pipelines/components/graph/dropdown_job_component.vue
...pts/pipelines/components/graph/dropdown_job_component.vue
+71
-64
app/assets/javascripts/pipelines/components/graph/graph_component.vue
...avascripts/pipelines/components/graph/graph_component.vue
+3
-4
app/assets/javascripts/pipelines/components/graph/job_component.vue
.../javascripts/pipelines/components/graph/job_component.vue
+3
-7
app/assets/javascripts/pipelines/components/graph/stage_column_component.vue
...pts/pipelines/components/graph/stage_column_component.vue
+4
-3
app/assets/javascripts/pipelines/pipeline_details_bundle.js
app/assets/javascripts/pipelines/pipeline_details_bundle.js
+10
-7
changelogs/unreleased/33697-remove-ujs-action-big-graph.yml
changelogs/unreleased/33697-remove-ujs-action-big-graph.yml
+5
-0
spec/javascripts/pipelines/graph/action_component_spec.js
spec/javascripts/pipelines/graph/action_component_spec.js
+44
-3
No files found.
app/assets/javascripts/pipelines/components/graph/action_component.vue
View file @
a527c9b9
...
@@ -32,26 +32,38 @@ export default {
...
@@ -32,26 +32,38 @@ export default {
required
:
true
,
required
:
true
,
},
},
buttonDisabled
:
{
requestFinishedFor
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
null
,
default
:
''
,
},
},
},
},
data
()
{
return
{
isDisabled
:
false
,
linkRequested
:
''
,
};
},
computed
:
{
computed
:
{
cssClass
()
{
cssClass
()
{
const
actionIconDash
=
dasherize
(
this
.
actionIcon
);
const
actionIconDash
=
dasherize
(
this
.
actionIcon
);
return
`
${
actionIconDash
}
js-icon-
${
actionIconDash
}
`
;
return
`
${
actionIconDash
}
js-icon-
${
actionIconDash
}
`
;
},
},
isDisabled
()
{
},
return
this
.
buttonDisabled
===
this
.
link
;
watch
:
{
requestFinishedFor
()
{
if
(
this
.
requestFinishedFor
===
this
.
linkRequested
)
{
this
.
isDisabled
=
false
;
}
},
},
},
},
methods
:
{
methods
:
{
onClickAction
()
{
onClickAction
()
{
$
(
this
.
$el
).
tooltip
(
'
hide
'
);
$
(
this
.
$el
).
tooltip
(
'
hide
'
);
eventHub
.
$emit
(
'
graphAction
'
,
this
.
link
);
eventHub
.
$emit
(
'
graphAction
'
,
this
.
link
);
this
.
linkRequested
=
this
.
link
;
this
.
isDisabled
=
true
;
},
},
},
},
};
};
...
@@ -62,7 +74,8 @@ export default {
...
@@ -62,7 +74,8 @@ export default {
@
click=
"onClickAction"
@
click=
"onClickAction"
v-tooltip
v-tooltip
:title=
"tooltipText"
:title=
"tooltipText"
class=
"js-ci-action btn btn-blank btn-transparent ci-action-icon-container ci-action-icon-wrapper"
class=
"js-ci-action btn btn-blank
btn-transparent ci-action-icon-container ci-action-icon-wrapper"
:class=
"cssClass"
:class=
"cssClass"
data-container=
"body"
data-container=
"body"
:disabled=
"isDisabled"
:disabled=
"isDisabled"
...
...
app/assets/javascripts/pipelines/components/graph/dropdown_job_component.vue
View file @
a527c9b9
<
script
>
<
script
>
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
JobNameComponent
from
'
./job_name_component.vue
'
;
import
JobNameComponent
from
'
./job_name_component.vue
'
;
import
JobComponent
from
'
./job_component.vue
'
;
import
JobComponent
from
'
./job_component.vue
'
;
import
tooltip
from
'
../../../vue_shared/directives/tooltip
'
;
import
tooltip
from
'
../../../vue_shared/directives/tooltip
'
;
/**
/**
* Renders the dropdown for the pipeline graph.
* Renders the dropdown for the pipeline graph.
*
*
* The following object should be provided as `job`:
* The following object should be provided as `job`:
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
* }
* }
* }
* }
*/
*/
export
default
{
export
default
{
directives
:
{
directives
:
{
tooltip
,
tooltip
,
},
},
...
@@ -42,6 +42,11 @@
...
@@ -42,6 +42,11 @@
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
requestFinishedFor
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
},
computed
:
{
computed
:
{
...
@@ -57,7 +62,8 @@
...
@@ -57,7 +62,8 @@
methods
:
{
methods
:
{
/**
/**
* When the user right clicks or cmd/ctrl + click in the job name or the action icon
* When the user right clicks or cmd/ctrl + click in the job name or the action icon
* the dropdown should not be closed so we stop propagation of the click event inside the dropdown.
* the dropdown should not be closed so we stop propagation
* of the click event inside the dropdown.
*
*
* Since this component is rendered multiple times per page we need to guarantee we only
* Since this component is rendered multiple times per page we need to guarantee we only
* target the click event of this component.
* target the click event of this component.
...
@@ -65,13 +71,13 @@
...
@@ -65,13 +71,13 @@
stopDropdownClickPropagation
()
{
stopDropdownClickPropagation
()
{
$
(
$
(
'
.js-grouped-pipeline-dropdown button, .js-grouped-pipeline-dropdown a.mini-pipeline-graph-dropdown-item
'
,
'
.js-grouped-pipeline-dropdown button, .js-grouped-pipeline-dropdown a.mini-pipeline-graph-dropdown-item
'
,
this
.
$el
,
this
.
$el
).
on
(
'
click
'
,
(
e
)
=>
{
).
on
(
'
click
'
,
e
=>
{
e
.
stopPropagation
();
e
.
stopPropagation
();
});
});
},
},
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"ci-job-dropdown-container"
>
<div
class=
"ci-job-dropdown-container"
>
...
@@ -102,6 +108,7 @@
...
@@ -102,6 +108,7 @@
<job-component
<job-component
:job=
"item"
:job=
"item"
css-class-job-name=
"mini-pipeline-graph-dropdown-item"
css-class-job-name=
"mini-pipeline-graph-dropdown-item"
:request-finished-for=
"requestFinishedFor"
/>
/>
</li>
</li>
</ul>
</ul>
...
...
app/assets/javascripts/pipelines/components/graph/graph_component.vue
View file @
a527c9b9
...
@@ -7,7 +7,6 @@ export default {
...
@@ -7,7 +7,6 @@ export default {
StageColumnComponent
,
StageColumnComponent
,
LoadingIcon
,
LoadingIcon
,
},
},
props
:
{
props
:
{
isLoading
:
{
isLoading
:
{
type
:
Boolean
,
type
:
Boolean
,
...
@@ -17,10 +16,10 @@ export default {
...
@@ -17,10 +16,10 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
actionDisabled
:
{
requestFinishedFor
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
null
,
default
:
''
,
},
},
},
},
...
@@ -75,7 +74,7 @@ export default {
...
@@ -75,7 +74,7 @@ export default {
:key=
"stage.name"
:key=
"stage.name"
:stage-connector-class=
"stageConnectorClass(index, stage)"
:stage-connector-class=
"stageConnectorClass(index, stage)"
:is-first-column=
"isFirstColumn(index)"
:is-first-column=
"isFirstColumn(index)"
:
action-disabled=
"actionDisabled
"
:
request-finished-for=
"requestFinishedFor
"
/>
/>
</ul>
</ul>
</div>
</div>
...
...
app/assets/javascripts/pipelines/components/graph/job_component.vue
View file @
a527c9b9
...
@@ -33,7 +33,6 @@ export default {
...
@@ -33,7 +33,6 @@ export default {
ActionComponent
,
ActionComponent
,
JobNameComponent
,
JobNameComponent
,
},
},
directives
:
{
directives
:
{
tooltip
,
tooltip
,
},
},
...
@@ -42,20 +41,17 @@ export default {
...
@@ -42,20 +41,17 @@ export default {
type
:
Object
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
cssClassJobName
:
{
cssClassJobName
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
},
},
requestFinishedFor
:
{
actionDisabled
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
null
,
default
:
''
,
},
},
},
},
computed
:
{
computed
:
{
status
()
{
status
()
{
return
this
.
job
&&
this
.
job
.
status
?
this
.
job
.
status
:
{};
return
this
.
job
&&
this
.
job
.
status
?
this
.
job
.
status
:
{};
...
@@ -130,7 +126,7 @@ export default {
...
@@ -130,7 +126,7 @@ export default {
:tooltip-text=
"status.action.title"
:tooltip-text=
"status.action.title"
:link=
"status.action.path"
:link=
"status.action.path"
:action-icon=
"status.action.icon"
:action-icon=
"status.action.icon"
:
button-disabled=
"actionDisabled
"
:
request-finished-for=
"requestFinishedFor
"
/>
/>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/pipelines/components/graph/stage_column_component.vue
View file @
a527c9b9
...
@@ -29,10 +29,11 @@ export default {
...
@@ -29,10 +29,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
''
,
default
:
''
,
},
},
actionDisabled
:
{
requestFinishedFor
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
default
:
null
,
default
:
''
,
},
},
},
},
...
@@ -74,12 +75,12 @@ export default {
...
@@ -74,12 +75,12 @@ export default {
v-if=
"job.size === 1"
v-if=
"job.size === 1"
:job=
"job"
:job=
"job"
css-class-job-name=
"build-content"
css-class-job-name=
"build-content"
:action-disabled=
"actionDisabled"
/>
/>
<dropdown-job-component
<dropdown-job-component
v-if=
"job.size > 1"
v-if=
"job.size > 1"
:job=
"job"
:job=
"job"
:request-finished-for=
"requestFinishedFor"
/>
/>
</li>
</li>
...
...
app/assets/javascripts/pipelines/pipeline_details_bundle.js
View file @
a527c9b9
...
@@ -25,7 +25,7 @@ export default () => {
...
@@ -25,7 +25,7 @@ export default () => {
data
()
{
data
()
{
return
{
return
{
mediator
,
mediator
,
actionDisabled
:
null
,
requestFinishedFor
:
null
,
};
};
},
},
created
()
{
created
()
{
...
@@ -36,15 +36,17 @@ export default () => {
...
@@ -36,15 +36,17 @@ export default () => {
},
},
methods
:
{
methods
:
{
postAction
(
action
)
{
postAction
(
action
)
{
this
.
actionDisabled
=
action
;
// Click was made, reset this variable
this
.
requestFinishedFor
=
null
;
this
.
mediator
.
service
.
postAction
(
action
)
this
.
mediator
.
service
.
postAction
(
action
)
.
then
(()
=>
{
.
then
(()
=>
{
this
.
mediator
.
refreshPipeline
();
this
.
mediator
.
refreshPipeline
();
this
.
actionDisabled
=
null
;
this
.
requestFinishedFor
=
action
;
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
this
.
actionDisabled
=
null
;
this
.
requestFinishedFor
=
action
;
Flash
(
__
(
'
An error occurred while making the request.
'
));
Flash
(
__
(
'
An error occurred while making the request.
'
));
});
});
},
},
...
@@ -54,7 +56,7 @@ export default () => {
...
@@ -54,7 +56,7 @@ export default () => {
props
:
{
props
:
{
isLoading
:
this
.
mediator
.
state
.
isLoading
,
isLoading
:
this
.
mediator
.
state
.
isLoading
,
pipeline
:
this
.
mediator
.
store
.
state
.
pipeline
,
pipeline
:
this
.
mediator
.
store
.
state
.
pipeline
,
actionDisabled
:
this
.
actionDisabled
,
requestFinishedFor
:
this
.
requestFinishedFor
,
},
},
});
});
},
},
...
@@ -79,7 +81,8 @@ export default () => {
...
@@ -79,7 +81,8 @@ export default () => {
},
},
methods
:
{
methods
:
{
postAction
(
action
)
{
postAction
(
action
)
{
this
.
mediator
.
service
.
postAction
(
action
.
path
)
this
.
mediator
.
service
.
postAction
(
action
.
path
)
.
then
(()
=>
this
.
mediator
.
refreshPipeline
())
.
then
(()
=>
this
.
mediator
.
refreshPipeline
())
.
catch
(()
=>
Flash
(
__
(
'
An error occurred while making the request.
'
)));
.
catch
(()
=>
Flash
(
__
(
'
An error occurred while making the request.
'
)));
},
},
...
...
changelogs/unreleased/33697-remove-ujs-action-big-graph.yml
0 → 100644
View file @
a527c9b9
---
title
:
Prevent pipeline actions in dropdown to redirct to a new page
merge_request
:
author
:
type
:
fixed
spec/javascripts/pipelines/graph/action_component_spec.js
View file @
a527c9b9
...
@@ -6,7 +6,7 @@ import mountComponent from '../../helpers/vue_mount_component_helper';
...
@@ -6,7 +6,7 @@ import mountComponent from '../../helpers/vue_mount_component_helper';
describe
(
'
pipeline graph action component
'
,
()
=>
{
describe
(
'
pipeline graph action component
'
,
()
=>
{
let
component
;
let
component
;
beforeEach
(
(
done
)
=>
{
beforeEach
(
done
=>
{
const
ActionComponent
=
Vue
.
extend
(
actionComponent
);
const
ActionComponent
=
Vue
.
extend
(
actionComponent
);
component
=
mountComponent
(
ActionComponent
,
{
component
=
mountComponent
(
ActionComponent
,
{
tooltipText
:
'
bar
'
,
tooltipText
:
'
bar
'
,
...
@@ -22,7 +22,7 @@ describe('pipeline graph action component', () => {
...
@@ -22,7 +22,7 @@ describe('pipeline graph action component', () => {
});
});
it
(
'
should emit an event with the provided link
'
,
()
=>
{
it
(
'
should emit an event with the provided link
'
,
()
=>
{
eventHub
.
$on
(
'
graphAction
'
,
(
link
)
=>
{
eventHub
.
$on
(
'
graphAction
'
,
link
=>
{
expect
(
link
).
toEqual
(
'
foo
'
);
expect
(
link
).
toEqual
(
'
foo
'
);
});
});
});
});
...
@@ -31,7 +31,7 @@ describe('pipeline graph action component', () => {
...
@@ -31,7 +31,7 @@ describe('pipeline graph action component', () => {
expect
(
component
.
$el
.
getAttribute
(
'
data-original-title
'
)).
toEqual
(
'
bar
'
);
expect
(
component
.
$el
.
getAttribute
(
'
data-original-title
'
)).
toEqual
(
'
bar
'
);
});
});
it
(
'
should update bootstrap tooltip when title changes
'
,
(
done
)
=>
{
it
(
'
should update bootstrap tooltip when title changes
'
,
done
=>
{
component
.
tooltipText
=
'
changed
'
;
component
.
tooltipText
=
'
changed
'
;
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -44,4 +44,45 @@ describe('pipeline graph action component', () => {
...
@@ -44,4 +44,45 @@ describe('pipeline graph action component', () => {
expect
(
component
.
$el
.
querySelector
(
'
.ci-action-icon-wrapper
'
)).
toBeDefined
();
expect
(
component
.
$el
.
querySelector
(
'
.ci-action-icon-wrapper
'
)).
toBeDefined
();
expect
(
component
.
$el
.
querySelector
(
'
svg
'
)).
toBeDefined
();
expect
(
component
.
$el
.
querySelector
(
'
svg
'
)).
toBeDefined
();
});
});
it
(
'
disables the button when clicked
'
,
done
=>
{
component
.
$el
.
click
();
component
.
$nextTick
(()
=>
{
expect
(
component
.
$el
.
getAttribute
(
'
disabled
'
)).
toEqual
(
'
disabled
'
);
done
();
});
});
it
(
'
re-enabled the button when `requestFinishedFor` matches `linkRequested`
'
,
done
=>
{
component
.
$el
.
click
();
component
.
$nextTick
()
.
then
(()
=>
{
expect
(
component
.
$el
.
getAttribute
(
'
disabled
'
)).
toEqual
(
'
disabled
'
);
component
.
requestFinishedFor
=
'
foo
'
;
})
.
then
(()
=>
{
expect
(
component
.
$el
.
getAttribute
(
'
disabled
'
)).
toBeNull
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
does not re-enable the button when `requestFinishedFor` does not matches `linkRequested`
'
,
done
=>
{
component
.
$el
.
click
();
component
.
$nextTick
()
.
then
(()
=>
{
expect
(
component
.
$el
.
getAttribute
(
'
disabled
'
)).
toEqual
(
'
disabled
'
);
component
.
requestFinishedFor
=
'
bar
'
;
})
.
then
(()
=>
{
expect
(
component
.
$el
.
getAttribute
(
'
disabled
'
)).
toEqual
(
'
disabled
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
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