Commit 0fcf0f0e authored by Phil Hughes's avatar Phil Hughes

Merge branch '34443-fix-template-bug' into 'master'

Fix template selector filename bug

Closes #34443

See merge request gitlab-org/gitlab!19376
parents af4b0838 cd6b9d8b
......@@ -118,8 +118,6 @@ export default class FileTemplateMediator {
}
});
this.setFilename(item.name);
if (this.editor.getValue() !== '') {
this.setTypeSelectorToggleText(item.name);
}
......@@ -133,14 +131,16 @@ export default class FileTemplateMediator {
selectTemplateFile(selector, query, data) {
const self = this;
const { name } = selector.config;
selector.renderLoading();
this.fetchFileTemplate(selector.config.type, query, data)
.then(file => {
this.setEditorContent(file);
this.setFilename(name);
selector.renderLoaded();
this.typeSelector.setToggleText(selector.config.name);
this.typeSelector.setToggleText(name);
toast(__(`${query} template applied`), {
action: {
text: __('Undo'),
......
---
title: Fix template selector filename bug
merge_request: 19376
author:
type: fixed
......@@ -62,6 +62,13 @@ describe 'Editing file blob', :js do
expect(page).to have_content 'NextFeature'
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
before do
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