From 7df4f83351fa261671ae0f3d462ecff2db9612dc Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 3 May 2023 14:10:14 +0530 Subject: [PATCH 01/21] 3.1.0 version --- appinfo/info.xml | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index a695b9fa..dc5aa25c 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -10,7 +10,7 @@ - 3.0.0 + 3.1.0 agpl Murena SAS EcloudAccounts diff --git a/package-lock.json b/package-lock.json index a153f139..5077e57f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ecloud-accounts", - "version": "3.0.0", + "version": "3.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ecloud-accounts", - "version": "3.0.0", + "version": "3.1.0", "dependencies": { "@nextcloud/axios": "^2.1.0", "@nextcloud/dialogs": "^3.2.0", diff --git a/package.json b/package.json index c3b7f007..83b8a14f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ecloud-accounts", - "version": "3.0.0", + "version": "3.1.0", "description": "App for ecloud account management.", "repository": { "type": "git", -- GitLab From 671ecc707fe425b260009cd3d3dcaee1ac4b24a0 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 5 May 2023 01:56:36 +0530 Subject: [PATCH 02/21] vue code --- appinfo/routes.php | 8 +- css/style.css | 68 ------- lib/Controller/BetaUserController.php | 29 ++- lib/Settings/BetaUserSetting.php | 14 -- src/BecomeBetaUser.vue | 276 ++++++++++++++++++++++++++ src/beta-user-setting.js | 90 +-------- templates/become_beta_user.php | 29 +-- templates/opt_out_beta_user.php | 49 ----- 8 files changed, 316 insertions(+), 247 deletions(-) delete mode 100644 css/style.css create mode 100644 src/BecomeBetaUser.vue delete mode 100644 templates/opt_out_beta_user.php diff --git a/appinfo/routes.php b/appinfo/routes.php index b4eb6822..36a01f8b 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -16,14 +16,18 @@ return ['routes' => [ ], [ 'name' => 'beta_user#remove_user_in_group', - 'url' => '/beta/update', 'verb' => 'DELETE' + 'url' => '/beta/remove', 'verb' => 'GET' ], [ 'name' => 'beta_user#add_user_in_group', - 'url' => '/beta/update', 'verb' => 'POST' + 'url' => '/beta/add', 'verb' => 'GET' ], [ 'name' => 'beta_user#submit_issue', 'url' => '/issue/submit', 'verb' => 'POST' + ], + [ + 'name' => 'beta_user#check_user_in_group', + 'url' => '/beta/check', 'verb' => 'GET' ] ]]; diff --git a/css/style.css b/css/style.css deleted file mode 100644 index 1c850421..00000000 --- a/css/style.css +++ /dev/null @@ -1,68 +0,0 @@ -.alert { - position: relative; - margin-top: 1rem; - margin-bottom: 1rem; - border: 1px solid transparent; - border-radius: 0.25rem; - width: fit-content; -} - -.alert-success { - color: #155724; - background-color: #d4edda; - border-color: #c3e6cb; - padding: 0.75rem 1.25rem; -} - -.alert-fail { - color: #721c24; - background-color: #f8d7da; - border-color: #f5c6cb; - padding: 0.75rem 1.25rem; -} - -#issue-submit-form #title, -#issue-submit-form textarea { - width: 450px; -} - -#issue-submit-form textarea { - height: 100px; -} - -#issue-submit-form textarea:hover { - border-color: var(--color-primary-element) !important; -} - -.mt-20 { - margin-top: 20px !important; -} - -#beta-form .btn-optout { - background-color: white; - color: var(--color-delete); - border-color: var(--color-delete); -} - -#beta-form .width300, -#issue-submit-form .width300 { - width: 300px; -} - -.color-red { - color: red; -} - -ul.beta-apps { - list-style: none; - margin-left: 0; - padding-left: 1em; -} - -ul.beta-apps > li:before { - display: inline-block; - content: '-'; - width: 1em; - margin-left: -1em; -} - diff --git a/lib/Controller/BetaUserController.php b/lib/Controller/BetaUserController.php index ac6b06c6..70722202 100644 --- a/lib/Controller/BetaUserController.php +++ b/lib/Controller/BetaUserController.php @@ -15,7 +15,7 @@ use OCP\IUserSession; use OCP\ILogger; use OCP\Mail\IMailer; use OCP\Util; - +use OCP\App\IAppManager; class BetaUserController extends Controller { protected $appName; protected $request; @@ -33,7 +33,8 @@ class BetaUserController extends Controller { IUserManager $userManager, IGroupManager $groupManager, IUserSession $userSession, - IMailer $mailer + IMailer $mailer, + IAppManager $appManager ) { parent::__construct($AppName, $request); $this->appName = $AppName; @@ -44,6 +45,7 @@ class BetaUserController extends Controller { $this->userSession = $userSession; $this->groupManager = $groupManager; $this->mailer = $mailer; + $this->appManager = $appManager; } /** @@ -101,4 +103,27 @@ class BetaUserController extends Controller { return true; } + + /** + * @NoAdminRequired + * @NoCSRFRequired + */ + public function checkUserInGroup() { + $uid = $this->userSession->getUser()->getUID(); + $betaGroupName = $this->config->getSystemValue("beta_group_name"); + $group = $this->groupManager->get($betaGroupName); + $betaGroupApps = $this->appManager->getEnabledAppsForGroup($group); + $betaApps = []; + foreach ($betaGroupApps as $app) { + $appEnabledGroups = $this->config->getAppValue($app, 'enabled', 'no'); + if (str_contains($appEnabledGroups, $betaGroupName)) { + $info = $this->appManager->getAppInfo($app); + $betaApps[] = $info['name']; + } + } + if ($this->groupManager->isInGroup($uid, $betaGroupName)) { + return ['isBetaUser' => true, 'betaApps' => $betaApps]; + } + return ['isBetaUser' => false, 'betaApps' => $betaApps]; + } } diff --git a/lib/Settings/BetaUserSetting.php b/lib/Settings/BetaUserSetting.php index 696d9433..a5746fb1 100644 --- a/lib/Settings/BetaUserSetting.php +++ b/lib/Settings/BetaUserSetting.php @@ -49,22 +49,8 @@ class BetaUserSetting implements ISettings { } public function getForm(): TemplateResponse { - $uid = $this->userSession->getUser()->getUID(); - $betaGroupName = $this->config->getSystemValue("beta_group_name"); $this->util->addScript($this->appName, $this->appName . '-beta-user-setting'); - $group = $this->groupManager->get($betaGroupName); - $betaGroupApps = $this->appManager->getEnabledAppsForGroup($group); $betaApps = []; - foreach ($betaGroupApps as $app) { - $appEnabledGroups = $this->config->getAppValue($app, 'enabled', 'no'); - if (str_contains($appEnabledGroups, $betaGroupName)) { - $info = $this->appManager->getAppInfo($app); - $betaApps[] = $info['name']; - } - } - if ($this->groupManager->isInGroup($uid, $betaGroupName)) { - return new TemplateResponse($this->appName, 'opt_out_beta_user', ['betaApps' => $betaApps], ''); - } return new TemplateResponse($this->appName, 'become_beta_user', ['betaApps' => $betaApps], ''); } diff --git a/src/BecomeBetaUser.vue b/src/BecomeBetaUser.vue new file mode 100644 index 00000000..53c375ea --- /dev/null +++ b/src/BecomeBetaUser.vue @@ -0,0 +1,276 @@ +