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
83f63653
Commit
83f63653
authored
Jun 04, 2021
by
Chad Woolley
Committed by
Tom Quirk
Jun 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converting jquery dropdown for ci_template
- Use GlDropdown
parent
86e8013f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
118 deletions
+79
-118
ee/app/assets/javascripts/pages/admin/application_settings/ci_cd/ci_template.js
...pts/pages/admin/application_settings/ci_cd/ci_template.js
+0
-58
ee/app/assets/javascripts/pages/admin/application_settings/ci_cd/ci_template_dropdown.vue
...admin/application_settings/ci_cd/ci_template_dropdown.vue
+43
-0
ee/app/assets/javascripts/pages/admin/application_settings/ci_cd/index.js
...vascripts/pages/admin/application_settings/ci_cd/index.js
+16
-2
ee/app/views/admin/application_settings/_required_instance_ci_setting.html.haml
...lication_settings/_required_instance_ci_setting.html.haml
+2
-0
ee/spec/frontend/pages/admin/application_settings/ci_cd/ci_template_dropdown_spec.js
...n/application_settings/ci_cd/ci_template_dropdown_spec.js
+18
-0
ee/spec/frontend/pages/admin/application_settings/ci_cd/ci_template_spec.js
...ages/admin/application_settings/ci_cd/ci_template_spec.js
+0
-58
No files found.
ee/app/assets/javascripts/pages/admin/application_settings/ci_cd/ci_template.js
deleted
100644 → 0
View file @
86e8013f
import
$
from
'
jquery
'
;
import
initDeprecatedJQueryDropdown
from
'
~/deprecated_jquery_dropdown
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
class
CiTemplate
{
constructor
()
{
this
.
$input
=
$
(
'
#required_instance_ci_template_name
'
);
this
.
$dropdown
=
$
(
'
.js-ci-template-dropdown
'
);
this
.
$dropdownToggle
=
this
.
$dropdown
.
find
(
'
.dropdown-toggle-text
'
);
this
.
initDropdown
();
}
initDropdown
()
{
initDeprecatedJQueryDropdown
(
this
.
$dropdown
,
{
data
:
this
.
formatDropdownList
(),
selectable
:
true
,
filterable
:
true
,
allowClear
:
true
,
toggleLabel
:
(
item
)
=>
item
.
name
,
search
:
{
fields
:
[
'
name
'
],
},
clicked
:
(
clickEvent
)
=>
this
.
updateInputValue
(
clickEvent
),
text
:
(
item
)
=>
item
.
name
,
});
this
.
setDropdownToggle
();
}
formatDropdownList
()
{
return
{
Reset
:
[
{
name
:
__
(
'
No required pipeline
'
),
id
:
null
,
},
{
type
:
'
divider
'
,
},
],
...
this
.
$dropdown
.
data
(
'
data
'
),
};
}
setDropdownToggle
()
{
const
initialValue
=
this
.
$input
.
val
();
if
(
initialValue
)
{
this
.
$dropdownToggle
.
text
(
initialValue
);
}
}
updateInputValue
({
selectedObj
,
e
})
{
e
.
preventDefault
();
this
.
$input
.
val
(
selectedObj
.
id
);
}
}
ee/app/assets/javascripts/pages/admin/application_settings/ci_cd/ci_template_dropdown.vue
0 → 100644
View file @
83f63653
<
script
>
import
{
GlDropdown
,
GlSearchBoxByType
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
s__
}
from
'
~/locale
'
;
export
default
{
name
:
'
CiTemplateDropdown
'
,
components
:
{
GlDropdown
,
GlSearchBoxByType
,
GlDropdownItem
},
props
:
{
gitlabCiYmls
:
{
type
:
Object
,
required
:
true
,
},
},
data
()
{
return
{
selectedGitlabCiYml
:
{
id
:
s__
(
'
Android
'
),
name
:
s__
(
'
Android
'
),
},
searchTerm
:
''
,
};
},
};
</
script
>
<
template
>
<gl-dropdown
:text=
"selectedGitlabCiYml.name"
:header-text=
"s__('SelectTemplate|Select template')"
>
<template
#header
>
<gl-search-box-by-type
v-model.trim=
"searchTerm"
/>
</
template
>
<gl-dropdown-item
v-for=
"gitlabCiYml in gitlabCiYmls.General"
:key=
"gitlabCiYml.id"
is-check-item
:is-checked=
"selectedGitlabCiYml.id === gitlabCiYml.id"
>
{{ gitlabCiYml.name }}
</gl-dropdown-item>
</gl-dropdown>
</template>
ee/app/assets/javascripts/pages/admin/application_settings/ci_cd/index.js
View file @
83f63653
import
CiTemplate
from
'
./ci_template
'
;
import
Vue
from
'
vue
'
;
import
CiTemplateDropdown
from
'
./ci_template_dropdown.vue
'
;
const
el
=
document
.
querySelector
(
'
.js-ci-template-dropdown
'
);
const
{
gitlabCiYmls
}
=
el
.
dataset
;
// eslint-disable-next-line no-new
new
CiTemplate
();
new
Vue
({
el
,
render
(
createElement
)
{
return
createElement
(
CiTemplateDropdown
,
{
props
:
{
gitlabCiYmls
:
JSON
.
parse
(
gitlabCiYmls
),
},
});
},
});
ee/app/views/admin/application_settings/_required_instance_ci_setting.html.haml
View file @
83f63653
...
...
@@ -20,6 +20,8 @@
.form-group
=
f
.
label
:required_instance_ci_template
,
s_
(
'AdminSettings|Select a CI/CD template'
),
class:
'text-muted'
=
dropdown_tag
(
s_
(
'AdminSettings|No required pipeline'
),
options:
{
toggle_class:
'js-ci-template-dropdown dropdown-select'
,
title:
s_
(
'AdminSettings|Select a CI/CD template'
),
filter:
true
,
placeholder:
_
(
"Filter"
),
data:
{
data:
gitlab_ci_ymls
(
nil
)
}
}
)
-# -# = dropdown_tag(s_('AdminSettings|No required pipeline'), options: { toggle_class: 'js-ci-template-dropdown dropdown-select', title: s_('AdminSettings|Select a template'), filter: true, placeholder: _("Filter"), data: { data: gitlab_ci_ymls(nil) } } )
-# .js-ci-template-dropdown{ data: { gitlab_ci_ymls: gitlab_ci_ymls(nil).to_json } }
=
f
.
text_field
:required_instance_ci_template
,
value:
@application_setting
.
required_instance_ci_template
,
id:
'required_instance_ci_template_name'
,
class:
'hidden'
=
f
.
submit
_
(
'Save changes'
),
class:
"gl-button btn btn-confirm"
ee/spec/frontend/pages/admin/application_settings/ci_cd/ci_template_dropdown_spec.js
0 → 100644
View file @
83f63653
import
{
GlDropdown
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
CiTemplateDropdown
from
'
ee/pages/admin/application_settings/ci_cd/ci_template_dropdown.vue
'
;
describe
(
'
CiTemplateDropdown
'
,
()
=>
{
let
wrapper
;
const
createComponent
=
()
=>
{
wrapper
=
shallowMount
(
CiTemplateDropdown
);
};
it
(
'
has a GlDropdown
'
,
()
=>
{
createComponent
();
const
dropdown
=
wrapper
.
findComponent
(
GlDropdown
);
expect
(
dropdown
.
exists
()).
toBe
(
true
);
});
});
ee/spec/frontend/pages/admin/application_settings/ci_cd/ci_template_spec.js
deleted
100644 → 0
View file @
86e8013f
import
CiTemplate
from
'
ee/pages/admin/application_settings/ci_cd/ci_template
'
;
import
{
setHTMLFixture
}
from
'
helpers/fixtures
'
;
const
DROPDOWN_DATA
=
{
Instance
:
[{
name
:
'
test
'
,
id
:
'
test
'
}],
General
:
[{
name
:
'
Android
'
,
id
:
'
Android
'
}],
};
const
INITIAL_VALUE
=
'
Android
'
;
describe
(
'
CI Template Dropdown (ee/pages/admin/application_settings/ci_cd/ci_template.js
'
,
()
=>
{
let
CiTemplateInstance
;
beforeEach
(()
=>
{
setHTMLFixture
(
`
<div>
<button class="js-ci-template-dropdown" data-data=
${
JSON
.
stringify
(
DROPDOWN_DATA
)}
>
<span class="dropdown-toggle-text"></span>
</button>
<input id="required_instance_ci_template_name" value="
${
INITIAL_VALUE
}
" />
</div>
`
);
CiTemplateInstance
=
new
CiTemplate
();
});
describe
(
'
Init Dropdown
'
,
()
=>
{
it
(
'
Instantiates dropdown objects
'
,
()
=>
{
expect
(
CiTemplateInstance
.
$input
).
toHaveLength
(
1
);
expect
(
CiTemplateInstance
.
$dropdown
).
toHaveLength
(
1
);
expect
(
CiTemplateInstance
.
$dropdownToggle
).
toHaveLength
(
1
);
});
it
(
'
Sets the dropdown text value
'
,
()
=>
{
expect
(
CiTemplateInstance
.
$dropdown
.
text
().
trim
()).
toBe
(
INITIAL_VALUE
);
});
});
describe
(
'
Format dropdown list
'
,
()
=>
{
it
(
'
Adds a reset option and divider
'
,
()
=>
{
const
expected
=
{
Reset
:
[{
name
:
'
No required pipeline
'
,
id
:
null
},
{
type
:
'
divider
'
}],
...
DROPDOWN_DATA
,
};
const
actual
=
CiTemplateInstance
.
formatDropdownList
();
expect
(
JSON
.
stringify
(
actual
)).
toBe
(
JSON
.
stringify
(
expected
));
});
});
describe
(
'
Update input value
'
,
()
=>
{
it
(
'
changes the value of the input
'
,
()
=>
{
const
selectedObj
=
{
name
:
'
update
'
,
id
:
'
update
'
};
const
e
=
{
preventDefault
:
()
=>
{}
};
CiTemplateInstance
.
updateInputValue
({
selectedObj
,
e
});
expect
(
CiTemplateInstance
.
$input
.
val
()).
toBe
(
'
update
'
);
});
});
});
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