Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
Merge pull request #67 from yiisoft/adopt
Browse files Browse the repository at this point in the history
Adopt changes for frontend
  • Loading branch information
xepozz authored Jun 10, 2024
2 parents 7eeeabe + f7798df commit f30a07f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"yiisoft/assets": "^4.0",
"yiisoft/data-response": "^2.0",
"yiisoft/http": "^1.1",
"yiisoft/router": "^3.1",
"yiisoft/view": "^8.0",
"yiisoft/yii-view": "^6.1"
},
Expand All @@ -60,7 +61,6 @@
"yiisoft/injector": "^1.0",
"yiisoft/log": "^2.0",
"yiisoft/log-target-file": "^3.0",
"yiisoft/router": "^3.0",
"yiisoft/router-fastroute": "^3.0",
"yiisoft/yii-console": "^2.0",
"yiisoft/yii-event": "^2.0",
Expand Down
6 changes: 3 additions & 3 deletions config/.merge-plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
'yiisoft/aliases' => [
'config/di.php',
],
'yiisoft/router' => [
'config/di.php',
],
'yiisoft/view' => [
'config/di.php',
],
Expand All @@ -93,9 +96,6 @@
'yiisoft/log-target-file' => [
'config/di.php',
],
'yiisoft/router' => [
'config/di.php',
],
'yiisoft/yii-event' => [
'config/di.php',
],
Expand Down
13 changes: 13 additions & 0 deletions src/Middleware/DevPanelMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$this->assetManager->registerCustomized(DevPanelAsset::class, ['baseUrl' => $this->staticUrl]);
$this->view->registerJs(
<<<JS
(function(){
let queryParams = {toolbar: '1'};
try {
queryParams = Object.fromEntries(new URLSearchParams(location.search));
} catch (e) {
console.error('Error while parsing query params: ', e);
}
const containerId = '{$this->containerId}';
const container = document.createElement('div');
container.setAttribute('id', containerId);
Expand All @@ -49,15 +57,20 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
application: {
editorUrl: '{$this->editorUrl}',
},
modules: {
toolbar: queryParams?.toolbar !== '0',
},
router: {
basename: '{$baseUriPrefix}{$this->viewerUrl}',
useHashRouter: false,
},
backend: {
baseUrl: '{$this->backendUrl}{$baseUriPrefix}',
usePreferredUrl: true,
}
},
};
})();
JS,
WebView::POSITION_LOAD,
);
Expand Down
6 changes: 6 additions & 0 deletions src/Middleware/ToolbarMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
$this->assetManager->registerCustomized(ToolbarAsset::class, ['baseUrl' => $this->staticUrl]);
$this->view->registerJs(
<<<JS
(function(){
const containerId = '{$this->containerId}';
const container = document.createElement('div');
container.setAttribute('id', containerId);
Expand All @@ -49,15 +50,20 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
application: {
editorUrl: '{$this->editorUrl}',
},
modules: {
toolbar: '1',
},
router: {
basename: '{$baseUriPrefix}',
useHashRouter: false,
},
backend: {
baseUrl: '{$this->backendUrl}{$baseUriPrefix}',
usePreferredUrl: true,
}
},
};
})();
JS,
WebView::POSITION_LOAD,
);
Expand Down

0 comments on commit f30a07f

Please sign in to comment.