@@ -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,9 @@ 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/apps/enable' )
200+ return Promise . all ( apps . map ( ( appId ) => api
201+ . post ( url , { appId, groups } , { confirmPassword : PwdConfirmationMode . Strict } )
200202 . then ( ( response ) => {
201203 context . commit ( 'stopLoading' , apps )
202204 context . commit ( 'stopLoading' , 'install' )
@@ -256,7 +258,7 @@ const actions = {
256258 } )
257259 context . commit ( 'APPS_API_FAILURE' , { appId, error } )
258260 }
259- } )
261+ } ) ) )
260262 } ,
261263 forceEnableApp ( context , { appId } ) {
262264 let apps
@@ -268,7 +270,8 @@ const actions = {
268270 return api . requireAdmin ( ) . then ( ( ) => {
269271 context . commit ( 'startLoading' , apps )
270272 context . commit ( 'startLoading' , 'install' )
271- return api . post ( generateUrl ( 'settings/apps/force' ) , { appId } )
273+ const url = generateOcsUrl ( 'apps/appstore/api/v1/apps/enable' )
274+ return api . post ( url , { appId, force : true } , { confirmPassword : PwdConfirmationMode . Strict } )
272275 . then ( ( ) => {
273276 context . commit ( 'setInstallState' , { appId, canInstall : true } )
274277 } )
@@ -296,24 +299,28 @@ const actions = {
296299 }
297300 return api . requireAdmin ( ) . then ( ( ) => {
298301 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 )
302+ const url = generateOcsUrl ( 'apps/appstore/api/v1/apps/disable' )
303+ return Promise . all ( apps . map ( ( appId ) => {
304+ return api . post ( url , { appId } )
305+ . then ( ( ) => {
306+ context . commit ( 'stopLoading' , apps )
307+ apps . forEach ( ( _appId ) => {
308+ context . commit ( 'disableApp' , _appId )
309+ } )
310+ return true
304311 } )
305- return true
306- } )
307- . catch ( ( error ) => {
308- context . commit ( 'stopLoading' , apps )
309- context . commit ( 'APPS_API_FAILURE' , { appId, error } )
310- } )
312+ . catch ( ( error ) => {
313+ context . commit ( 'stopLoading' , apps )
314+ context . commit ( 'APPS_API_FAILURE' , { appId, error } )
315+ } )
316+ } ) )
311317 } ) . catch ( ( error ) => context . commit ( 'API_FAILURE' , { appId, error } ) )
312318 } ,
313319 uninstallApp ( context , { appId } ) {
314320 return api . requireAdmin ( ) . then ( ( ) => {
315321 context . commit ( 'startLoading' , appId )
316- return api . get ( generateUrl ( `settings/apps/uninstall/${ appId } ` ) )
322+ const url = generateOcsUrl ( 'apps/appstore/api/v1/apps/uninstall' )
323+ return api . post ( url , { appId } )
317324 . then ( ( ) => {
318325 context . commit ( 'stopLoading' , appId )
319326 context . commit ( 'uninstallApp' , appId )
@@ -330,7 +337,8 @@ const actions = {
330337 return api . requireAdmin ( ) . then ( ( ) => {
331338 context . commit ( 'startLoading' , appId )
332339 context . commit ( 'startLoading' , 'install' )
333- return api . get ( generateUrl ( `settings/apps/update/${ appId } ` ) )
340+ const url = generateOcsUrl ( 'apps/appstore/api/v1/apps/update' )
341+ return api . post ( url , { appId } , { confirmPassword : PwdConfirmationMode . Strict } )
334342 . then ( ( ) => {
335343 context . commit ( 'stopLoading' , 'install' )
336344 context . commit ( 'stopLoading' , appId )
@@ -347,9 +355,11 @@ const actions = {
347355
348356 getAllApps ( context ) {
349357 context . commit ( 'startLoading' , 'list' )
350- return api . get ( generateUrl ( 'settings/apps/list' ) )
358+ const url = generateOcsUrl ( 'apps/appstore/api/v1/apps' )
359+ return api . get ( url )
351360 . then ( ( response ) => {
352- context . commit ( 'setAllApps' , response . data . apps )
361+ const apps = response . data . ocs . data
362+ context . commit ( 'setAllApps' , apps )
353363 context . commit ( 'stopLoading' , 'list' )
354364 return true
355365 } )
@@ -360,9 +370,9 @@ const actions = {
360370 if ( shouldRefetchCategories || ! context . state . gettingCategoriesPromise ) {
361371 context . commit ( 'startLoading' , 'categories' )
362372 try {
363- const categoriesPromise = api . get ( generateUrl ( 'settings /apps/categories') )
373+ const categoriesPromise = api . get ( generateOcsUrl ( 'apps/appstore/api/v1 /apps/categories') )
364374 context . commit ( 'updateCategories' , categoriesPromise )
365- const categoriesPromiseResponse = await categoriesPromise
375+ const categoriesPromiseResponse = ( await categoriesPromise ) . data . ocs
366376 if ( categoriesPromiseResponse . data . length > 0 ) {
367377 context . commit ( 'appendCategories' , categoriesPromiseResponse . data )
368378 context . commit ( 'stopLoading' , 'categories' )
0 commit comments