Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sidebar_service.js « services « sidebar « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 37c97225bfde7bd90e4fe429bd6f3f43e8e8843a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Vue from 'vue';
import VueResource from 'vue-resource';

Vue.use(VueResource);

export default class SidebarService {
  constructor(endpointMap) {
    if (!SidebarService.singleton) {
      this.endpoint = endpointMap.endpoint;
      this.toggleSubscriptionEndpoint = endpointMap.toggleSubscriptionEndpoint;
      this.moveIssueEndpoint = endpointMap.moveIssueEndpoint;
      this.projectsAutocompleteEndpoint = endpointMap.projectsAutocompleteEndpoint;

      SidebarService.singleton = this;
    }

    return SidebarService.singleton;
  }

  get() {
    return Vue.http.get(this.endpoint);
  }

  update(key, data) {
    return Vue.http.put(this.endpoint, {
      [key]: data,
    }, {
      emulateJSON: true,
    });
  }

  getProjectsAutocomplete(searchTerm) {
    return Vue.http.get(this.projectsAutocompleteEndpoint, {
      params: {
        search: searchTerm,
      },
    });
  }

  toggleSubscription() {
    return Vue.http.post(this.toggleSubscriptionEndpoint);
  }

  moveIssue(moveToProjectId) {
    return Vue.http.post(this.moveIssueEndpoint, {
      move_to_project_id: moveToProjectId,
    });
  }
}