Skip to content
Snippets Groups Projects
Commit 7364b9bd authored by Matthew Grasmick's avatar Matthew Grasmick
Browse files

Properly identify inactive modules.

parent 60235c35
No related branches found
No related tags found
No related merge requests found
......@@ -11,19 +11,6 @@ project_browser.api_project_get_all:
_access: 'TRUE'
#options:
# no_cache: 'TRUE'
project_browser.api_project_get:
path: '/drupal-org-proxy/project/{name}'
methods: [GET]
defaults:
_controller: '\Drupal\project_browser\Controller\DrupalOrgProxyController::getProject'
_title: 'Get project by name'
requirements:
#_permission: 'manage own subscriptions+administer subscriptions'
#_user_is_logged_in: 'TRUE'
# @todo Undo this access bypass!
_access: 'TRUE'
options:
no_cache: 'TRUE'
project_browser.browse:
path: '/admin/modules/browse'
defaults:
......
......@@ -3,14 +3,31 @@
namespace Drupal\project_browser\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Extension\InfoParserException;
use Drupal\Core\Extension\ModuleExtensionList;
class BrowserController extends ControllerBase {
public function browse() {
$module_service = \Drupal::service('extension.list.module')->getList();
/** @var ModuleExtensionList $module_service */
$module_service = \Drupal::service('extension.list.module');
// Sort all modules by their names.
try {
// The module list needs to be reset so that it can re-scan and include
// any new modules that may have been added directly into the filesystem.
$modules = $module_service->reset()->getList();
uasort($modules, 'system_sort_modules_by_info_name');
}
catch (InfoParserException $e) {
$this->messenger()->addError($this->t('Modules could not be listed due to an error: %error',
['%error' => $e->getMessage()]));
$modules = [];
}
$modules_status = array_map(function($value) {
return $value->status;
}, $module_service);
}, $modules);
return [
'#markup' => '<div id="project-browser"></div>',
'#attached' => [
......
......@@ -84,30 +84,4 @@ class DrupalOrgProxyController extends ControllerBase {
}
}
/**
* @param string $name The machine name of the project.
*
* @return \Drupal\Core\Cache\CacheableResponseInterface|mixed|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function getProject($name = NULL) {
try {
$drupal_org_client = new DrupalOrgClient();
// @todo Determine current major version and filter modules by compatibility.
$project = $drupal_org_client->getProjects(['field_project_machine_name' => $name]);
if ($project) {
$response = new JsonResponse($project, Response::HTTP_ACCEPTED);
// Configure caching for results.
if ($response instanceof CacheableResponseInterface) {
$response->addCacheableDependency($project);
}
return $response;
}
return new Response('Could not find any projects', Response::HTTP_BAD_REQUEST);
}
catch (\Exception $exception) {
$this->logger->error($exception->getMessage());
return new Response($exception->getMessage(), Response::HTTP_BAD_REQUEST);
}
}
}
<script>
import { fly } from 'svelte/transition';
import { bind } from './Modal.svelte';
import ComposerPopup from './ComposerPopup.svelte';
import ComposerPopup from './DownloadPopup.svelte';
import { modal } from './stores.js';
let opening = false;
......@@ -19,7 +19,7 @@
};
</script>
<button on:click={showPopupWithProps}>Install</button>
<button on:click={showPopupWithProps}>Download</button>
<style>
</style>
......@@ -12,11 +12,14 @@
}
</style>
<h2>Install {project.title}</h2>
<h2>Download {project.title}</h2>
<p>The recommended way to install any Drupal module is with Composer. If you already manage your Drupal application
<p>The recommended way to download any Drupal module is with Composer. If you already manage your Drupal application
dependencies with Composer, simply open your CLI and run the following command from the Composer root directory
for your application:</p>
<pre>
composer require {project.field_project_machine_name} --with-all-dependencies
composer require drupal/{project.field_project_machine_name} --with-all-dependencies
</pre>
This will add the module to your codebase. You will then need to enable it via Drupal. You can either use `drush` from
the CLI, or you can visit the <a href="/admin/modules">modules page</a>.
......@@ -2,7 +2,7 @@
import { onMount } from "svelte";
import Table, { Pagination, Row, Search, Sort } from "./Table.svelte";
import { sortNumber, sortString } from "./sorting.js";
import InstallButton from './InstallButton.svelte';
import DownloadButton from './DownloadButton.svelte';
let data;
let rows = [];
......@@ -143,12 +143,13 @@
<div><a href="{row.url}" target="_blank">{row.title}</a></div>
<div>{@html String(row.body.summary).substring(0, 200) + '...'}</div>
<div class="status">Status:
{#if projectIsEnabled(row.project_machine_name)}
{#if projectIsEnabled(row.field_project_machine_name)}
Installed
{:else if projectIsDownloaded(row.project_machine_name)}
Downloaded, not installed.
{:else if projectIsDownloaded(row.field_project_machine_name)}
Downloaded, <a href="/admin/modules#module-{row.field_project_machine_name}" target="_blank">not installed</a>
{:else}
Not downloaded
<DownloadButton project={row} />
{/if}
</div>
<div class="images">Images:
......@@ -158,7 +159,6 @@
{/each}
</ul>
</div>
<InstallButton project={row} />
</td>
<td data-label="Maintenance status">
{#if row.taxonomy_vocabulary_44}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment