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
Léo-Paul Géneau
gitlab-ce
Commits
a15c4d49
Commit
a15c4d49
authored
Dec 15, 2017
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use icons instead of string labels for toggles
parent
31fa9313
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
18 deletions
+31
-18
app/assets/javascripts/vue_shared/components/toggle_button.vue
...ssets/javascripts/vue_shared/components/toggle_button.vue
+23
-13
app/views/projects/clusters/_cluster.html.haml
app/views/projects/clusters/_cluster.html.haml
+4
-3
app/views/projects/clusters/_enabled.html.haml
app/views/projects/clusters/_enabled.html.haml
+4
-2
No files found.
app/assets/javascripts/vue_shared/components/toggle_button.vue
View file @
a15c4d49
<
script
>
<
script
>
import
{
s__
}
from
'
../../locale
'
;
import
icon
from
'
./icon.vue
'
;
import
loadingIcon
from
'
./loading_icon.vue
'
;
import
loadingIcon
from
'
./loading_icon.vue
'
;
const
ICON_ON
=
'
status_success_borderless
'
;
const
ICON_OFF
=
'
status_failed_borderless
'
;
const
LABEL_ON
=
s__
(
'
ToggleButton|Toggle Status: ON
'
);
const
LABEL_OFF
=
s__
(
'
ToggleButton|Toggle Status: OFF
'
);
export
default
{
export
default
{
props
:
{
props
:
{
name
:
{
name
:
{
...
@@ -22,19 +29,10 @@
...
@@ -22,19 +29,10 @@
required
:
false
,
required
:
false
,
default
:
false
,
default
:
false
,
},
},
enabledText
:
{
type
:
String
,
required
:
false
,
default
:
'
Enabled
'
,
},
disabledText
:
{
type
:
String
,
required
:
false
,
default
:
'
Disabled
'
,
},
},
},
components
:
{
components
:
{
icon
,
loadingIcon
,
loadingIcon
,
},
},
...
@@ -43,6 +41,15 @@
...
@@ -43,6 +41,15 @@
event
:
'
change
'
,
event
:
'
change
'
,
},
},
computed
:
{
toggleIcon
()
{
return
this
.
value
?
ICON_ON
:
ICON_OFF
;
},
ariaLabel
()
{
return
this
.
value
?
LABEL_ON
:
LABEL_OFF
;
},
},
methods
:
{
methods
:
{
toggleFeature
()
{
toggleFeature
()
{
if
(
!
this
.
disabledInput
)
this
.
$emit
(
'
change
'
,
!
this
.
value
);
if
(
!
this
.
disabledInput
)
this
.
$emit
(
'
change
'
,
!
this
.
value
);
...
@@ -60,10 +67,8 @@
...
@@ -60,10 +67,8 @@
/>
/>
<button
<button
type=
"button"
type=
"button"
aria-label=
"Toggle"
class=
"project-feature-toggle"
class=
"project-feature-toggle"
:data-enabled-text=
"enabledText"
:aria-label=
"ariaLabel"
:data-disabled-text=
"disabledText"
:class=
"
{
:class=
"
{
'is-checked': value,
'is-checked': value,
'is-disabled': disabledInput,
'is-disabled': disabledInput,
...
@@ -72,6 +77,11 @@
...
@@ -72,6 +77,11 @@
@click="toggleFeature"
@click="toggleFeature"
>
>
<loadingIcon
class=
"loading-icon"
/>
<loadingIcon
class=
"loading-icon"
/>
<span
class=
"toggle-icon"
>
<icon
css-classes=
"toggle-icon-svg"
:name=
"toggleIcon"
/>
</span>
</button>
</button>
</label>
</label>
</
template
>
</
template
>
app/views/projects/clusters/_cluster.html.haml
View file @
a15c4d49
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
class:
"js-toggle-cluster-list project-feature-toggle #{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}"
,
class:
"js-toggle-cluster-list project-feature-toggle #{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}"
,
"aria-label"
:
s_
(
"ClusterIntegration|Toggle Cluster"
),
"aria-label"
:
s_
(
"ClusterIntegration|Toggle Cluster"
),
disabled:
!
cluster
.
can_toggle_cluster?
,
disabled:
!
cluster
.
can_toggle_cluster?
,
data:
{
"enabled-text"
:
s_
(
"ClusterIntegration|Active"
),
data:
{
endpoint:
namespace_project_cluster_path
(
@project
.
namespace
,
@project
,
cluster
,
format: :json
)
}
}
"disabled-text"
:
s_
(
"ClusterIntegration|Inactive"
),
endpoint:
namespace_project_cluster_path
(
@project
.
namespace
,
@project
,
cluster
,
format: :json
)
}
}
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
=
icon
(
"spinner spin"
,
class:
"loading-icon"
)
%span
.toggle-icon
=
sprite_icon
(
'status_success_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-checked'
)
=
sprite_icon
(
'status_failed_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-unchecked'
)
app/views/projects/clusters/_enabled.html.haml
View file @
a15c4d49
...
@@ -7,8 +7,10 @@
...
@@ -7,8 +7,10 @@
%button
{
type:
'button'
,
%button
{
type:
'button'
,
class:
"js-toggle-cluster project-feature-toggle #{'is-checked' unless !@cluster.enabled?} #{'is-disabled' unless can?(current_user, :update_cluster, @cluster)}"
,
class:
"js-toggle-cluster project-feature-toggle #{'is-checked' unless !@cluster.enabled?} #{'is-disabled' unless can?(current_user, :update_cluster, @cluster)}"
,
"aria-label"
:
s_
(
"ClusterIntegration|Toggle Cluster"
),
"aria-label"
:
s_
(
"ClusterIntegration|Toggle Cluster"
),
disabled:
!
can?
(
current_user
,
:update_cluster
,
@cluster
),
disabled:
!
can?
(
current_user
,
:update_cluster
,
@cluster
)
}
data:
{
"enabled-text"
:
s_
(
"ClusterIntegration|Active"
),
"disabled-text"
:
s_
(
"ClusterIntegration|Inactive"
),
}
}
%span
.toggle-icon
=
sprite_icon
(
'status_success_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-checked'
)
=
sprite_icon
(
'status_failed_borderless'
,
size:
16
,
css_class:
'toggle-icon-svg toggle-status-unchecked'
)
-
if
can?
(
current_user
,
:update_cluster
,
@cluster
)
-
if
can?
(
current_user
,
:update_cluster
,
@cluster
)
.form-group
.form-group
...
...
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