Commit c8b5f9de authored by Illya Klymov's avatar Illya Klymov

Address reviewer comments

- improve readability of import_table component
parent 39f12a7f
...@@ -16,19 +16,6 @@ import importGroupMutation from '../graphql/mutations/import_group.mutation.grap ...@@ -16,19 +16,6 @@ import importGroupMutation from '../graphql/mutations/import_group.mutation.grap
import ImportTableRow from './import_table_row.vue'; import ImportTableRow from './import_table_row.vue';
import PaginationLinks from '~/vue_shared/components/pagination_links.vue'; import PaginationLinks from '~/vue_shared/components/pagination_links.vue';
const mapApolloMutations = (mutations) =>
Object.fromEntries(
Object.entries(mutations).map(([key, mutation]) => [
key,
function mutate(config) {
return this.$apollo.mutate({
mutation,
...config,
});
},
]),
);
export default { export default {
components: { components: {
GlEmptyState, GlEmptyState,
...@@ -106,11 +93,26 @@ export default { ...@@ -106,11 +93,26 @@ export default {
this.page = page; this.page = page;
}, },
...mapApolloMutations({ updateTargetNamespace(sourceGroupId, targetNamespace) {
setTargetNamespace: setTargetNamespaceMutation, this.$apollo.mutate({
setNewName: setNewNameMutation, mutation: setTargetNamespaceMutation,
importGroup: importGroupMutation, variables: { sourceGroupId, targetNamespace },
}), });
},
updateNewName(sourceGroupId, newName) {
this.$apollo.mutate({
mutation: setNewNameMutation,
variables: { sourceGroupId, newName },
});
},
importGroup(sourceGroupId) {
this.$apollo.mutate({
mutation: importGroupMutation,
variables: { sourceGroupId },
});
},
}, },
}; };
</script> </script>
...@@ -164,17 +166,9 @@ export default { ...@@ -164,17 +166,9 @@ export default {
:key="group.id" :key="group.id"
:group="group" :group="group"
:available-namespaces="availableNamespaces" :available-namespaces="availableNamespaces"
@update-target-namespace=" @update-target-namespace="updateTargetNamespace(group.id, $event)"
setTargetNamespace({ @update-new-name="updateNewName(group.id, $event)"
variables: { sourceGroupId: group.id, targetNamespace: $event }, @import-group="importGroup(group.id)"
})
"
@update-new-name="
setNewName({
variables: { sourceGroupId: group.id, newName: $event },
})
"
@import-group="importGroup({ variables: { sourceGroupId: group.id } })"
/> />
</template> </template>
</tbody> </tbody>
......
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