diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a29b6313332ad39922515b40f46ae4e85f2c64af..6119917f226a5a16fd4103165beb5861724de6a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ variables: - TO_PACKAGE: 'appinfo css l10n lib templates js img' + TO_PACKAGE: 'appinfo l10n lib templates js img' include: - project: "e/infra/ecloud/nextcloud-apps/ci-templates" ref: main diff --git a/appinfo/info.xml b/appinfo/info.xml index a695b9fabd50f7d579fbeb089f13f6422598d363..dc5aa25c5412921ea83de92fde0732915124b494 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/appinfo/routes.php b/appinfo/routes.php index b4eb6822029af966b5d3137f84643d5332a14de5..24d5750238339b2056d5e83ee6beb412901dc463 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -16,11 +16,11 @@ 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', diff --git a/css/style.css b/css/style.css deleted file mode 100644 index 1c8504213c6e7c1e0655bd90cd00b82d895789fa..0000000000000000000000000000000000000000 --- 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 ac6b06c60a999a7d5d93b7429dc3683d542be2b3..be1b970f83d308170ae8b7a807a9a800b0b05b39 100644 --- a/lib/Controller/BetaUserController.php +++ b/lib/Controller/BetaUserController.php @@ -12,7 +12,6 @@ use OCP\IConfig; use OCP\IUserManager; use OCP\IGroupManager; use OCP\IUserSession; -use OCP\ILogger; use OCP\Mail\IMailer; use OCP\Util; @@ -29,7 +28,6 @@ class BetaUserController extends Controller { $AppName, IRequest $request, IConfig $config, - ILogger $logger, IUserManager $userManager, IGroupManager $groupManager, IUserSession $userSession, @@ -39,7 +37,6 @@ class BetaUserController extends Controller { $this->appName = $AppName; $this->request = $request; $this->config = $config; - $this->logger = $logger; $this->userManager = $userManager; $this->userSession = $userSession; $this->groupManager = $groupManager; @@ -85,7 +82,6 @@ class BetaUserController extends Controller { $fromEmail = $user->getEMailAddress(); $fromName = $user->getDisplayName(); - $template = $this->mailer->createEMailTemplate('betauser.SubmitGitIssue', []); $template->addHeader(); $template->setSubject($title); @@ -98,7 +94,6 @@ class BetaUserController extends Controller { $message->useTemplate($template); $this->mailer->send($message); - return true; } } diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index dd87f13eea12cfec94bf54d9edf99cbce46637c7..975e7aa769cf80631fc1f3fa60f7e5f0d6988968 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -65,7 +65,7 @@ class UserController extends ApiController { * @PublicPage * @NoCSRFRequired */ - public function setAccountData(string $token, string $uid, string $email, string $recoveryEmail, string $hmeAlias, string $quota = '1024 MB'): DataResponse { + public function setAccountData(string $token, string $uid, string $email, string $recoveryEmail, string $hmeAlias, string $quota = '1024 MB', bool $tosAccepted = false): DataResponse { $response = new DataResponse(); if (!$this->checkAppCredentials($token)) { @@ -87,7 +87,7 @@ class UserController extends ApiController { $user->setEMailAddress($email); $user->setQuota($quota); - + $this->config->setUserValue($uid, 'terms_of_service', 'tosAccepted', intval($tosAccepted)); $recoveryEmailUpdated = $this->userService->setRecoveryEmail($uid, $recoveryEmail); if (!$recoveryEmailUpdated) { return $this->getErrorResponse($response, 'error_setting_recovery', 400); diff --git a/lib/Service/BetaUserService.php b/lib/Service/BetaUserService.php new file mode 100644 index 0000000000000000000000000000000000000000..3f6f84d293d31454a264ab2a84a2c8373f884761 --- /dev/null +++ b/lib/Service/BetaUserService.php @@ -0,0 +1,63 @@ +config = $config; + $this->groupManager = $groupManager; + $this->userSession = $userSession; + $this->appManager = $appManager; + } + + /** + * Method getBetaUserStatus used to get beta user status + * + * @return void + */ + public function getBetaUserStatus() { + $uid = $this->userSession->getUser()->getUID(); + $betaGroupName = $this->config->getSystemValue("beta_group_name"); + if ($this->groupManager->isInGroup($uid, $betaGroupName)) { + return true; + } + return false; + } + + /** + * Method getBetaApps used to get beta apps + * + * @return void + */ + public function getBetaApps() { + $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']; + } + } + return $betaApps; + } +} diff --git a/lib/Settings/BetaUserSetting.php b/lib/Settings/BetaUserSetting.php index 696d94337ea6a52d26b55ffa5bfd464233aa0465..79c6b95cc607a5391d8b326ececf8b30a8862be5 100644 --- a/lib/Settings/BetaUserSetting.php +++ b/lib/Settings/BetaUserSetting.php @@ -6,66 +6,42 @@ namespace OCA\EcloudAccounts\Settings; use OCP\AppFramework\Http\TemplateResponse; use OCP\IGroupManager; -use OCP\IUserSession; use OCP\Settings\ISettings; -use OCP\Util; use OCP\IConfig; -use OCP\App\IAppManager; use OCP\ILogger; +use OCP\AppFramework\Services\IInitialState; +use OCA\EcloudAccounts\Service\BetaUserService; class BetaUserSetting implements ISettings { - /** @var IUserSession */ - private $userSession; - - /** @var IGroupManager */ protected $groupManager; - - /** @var Util */ - protected $util; - - private $appName; - - private $appManager; - - /** @var ILogger */ private $logger; + private $initialState; + private $config; + private $appName; + private $betaUserService; public function __construct( $appName, - IUserSession $userSession, IGroupManager $groupManager, - Util $util, IConfig $config, - IAppManager $appManager, - ILogger $logger + ILogger $logger, + IInitialState $initialState, + BetaUserService $betaUserService ) { - $this->userSession = $userSession; $this->groupManager = $groupManager; $this->appName = $appName; $this->config = $config; - $this->util = $util; - $this->appManager = $appManager; $this->logger = $logger; + $this->initialState = $initialState; + $this->betaUserService = $betaUserService; } 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], ''); + $betaUserStatus = $this->betaUserService->getBetaUserStatus(); + $betaApps = $this->betaUserService->getBetaApps(); + $this->initialState->provideInitialState('is_beta_user', $betaUserStatus); + $this->initialState->provideInitialState('beta_apps', $betaApps); + return new TemplateResponse($this->appName, 'beta', ['appName' => $this->appName], ''); } public function getSection(): ?string { diff --git a/package-lock.json b/package-lock.json index a153f1390b0fc2a02585f0e03bccd64aca331624..5077e57f6351ca83850c3c64718d8e88400480d3 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 c3b7f0076d372cc0a2fc268169dd56cc9bd38116..83b8a14f52ca558912e46b633968d3c5a1b20a08 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", diff --git a/src/BecomeBetaUser.vue b/src/BecomeBetaUser.vue new file mode 100644 index 0000000000000000000000000000000000000000..1fbb375957e35d7ae47b9d785a8f4c5ca4a8959b --- /dev/null +++ b/src/BecomeBetaUser.vue @@ -0,0 +1,239 @@ +