Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace usage of Deprecated API Endpoints - MEED-7624 - Meeds-io/meeds#2479 #1750

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</v-app>
</template>
<script>
import * as popularSpacesService from '../js/PopularSpacesService.js';

export default {
props: {
limit: {
Expand All @@ -66,14 +64,14 @@ export default {
methods: {
refresh() {
this.loading = true;
return popularSpacesService.getSpaceLeaderBord(this.period, this.limit)
return this.$popularSpacesService.getSpaceLeaderBord(this.period, this.limit)
.then((spacesByPoints) => {
const promises = [];
spacesByPoints
.filter(spaceByPoints => spaceByPoints.technicalId)
.forEach(spaceByPoints => {
promises.push(
popularSpacesService.getSpace(spaceByPoints.technicalId)
this.$spaceService.getSpaceById(spaceByPoints.technicalId)
.then(space => {
if (space && space.id) {
Object.assign(spaceByPoints, space);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</template>
<script>
const randomMax = 10000;
import * as popularSpacesService from '../js/PopularSpacesService.js';

export default {
props: {
space: {
Expand All @@ -140,7 +138,7 @@ export default {
methods: {
acceptToJoin() {
this.sendingAction = true;
popularSpacesService.accept(this.space.id)
this.$spaceService.accept(this.space.id)
.then(() => this.$emit('refresh'))
.catch((e) => {
// eslint-disable-next-line no-console
Expand All @@ -152,7 +150,7 @@ export default {
},
refuseToJoin() {
this.sendingSecondAction = true;
popularSpacesService.deny(this.space.id)
this.$spaceService.deny(this.space.id)
.then(() => this.$emit('refresh'))
.catch((e) => {
// eslint-disable-next-line no-console
Expand All @@ -164,7 +162,7 @@ export default {
},
join() {
this.sendingAction = true;
popularSpacesService.join(this.space.id)
this.$spaceService.join(this.space.id)
.then(() => this.$emit('refresh'))
.catch((e) => {
// eslint-disable-next-line no-console
Expand All @@ -176,7 +174,7 @@ export default {
},
requestJoin() {
this.sendingAction = true;
popularSpacesService.requestJoin(this.space.id)
this.$spaceService.requestJoin(this.space.id)
.then(() => this.$emit('refresh'))
.catch((e) => {
// eslint-disable-next-line no-console
Expand All @@ -188,7 +186,7 @@ export default {
},
cancelRequest() {
this.sendingAction = true;
popularSpacesService.cancel(this.space.id)
this.$spaceService.cancel(this.space.id)
.then(() => this.$emit('refresh'))
.catch((e) => {
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,72 +26,3 @@ export function getSpaceLeaderBord(period, limit) {
}
});
}

export function getSpace(spaceId) {
return fetch(`/portal/rest/v1/social/spaces/${spaceId}`, {
method: 'GET',
credentials: 'include',
}).then(resp => {
if (!resp || !resp.ok) {
throw new Error('Response code indicates a server error', resp);
} else {
return resp.json();
}
});
}


export function cancel(spaceId) {
return fetch(`/portal/rest/homepage/intranet/spaces/cancel/${spaceId}`, {
method: 'DELETE',
credentials: 'include',
}).then(resp => {
if (!resp || !resp.ok) {
throw new Error('Response code indicates a server error', resp);
}
});
}

export function join(spaceId) {
return fetch(`/portal/rest/homepage/intranet/spaces/join/${spaceId}`, {
method: 'GET',
credentials: 'include',
}).then(resp => {
if (!resp || !resp.ok) {
throw new Error('Response code indicates a server error', resp);
}
});
}

export function requestJoin(spaceId) {
return fetch(`/portal/rest/homepage/intranet/spaces/request/${spaceId}`, {
method: 'GET',
credentials: 'include',
}).then(resp => {
if (!resp || !resp.ok) {
throw new Error('Response code indicates a server error', resp);
}
});
}

export function accept(spaceId) {
return fetch(`/portal/rest/homepage/intranet/spaces/accept/${spaceId}`, {
method: 'GET',
credentials: 'include',
}).then(resp => {
if (!resp || !resp.ok) {
throw new Error('Response code indicates a server error', resp);
}
});
}

export function deny(spaceId) {
return fetch(`/portal/rest/homepage/intranet/spaces/deny/${spaceId}`, {
method: 'GET',
credentials: 'include',
}).then(resp => {
if (!resp || !resp.ok) {
throw new Error('Response code indicates a server error', resp);
}
});
}
1 change: 1 addition & 0 deletions portlets/src/main/webapp/vue-app/popularSpaces/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import './initComponents.js';
import './services.js';

//get overrided components if exists
if (extensionRegistry) {
Expand Down
26 changes: 26 additions & 0 deletions portlets/src/main/webapp/vue-app/popularSpaces/services.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as popularSpacesService from './js/PopularSpacesService.js';

if (!Vue.prototype.$popularSpacesService) {
window.Object.defineProperty(Vue.prototype, '$popularSpacesService', {
value: popularSpacesService,
});
}