Skip to content

Commit d46d822

Browse files
committed
feat: show the groups that an app is enabled for when using occ app:list
Signed-off-by: Akhil <akhil@e.email>
1 parent 5467d41 commit d46d822

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

core/Command/App/ListApps.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use OC\Core\Command\Base;
1111
use OCP\App\IAppManager;
12+
use OCP\IGroupManager;
1213
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
1314
use Symfony\Component\Console\Input\InputInterface;
1415
use Symfony\Component\Console\Input\InputOption;
@@ -17,6 +18,7 @@
1718
class ListApps extends Base {
1819
public function __construct(
1920
protected IAppManager $appManager,
21+
protected IGroupManager $groupManager,
2022
) {
2123
parent::__construct();
2224
}
@@ -83,7 +85,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8385

8486
sort($enabledApps);
8587
foreach ($enabledApps as $app) {
86-
$apps['enabled'][$app] = $versions[$app] ?? true;
88+
$appDetails = $versions[$app] ?? true;
89+
$appRestrictions = $this->appManager->getAppRestriction($app);
90+
91+
if ($appRestrictions !== []) {
92+
$appDetails = $this->valueToString($appDetails, false) . $this->formatAppRestrictions($appRestrictions);
93+
}
94+
95+
$apps['enabled'][$app] = $appDetails;
8796
}
8897
}
8998

@@ -100,6 +109,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
100109
return 0;
101110
}
102111

112+
/**
113+
* @param list<string> $groupIds
114+
*/
115+
private function formatAppRestrictions(array $groupIds): string {
116+
$groups = array_map(fn (string $groupId): string => $this->groupManager->get($groupId)?->getDisplayName() ?? $groupId, $groupIds);
117+
118+
return ' (enabled for groups: ' . implode(', ', $groups) . ')';
119+
}
120+
103121
/**
104122
* @param InputInterface $input
105123
* @param OutputInterface $output

0 commit comments

Comments
 (0)