Permalink
Browse files

NodesList CLI table rendering error when no nodes.

Disable CacheStreamLayer when in command line
Change empty_recycle to a dedicated action (no more selectAll + delete). Send in background.
  • Loading branch information...
1 parent ff6b8a4 commit 8484f21f39ed2b50156381fcb3348f3fc00fc9eb @cdujeu cdujeu committed Sep 3, 2016
@@ -919,6 +919,46 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
break;
+ case "empty_recycle":
+
+ $taskId = $request->getAttribute("pydio-task-id");
+ if($taskId === null && !ConfService::currentContextIsCommandLine()){
+ $task = TaskService::actionAsTask($ctx, $action, $httpVars);
+ $response = TaskService::getInstance()->enqueueTask($task, $request, $response);
+ break;
+ }
+ // List recycle content
+ $fakeResp = new Response();
+ $recycleBin = RecycleBinManager::getRelativeRecycle();
+ $newRequest = $request->withAttribute("action", "ls");
+ $newRequest = $newRequest->withParsedBody(["dir" => $recycleBin]);
+ $this->switchAction($newRequest, $fakeResp);
+ $b = $fakeResp->getBody();
+ if($b instanceof SerializableResponseStream){
+ foreach($b->getChunks() as $chunk){
+ if($chunk instanceof NodesList){
+ $list = $chunk;
+ }
+ }
+ }
+ if(!isSet($list)){
+ throw new PydioException("Could not retrieve recycle bin content");
+ }
+ $selection = UserSelection::fromContext($ctx, []);
+ $selection->initFromNodes($list->getChildren());
+ $logMessages = [];
+ $errorMessage = $this->delete($selection, $logMessages, $taskId);
+ if (count($logMessages)) {
+ $logMessage = new UserMessage(join("\n", $logMessages));
+ }
+ if($errorMessage) {
+ throw new PydioException(TextEncoder::toUTF8($errorMessage));
+ }
+ $this->logInfo("Delete", ["files"=>$this->addSlugToPath($selection)]);
+ $nodesDiffs->remove($selection->getFiles());
+
+ break;
+
//------------------------------------
// COPY / MOVE
//------------------------------------
@@ -195,18 +195,26 @@
</action>
<action name="empty_recycle">
<gui text="220" title="221" src="trashcan_empty.png" iconClass="icon-ban-circle" accessKey="empty_recycle_access_key" hasAccessKey="true">
- <context selection="false" dir="true" recycle="only" actionBar="true"
+ <context selection="true" dir="true" recycle="only" actionBar="true"
contextMenu="true" infoPanel="false" actionBarGroup="change_main"/>
+ <selectionContext dir="false" file="false" recycle="true" unique="true"/>
</gui>
<rightsContext noUser="true" userLogged="" read="true" write="true" adminOnly=""/>
<processing>
+ <serverCallback methodName="switchAction" restParams="/"/>
<clientCallback prepareModal="false"><![CDATA[
- ajaxplorer.getContextHolder().selectAll();
- window.setTimeout(function(){
- pydio.getController().fireAction('delete');
- }, 200);
- ]]></clientCallback>
- </processing>
+ modal.showDialogForm('EmptyRecycle', 'empty_recycle_form', null, function(){
+ PydioApi.getClient().request({get_action:'empty_recycle'});
+ hideLightBox(true);
+ return false;
+ });
+ ]]></clientCallback>
+ <clientForm id="empty_recycle_form"><![CDATA[
+ <div id="empty_recycle_form" action="empty_recycle" box_width="200">
+ <span ajxp_message_id="177">AJXP_MESSAGE[177]</span>
+ </div>
+ ]]></clientForm>
+ </processing>
</action>
<action name="download" fileDefault="false">
<gui text="88" title="88" src="download_manager.png" iconClass="mdi mdi-download" accessKey="download_access_key" hasAccessKey="true">
@@ -255,7 +255,7 @@ public function render($output)
$collAttr = $column["attributeName"];
$headers[$collAttr] = $colTitle;
}
- }else{
+ }else if(count($this->children)){
/** @var AJXP_Node $firstNode */
$firstNode = $this->children[0];
$headers["text"] = "Label"; //$firstNode->getLabel();
@@ -268,6 +268,8 @@ public function render($output)
$headers[$attName] = ucfirst($attName);
}
}
+ }else{
+ $headers["h"] = "No results found";
}
$table->setHeaders(array_values($headers));
@@ -68,7 +68,7 @@ public function getImplementation($pluginsService = null)
$pluginInstance = ConfService::instanciatePluginFromGlobalParams($this->pluginConf["UNIQUE_INSTANCE_CONFIG"], "Pydio\\Cache\\Core\\AbstractCacheDriver", $pluginsService);
}
self::$cacheInstance = $pluginInstance;
- if($pluginInstance !== null && $pluginInstance instanceof AbstractCacheDriver && $pluginInstance->supportsPatternDelete(AJXP_CACHE_SERVICE_NS_NODES)){
+ if(!ConfService::currentContextIsCommandLine() && $pluginInstance !== null && $pluginInstance instanceof AbstractCacheDriver && $pluginInstance->supportsPatternDelete(AJXP_CACHE_SERVICE_NS_NODES)){
MetaStreamWrapper::appendMetaWrapper("pydio.cache", "\\Pydio\\Cache\\Core\\CacheStreamLayer");
}
}

0 comments on commit 8484f21

Please sign in to comment.