summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-02-02 13:07:37 +0000
committerPhil Hughes <me@iamphill.com>2018-02-05 09:41:45 +0000
commit7c4dfb5a5d96ef509047ad75462979bcafecb8f7 (patch)
tree49d478f7a49cbbb6a98515146570912fb289a3c9
parent663681f71924e7cda57637d46d50a84bd0bf4263 (diff)
downloadgitlab-ce-7c4dfb5a5d96ef509047ad75462979bcafecb8f7.tar.gz
converted user_tabs.js to use axios
-rw-r--r--app/assets/javascripts/users/user_tabs.js33
1 files changed, 18 insertions, 15 deletions
diff --git a/app/assets/javascripts/users/user_tabs.js b/app/assets/javascripts/users/user_tabs.js
index 992baa9a1ef..93eb4ee9524 100644
--- a/app/assets/javascripts/users/user_tabs.js
+++ b/app/assets/javascripts/users/user_tabs.js
@@ -1,6 +1,9 @@
+import axios from '../lib/utils/axios_utils';
import Activities from '../activities';
import ActivityCalendar from './activity_calendar';
import { localTimeAgo } from '../lib/utils/datetime_utility';
+import { __ } from '../locale';
+import flash from '../flash';
/**
* UserTabs
@@ -131,18 +134,20 @@ export default class UserTabs {
}
loadTab(action, endpoint) {
- return $.ajax({
- beforeSend: () => this.toggleLoading(true),
- complete: () => this.toggleLoading(false),
- dataType: 'json',
- url: endpoint,
- success: (data) => {
+ this.toggleLoading(true);
+
+ return axios.get(endpoint)
+ .then(({ data }) => {
const tabSelector = `div#${action}`;
this.$parentEl.find(tabSelector).html(data.html);
this.loaded[action] = true;
localTimeAgo($('.js-timeago', tabSelector));
- },
- });
+
+ this.toggleLoading(false);
+ })
+ .catch(() => {
+ this.toggleLoading(false);
+ });
}
loadActivities() {
@@ -158,17 +163,15 @@ export default class UserTabs {
utcFormatted = `UTC${utcOffset > 0 ? '+' : ''}${(utcOffset / 3600)}`;
}
- $.ajax({
- dataType: 'json',
- url: calendarPath,
- success: (activityData) => {
+ axios.get(calendarPath)
+ .then(({ data }) => {
$calendarWrap.html(CALENDAR_TEMPLATE);
$calendarWrap.find('.calendar-hint').append(`(Timezone: ${utcFormatted})`);
// eslint-disable-next-line no-new
- new ActivityCalendar('.js-contrib-calendar', activityData, calendarActivitiesPath, utcOffset);
- },
- });
+ new ActivityCalendar('.js-contrib-calendar', data, calendarActivitiesPath, utcOffset);
+ })
+ .catch(() => flash(__('There was ane error loaing users activity calendar.')));
// eslint-disable-next-line no-new
new Activities();