perf: Already pass board list as initial state
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -23,12 +23,10 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Controller;
|
namespace OCA\Deck\Controller;
|
||||||
|
|
||||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
|
||||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
|
||||||
use \OCP\AppFramework\Http\RedirectResponse;
|
use \OCP\AppFramework\Http\RedirectResponse;
|
||||||
use OCA\Deck\AppInfo\Application;
|
|
||||||
use OCA\Deck\Db\Acl;
|
use OCA\Deck\Db\Acl;
|
||||||
use OCA\Deck\Db\CardMapper;
|
use OCA\Deck\Db\CardMapper;
|
||||||
|
use OCA\Deck\Service\BoardService;
|
||||||
use OCA\Deck\Service\CardService;
|
use OCA\Deck\Service\CardService;
|
||||||
use OCA\Deck\Service\ConfigService;
|
use OCA\Deck\Service\ConfigService;
|
||||||
use OCA\Deck\Service\PermissionService;
|
use OCA\Deck\Service\PermissionService;
|
||||||
@@ -36,23 +34,24 @@ use OCA\Files\Event\LoadSidebar;
|
|||||||
use OCA\Text\Event\LoadEditor;
|
use OCA\Text\Event\LoadEditor;
|
||||||
use OCA\Viewer\Event\LoadViewer;
|
use OCA\Viewer\Event\LoadViewer;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||||
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
use OCP\AppFramework\Services\IInitialState;
|
||||||
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent as CollaborationResourcesEvent;
|
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent as CollaborationResourcesEvent;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IInitialStateService;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
|
|
||||||
class PageController extends Controller {
|
class PageController extends Controller {
|
||||||
private IInitialStateService $initialState;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $AppName,
|
string $AppName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
private PermissionService $permissionService,
|
private PermissionService $permissionService,
|
||||||
IInitialStateService $initialStateService,
|
private IInitialState $initialState,
|
||||||
|
private BoardService $boardService,
|
||||||
private ConfigService $configService,
|
private ConfigService $configService,
|
||||||
private IEventDispatcher $eventDispatcher,
|
private IEventDispatcher $eventDispatcher,
|
||||||
private CardMapper $cardMapper,
|
private CardMapper $cardMapper,
|
||||||
@@ -61,21 +60,16 @@ class PageController extends Controller {
|
|||||||
private IConfig $config,
|
private IConfig $config,
|
||||||
) {
|
) {
|
||||||
parent::__construct($AppName, $request);
|
parent::__construct($AppName, $request);
|
||||||
|
|
||||||
$this->initialState = $initialStateService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[NoAdminRequired]
|
||||||
* Handle main html view from templates/main.php
|
#[NoCSRFRequired]
|
||||||
* This will return the main angular application
|
public function index(): TemplateResponse {
|
||||||
*
|
$this->initialState->provideInitialState('maxUploadSize', (int)\OCP\Util::uploadLimit());
|
||||||
* @NoAdminRequired
|
$this->initialState->provideInitialState('canCreate', $this->permissionService->canCreate());
|
||||||
* @NoCSRFRequired
|
$this->initialState->provideInitialState('config', $this->configService->getAll());
|
||||||
*/
|
|
||||||
public function index() {
|
$this->initialState->provideInitialState('initialBoards', $this->boardService->findAll());
|
||||||
$this->initialState->provideInitialState(Application::APP_ID, 'maxUploadSize', (int)\OCP\Util::uploadLimit());
|
|
||||||
$this->initialState->provideInitialState(Application::APP_ID, 'canCreate', $this->permissionService->canCreate());
|
|
||||||
$this->initialState->provideInitialState(Application::APP_ID, 'config', $this->configService->getAll());
|
|
||||||
|
|
||||||
$this->eventDispatcher->dispatchTyped(new LoadSidebar());
|
$this->eventDispatcher->dispatchTyped(new LoadSidebar());
|
||||||
$this->eventDispatcher->dispatchTyped(new CollaborationResourcesEvent());
|
$this->eventDispatcher->dispatchTyped(new CollaborationResourcesEvent());
|
||||||
@@ -110,25 +104,23 @@ class PageController extends Controller {
|
|||||||
#[NoAdminRequired]
|
#[NoAdminRequired]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
public function indexBoard(int $boardId): TemplateResponse {
|
public function indexBoard(int $boardId): TemplateResponse {
|
||||||
return $this->index($boardId);
|
return $this->index();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[NoAdminRequired]
|
#[NoAdminRequired]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
public function indexBoardDetails(int $boardId): TemplateResponse {
|
public function indexBoardDetails(int $boardId): TemplateResponse {
|
||||||
return $this->index($boardId);
|
return $this->index();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[NoAdminRequired]
|
#[NoAdminRequired]
|
||||||
#[NoCSRFRequired]
|
#[NoCSRFRequired]
|
||||||
public function indexCard(int $cardId): TemplateResponse {
|
public function indexCard(int $cardId): TemplateResponse {
|
||||||
return $this->index(cardId: $cardId);
|
return $this->index();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[NoAdminRequired]
|
||||||
* @NoAdminRequired
|
#[NoCSRFRequired]
|
||||||
* @NoCSRFRequired
|
|
||||||
*/
|
|
||||||
public function redirectToCard($cardId): RedirectResponse {
|
public function redirectToCard($cardId): RedirectResponse {
|
||||||
try {
|
try {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import AppNavigation from './components/navigation/AppNavigation.vue'
|
|||||||
import { NcModal, NcContent, NcAppContent } from '@nextcloud/vue'
|
import { NcModal, NcContent, NcAppContent } from '@nextcloud/vue'
|
||||||
import { BoardApi } from './services/BoardApi.js'
|
import { BoardApi } from './services/BoardApi.js'
|
||||||
import { emit, subscribe } from '@nextcloud/event-bus'
|
import { emit, subscribe } from '@nextcloud/event-bus'
|
||||||
|
import { loadState } from '@nextcloud/initial-state'
|
||||||
|
|
||||||
const boardApi = new BoardApi()
|
const boardApi = new BoardApi()
|
||||||
|
|
||||||
@@ -108,7 +109,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
const initialState = loadState('deck', 'initialBoards', null)
|
||||||
|
if (initialState !== null) {
|
||||||
this.$store.dispatch('loadBoards')
|
this.$store.dispatch('loadBoards')
|
||||||
|
}
|
||||||
this.$store.dispatch('loadSharees')
|
this.$store.dispatch('loadSharees')
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
@@ -89,5 +89,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.opened = this.boards.length > 0
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export default new Vuex.Store({
|
|||||||
sidebarShown: false,
|
sidebarShown: false,
|
||||||
currentBoard: null,
|
currentBoard: null,
|
||||||
currentCard: null,
|
currentCard: null,
|
||||||
boards: [],
|
boards: loadState('deck', 'initialBoards', []),
|
||||||
sharees: [],
|
sharees: [],
|
||||||
assignableUsers: [],
|
assignableUsers: [],
|
||||||
boardFilter: BOARD_FILTERS.ALL,
|
boardFilter: BOARD_FILTERS.ALL,
|
||||||
|
|||||||
@@ -25,12 +25,13 @@
|
|||||||
namespace OCA\Deck\Controller;
|
namespace OCA\Deck\Controller;
|
||||||
|
|
||||||
use OCA\Deck\Db\CardMapper;
|
use OCA\Deck\Db\CardMapper;
|
||||||
|
use OCA\Deck\Service\BoardService;
|
||||||
use OCA\Deck\Service\CardService;
|
use OCA\Deck\Service\CardService;
|
||||||
use OCA\Deck\Service\ConfigService;
|
use OCA\Deck\Service\ConfigService;
|
||||||
use OCA\Deck\Service\PermissionService;
|
use OCA\Deck\Service\PermissionService;
|
||||||
|
use OCP\AppFramework\Services\IInitialState;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IInitialStateService;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@@ -40,6 +41,7 @@ class PageControllerTest extends TestCase {
|
|||||||
private $request;
|
private $request;
|
||||||
private $permissionService;
|
private $permissionService;
|
||||||
private $initialState;
|
private $initialState;
|
||||||
|
private $boardService;
|
||||||
private $configService;
|
private $configService;
|
||||||
private $eventDispatcher;
|
private $eventDispatcher;
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +63,8 @@ class PageControllerTest extends TestCase {
|
|||||||
$this->request = $this->createMock(IRequest::class);
|
$this->request = $this->createMock(IRequest::class);
|
||||||
$this->permissionService = $this->createMock(PermissionService::class);
|
$this->permissionService = $this->createMock(PermissionService::class);
|
||||||
$this->configService = $this->createMock(ConfigService::class);
|
$this->configService = $this->createMock(ConfigService::class);
|
||||||
$this->initialState = $this->createMock(IInitialStateService::class);
|
$this->initialState = $this->createMock(IInitialState::class);
|
||||||
|
$this->boardService = $this->createMock(BoardService::class);
|
||||||
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
||||||
$this->cardMapper = $this->createMock(CardMapper::class);
|
$this->cardMapper = $this->createMock(CardMapper::class);
|
||||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||||
@@ -73,6 +76,7 @@ class PageControllerTest extends TestCase {
|
|||||||
$this->request,
|
$this->request,
|
||||||
$this->permissionService,
|
$this->permissionService,
|
||||||
$this->initialState,
|
$this->initialState,
|
||||||
|
$this->boardService,
|
||||||
$this->configService,
|
$this->configService,
|
||||||
$this->eventDispatcher,
|
$this->eventDispatcher,
|
||||||
$this->cardMapper,
|
$this->cardMapper,
|
||||||
|
|||||||
Reference in New Issue
Block a user