Skip to content
Snippets Groups Projects
Commit 4fc2f484 authored by Jacques Erasmus's avatar Jacques Erasmus :speech_balloon:
Browse files

Implement delete mutation

Implemented the delete mutation for delete file

Changelog: added
parent d4a8810e
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,11 @@ export default {
return sprintf(__('Replace %{name}'), { name: this.name });
},
},
methods: {
deleteFile() {
this.$emit('delete');
},
},
};
</script>
......@@ -63,7 +68,7 @@ export default {
<gl-button v-gl-modal="replaceModalId">
{{ $options.i18n.replace }}
</gl-button>
<gl-button>{{ $options.i18n.delete }}</gl-button>
<gl-button @click="deleteFile">{{ $options.i18n.delete }}</gl-button>
</gl-button-group>
<upload-blob-modal
:modal-id="replaceModalId"
......
......@@ -7,6 +7,7 @@ import { SIMPLE_BLOB_VIEWER, RICH_BLOB_VIEWER } from '~/blob/components/constant
import createFlash from '~/flash';
import { isLoggedIn } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import deleteBlobMutation from '../mutations/blob_delete.mutation.graphql';
import blobInfoQuery from '../queries/blob_info.query.graphql';
import BlobButtonGroup from './blob_button_group.vue';
import BlobEdit from './blob_edit.vue';
......@@ -116,6 +117,23 @@ export default {
switchViewer(newViewer) {
this.activeViewerType = newViewer || SIMPLE_BLOB_VIEWER;
},
deleteFile() {
const project = this.projectPath;
const file = this.path;
const branch = 'master';
const message = `Deleted ${file}`;
this.$apollo
.mutate({
mutation: deleteBlobMutation,
variables: { project, file, branch, message },
})
.then(() => {
// TODO - redirect to repository list
})
.catch(() => {
// TODO - handle error
});
},
},
};
</script>
......@@ -139,6 +157,7 @@ export default {
:name="blobInfo.name"
:replace-path="blobInfo.replacePath"
:can-push-code="blobInfo.canModifyBlob"
@delete="deleteFile"
/>
</template>
</blob-header>
......
mutation DeleteBlob($project: ID!, $branch: String!, $message: String!, $file: String!) {
commitCreate(input: {projectPath: $project, branch: $branch, message: $message, actions: [{action: DELETE, filePath: $file}]}) {
commit {
title
authorName
message
}
errors
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment