Commit cd6b9d8b authored by Payton Burdette's avatar Payton Burdette Committed by Phil Hughes

Destructure selector config name

Instead of calling selector config
name directly, destructure the key
for reuse and readablility.
parent af4b0838
...@@ -118,8 +118,6 @@ export default class FileTemplateMediator { ...@@ -118,8 +118,6 @@ export default class FileTemplateMediator {
} }
}); });
this.setFilename(item.name);
if (this.editor.getValue() !== '') { if (this.editor.getValue() !== '') {
this.setTypeSelectorToggleText(item.name); this.setTypeSelectorToggleText(item.name);
} }
...@@ -133,14 +131,16 @@ export default class FileTemplateMediator { ...@@ -133,14 +131,16 @@ export default class FileTemplateMediator {
selectTemplateFile(selector, query, data) { selectTemplateFile(selector, query, data) {
const self = this; const self = this;
const { name } = selector.config;
selector.renderLoading(); selector.renderLoading();
this.fetchFileTemplate(selector.config.type, query, data) this.fetchFileTemplate(selector.config.type, query, data)
.then(file => { .then(file => {
this.setEditorContent(file); this.setEditorContent(file);
this.setFilename(name);
selector.renderLoaded(); selector.renderLoaded();
this.typeSelector.setToggleText(selector.config.name); this.typeSelector.setToggleText(name);
toast(__(`${query} template applied`), { toast(__(`${query} template applied`), {
action: { action: {
text: __('Undo'), text: __('Undo'),
......
---
title: Fix template selector filename bug
merge_request: 19376
author:
type: fixed
...@@ -62,6 +62,13 @@ describe 'Editing file blob', :js do ...@@ -62,6 +62,13 @@ describe 'Editing file blob', :js do
expect(page).to have_content 'NextFeature' expect(page).to have_content 'NextFeature'
end end
it 'editing a template file in a sub directory does not change path' do
project.repository.create_file(user, 'ci/.gitlab-ci.yml', 'test', message: 'testing', branch_name: branch)
visit project_edit_blob_path(project, tree_join(branch, 'ci/.gitlab-ci.yml'))
expect(find_by_id('file_path').value).to eq('ci/.gitlab-ci.yml')
end
context 'from blob file path' do context 'from blob file path' do
before do before do
visit project_blob_path(project, tree_join(branch, file_path)) visit project_blob_path(project, tree_join(branch, file_path))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment