Commit 7465f62e authored by Phil Hughes's avatar Phil Hughes

fixed action name changes after rebase

fixed content not updating in editor when changing template
parent 843467b8
......@@ -23,16 +23,20 @@ export default {
this.setInitialType();
},
methods: {
...mapActions('fileTemplates', ['setTemplateType', 'fetchTemplate']),
...mapActions('fileTemplates', [
'setSelectedTemplateType',
'fetchTemplate',
'undoFileTemplate',
]),
setInitialType() {
const type = this.templateTypes.find(t => t.name === this.activeFile.name);
if (type) {
this.setTemplateType(type);
this.setSelectedTemplateType(type);
}
},
selectTemplateType(type) {
this.setTemplateType(type);
this.setSelectedTemplateType(type);
},
selecteTemplate(template) {
this.fetchTemplate(template);
......@@ -69,6 +73,7 @@ export default {
<button
type="button"
class="btn btn-default"
@click="undoFileTemplate"
>
{{ __('Undo') }}
</button>
......
......@@ -77,11 +77,12 @@ export default {
<div class="dropdown">
<dropdown-button
:toggle-text="label"
data-display="static"
/>
<div class="dropdown-menu">
<div
v-if="title"
class="dropdown-title"
class="dropdown-title ml-0 mr-0"
>
{{ title }}
</div>
......@@ -95,6 +96,10 @@ export default {
type="search"
class="dropdown-input-field"
/>
<i
aria-hidden="true"
class="fa fa-search dropdown-input-search"
></i>
</div>
<div class="dropdown-content">
<loading-icon
......
import Api from '~/api';
import { __ } from '~/locale';
import * as types from './mutation_types';
import eventHub from '../../../eventhub';
export const requestTemplateTypes = ({ commit }) => commit(types.REQUEST_TEMPLATE_TYPES);
export const receiveTemplateTypesError = ({ commit, dispatch }) => {
......@@ -69,6 +70,7 @@ export const setFileTemplate = ({ dispatch, commit, rootGetters }, template) =>
{ root: true },
);
commit(types.SET_UPDATE_SUCCESS, true);
eventHub.$emit(`editor.update.model.new.content.${rootGetters.activeFile.key}`, template.content);
};
export const undoFileTemplate = ({ dispatch, commit, rootGetters }) => {
......@@ -76,6 +78,8 @@ export const undoFileTemplate = ({ dispatch, commit, rootGetters }) => {
dispatch('changeFileContent', { path: file.path, content: file.raw }, { root: true });
commit(types.SET_UPDATE_SUCCESS, false);
eventHub.$emit(`editor.update.model.new.content.${file.key}`, file.raw);
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
......
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