Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_fetch(method, handler, mapper) {
if (this.cache[method]) {
handler(this.cache[method]);
return;
}
Fetch.fetchJSON(`${UrlConfig.getBlueOceanAppURL()}/rest/pipeline-metadata/${method}?depth=20`).then(data => {
if (mapper) {
data = mapper(data);
}
this.cache[method] = data;
handler(this.cache[method]);
});
}
return (dispatch) => {
const baseUrl = UrlConfig.getBlueOceanAppURL();
const username = user.id;
const organization = AppConfig.getOrganizationName();
const url = cleanSlashes(`${baseUrl}/rest/organizations/${organization}/users/${username}/favorites/`);
if (fetchFlags[ACTION_TYPES.SET_FAVORITES]) {
return null;
}
fetchFlags[ACTION_TYPES.SET_FAVORITES] = true;
return dispatch(actions.generateData(
{ url },
ACTION_TYPES.SET_FAVORITES
));
};
},
get favorites() {
if (!this._fetched) {
const user = User.current();
this._fetched = true;
if (user && !user.isAnonymous()) {
const baseUrl = UrlConfig.getBlueOceanAppURL();
const username = user.id;
const organization = AppConfig.getOrganizationName();
const url = cleanSlashes(`${baseUrl}/rest/organizations/${organization}/users/${username}/favorites/?start=0&limit=26`);
this.fetch(url).then(favorites => this._setFavorites(sortHelper.applyStandardSort(favorites)));
}
}
return this._favorites;
}
getStepListing(handler) {
if (this.stepData) {
handler(this.stepData);
return;
}
Fetch.fetchJSON(`${UrlConfig.getBlueOceanAppURL()}/rest/pipeline-metadata/pipelineStepMetadata?depth=20`).then(data => {
this.stepData = this.filterStepListing(data);
handler(this.stepData);
});
}
filterStepListing(steps) {