@@ -7,7 +7,7 @@ import axios from '@nextcloud/axios'
77import { showError , showInfo } from '@nextcloud/dialogs'
88import { loadState } from '@nextcloud/initial-state'
99import { PwdConfirmationMode } from '@nextcloud/password-confirmation'
10- import { generateUrl } from '@nextcloud/router'
10+ import { generateOcsUrl , generateUrl } from '@nextcloud/router'
1111import Vue from 'vue'
1212import logger from '../utils/logger.ts'
1313import api from './api.js'
@@ -196,7 +196,8 @@ const actions = {
196196 }
197197 } )
198198
199- return api . post ( generateUrl ( 'settings/apps/enable' ) , { appIds : apps , groups } , { confirmPassword : PwdConfirmationMode . Strict } )
199+ const url = generateOcsUrl ( 'apps/appstore/api/v1/enable' )
200+ return api . post ( url , { appIds : apps , groups } , { confirmPassword : PwdConfirmationMode . Strict } )
200201 . then ( ( response ) => {
201202 context . commit ( 'stopLoading' , apps )
202203 context . commit ( 'stopLoading' , 'install' )
@@ -268,7 +269,8 @@ const actions = {
268269 return api . requireAdmin ( ) . then ( ( ) => {
269270 context . commit ( 'startLoading' , apps )
270271 context . commit ( 'startLoading' , 'install' )
271- return api . post ( generateUrl ( 'settings/apps/force' ) , { appId } )
272+ const url = generateOcsUrl ( 'apps/appstore/api/v1/force' )
273+ return api . post ( url , { appId } )
272274 . then ( ( ) => {
273275 context . commit ( 'setInstallState' , { appId, canInstall : true } )
274276 } )
@@ -296,24 +298,28 @@ const actions = {
296298 }
297299 return api . requireAdmin ( ) . then ( ( ) => {
298300 context . commit ( 'startLoading' , apps )
299- return api . post ( generateUrl ( 'settings/apps/disable' ) , { appIds : apps } )
300- . then ( ( ) => {
301- context . commit ( 'stopLoading' , apps )
302- apps . forEach ( ( _appId ) => {
303- context . commit ( 'disableApp' , _appId )
301+ const url = generateOcsUrl ( 'apps/appstore/api/v1/disable' )
302+ return Promise . all ( apps . map ( ( appId ) => {
303+ return api . post ( url , { appId } )
304+ . then ( ( ) => {
305+ context . commit ( 'stopLoading' , apps )
306+ apps . forEach ( ( _appId ) => {
307+ context . commit ( 'disableApp' , _appId )
308+ } )
309+ return true
304310 } )
305- return true
306- } )
307- . catch ( ( error ) => {
308- context . commit ( 'stopLoading' , apps )
309- context . commit ( 'APPS_API_FAILURE' , { appId, error } )
310- } )
311+ . catch ( ( error ) => {
312+ context . commit ( 'stopLoading' , apps )
313+ context . commit ( 'APPS_API_FAILURE' , { appId, error } )
314+ } )
315+ } ) )
311316 } ) . catch ( ( error ) => context . commit ( 'API_FAILURE' , { appId, error } ) )
312317 } ,
313318 uninstallApp ( context , { appId } ) {
314319 return api . requireAdmin ( ) . then ( ( ) => {
315320 context . commit ( 'startLoading' , appId )
316- return api . get ( generateUrl ( `settings/apps/uninstall/${ appId } ` ) )
321+ const url = generateOcsUrl ( 'apps/appstore/api/v1/uninstall' )
322+ return api . post ( url , { appId } )
317323 . then ( ( ) => {
318324 context . commit ( 'stopLoading' , appId )
319325 context . commit ( 'uninstallApp' , appId )
@@ -330,7 +336,8 @@ const actions = {
330336 return api . requireAdmin ( ) . then ( ( ) => {
331337 context . commit ( 'startLoading' , appId )
332338 context . commit ( 'startLoading' , 'install' )
333- return api . get ( generateUrl ( `settings/apps/update/${ appId } ` ) )
339+ const url = generateOcsUrl ( 'apps/appstore/api/v1/update' )
340+ return api . post ( url , { appId } )
334341 . then ( ( ) => {
335342 context . commit ( 'stopLoading' , 'install' )
336343 context . commit ( 'stopLoading' , appId )
@@ -347,9 +354,11 @@ const actions = {
347354
348355 getAllApps ( context ) {
349356 context . commit ( 'startLoading' , 'list' )
350- return api . get ( generateUrl ( 'settings/apps/list' ) )
357+ const url = generateOcsUrl ( 'apps/appstore/api/v1/apps' )
358+ return api . get ( url )
351359 . then ( ( response ) => {
352- context . commit ( 'setAllApps' , response . data . apps )
360+ const apps = response . data . ocs . data
361+ context . commit ( 'setAllApps' , apps )
353362 context . commit ( 'stopLoading' , 'list' )
354363 return true
355364 } )
@@ -360,9 +369,9 @@ const actions = {
360369 if ( shouldRefetchCategories || ! context . state . gettingCategoriesPromise ) {
361370 context . commit ( 'startLoading' , 'categories' )
362371 try {
363- const categoriesPromise = api . get ( generateUrl ( 'settings /apps/categories') )
372+ const categoriesPromise = api . get ( generateOcsUrl ( 'apps/appstore/api/v1 /apps/categories') )
364373 context . commit ( 'updateCategories' , categoriesPromise )
365- const categoriesPromiseResponse = await categoriesPromise
374+ const categoriesPromiseResponse = ( await categoriesPromise ) . data . ocs
366375 if ( categoriesPromiseResponse . data . length > 0 ) {
367376 context . commit ( 'appendCategories' , categoriesPromiseResponse . data )
368377 context . commit ( 'stopLoading' , 'categories' )
0 commit comments