aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api/navigation.jsx
blob: 8204fc34c111edbb3499eeb7d5e3fe092700623f (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
function _request(options) {
  let $ = jQuery;
  return $.ajax(options);
}

function _url(path) {
  return window.baseUrl + path;
}

function _typeError(method, message) {
  throw new TypeError(`navigation#${method}: ${message}`);
}

export function global() {
  let url = _url('/api/navigation/global');
  return _request({ type: 'GET', url });
}

export function component(componentKey) {
  if (typeof componentKey !== 'string' || !componentKey.length) {
    return _typeError('component', 'please provide componentKey');
  }
  let url = _url('/api/navigation/component');
  let data = { componentKey };
  return _request({ type: 'GET', url, data });
}