Commit d35eea3d authored by Fernando Arias's avatar Fernando Arias

Hit graphql mutation for corpus creation

parent 13ebe8bf
...@@ -74,7 +74,11 @@ export default { ...@@ -74,7 +74,11 @@ export default {
addCorpus() { addCorpus() {
this.$apollo.mutate({ this.$apollo.mutate({
mutation: addCorpusMutation, mutation: addCorpusMutation,
variables: { name: this.$options.i18n.newCorpus, projectPath: this.projectFullPath }, variables: {
name: this.$options.i18n.newCorpus,
projectPath: this.projectFullPath,
packageId: this.states.uploadState.uploadedPackageId,
},
}); });
}, },
resetCorpus() { resetCorpus() {
......
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
corpusName: s__('CorpusManagement|Corpus name'), corpusName: s__('CorpusManagement|Corpus name'),
uploadButtonText: __('Choose File...'), uploadButtonText: __('Choose File...'),
uploadMessage: s__( uploadMessage: s__(
'CorpusManagement|New corpus needs to be a upload in *.zip format. Maximum 10GB', 'CorpusManagement|New corpus needs to be a upload in *.zip format. Maximum 5GB',
), ),
}, },
data() { data() {
......
mutation addCorpus($projectPath: ID!, $name: String!) { mutation addCorpus($projectPath: ID!, $name: String!, $packageId: Int!) {
addCorpus(projectPath: $projectPath, name: $name) @client { addCorpus(projectPath: $projectPath, name: $name, packageId: $packageId) @client {
errors errors
} }
} }
mutation CorpusCreate($input: CorpusCreateInput!) {
corpusCreate(input: $input) {
errors
}
}
...@@ -5,6 +5,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -5,6 +5,7 @@ import axios from '~/lib/utils/axios_utils';
import getCorpusesQuery from '../queries/get_corpuses.query.graphql'; import getCorpusesQuery from '../queries/get_corpuses.query.graphql';
import updateProgress from '../mutations/update_progress.mutation.graphql'; import updateProgress from '../mutations/update_progress.mutation.graphql';
import uploadComplete from '../mutations/upload_complete.mutation.graphql'; import uploadComplete from '../mutations/upload_complete.mutation.graphql';
import corpusCreate from '../mutations/corpus_create.mutation.graphql';
export default { export default {
Query: { Query: {
...@@ -29,7 +30,7 @@ export default { ...@@ -29,7 +30,7 @@ export default {
}, },
}, },
Mutation: { Mutation: {
addCorpus: (_, { name, projectPath }, { cache }) => { addCorpus: (_, { name, projectPath, packageId }, { cache, client }) => {
const sourceData = cache.readQuery({ const sourceData = cache.readQuery({
query: getCorpusesQuery, query: getCorpusesQuery,
variables: { projectPath }, variables: { projectPath },
...@@ -56,6 +57,11 @@ export default { ...@@ -56,6 +57,11 @@ export default {
}); });
cache.writeQuery({ query: getCorpusesQuery, data, variables: { projectPath } }); cache.writeQuery({ query: getCorpusesQuery, data, variables: { projectPath } });
client.mutate({
mutation: corpusCreate,
variables: { fullPath: projectPath, packageId },
});
}, },
deleteCorpus: (_, { name, projectPath }, { cache }) => { deleteCorpus: (_, { name, projectPath }, { cache }) => {
const sourceData = cache.readQuery({ const sourceData = cache.readQuery({
...@@ -99,7 +105,7 @@ export default { ...@@ -99,7 +105,7 @@ export default {
uploadState.cancelSource = source; uploadState.cancelSource = source;
}); });
cache.writeQuery({ query: getCorpusesQuery, targetData, variables: { projectPath } }); cache.writeQuery({ query: getCorpusesQuery, data: targetData, variables: { projectPath } });
publishPackage( publishPackage(
{ projectPath, name, version: 0, fileName: name, files }, { projectPath, name, version: 0, fileName: name, files },
......
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