Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you require adaptations to comply with your country's regulations, please ope
[![Donate](https://img.shields.io/badge/Donate-Buy%20me%20a%20coffee-yellow.svg)](https://www.buymeacoffee.com/benjaminaimard)

]]></description>
<version>3.4.7</version>
<version>3.4.8</version>
<licence>agpl</licence>
<author mail="benjamin@cybercorp.fr" homepage="https://github.com/baimard">Benjamin AIMARD</author>
<namespace>Gestion</namespace>
Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
['name' => 'view#produit', 'url' => '/produit', 'verb' => 'GET'],
['name' => 'configuration#config', 'url' => '/config', 'verb' => 'GET'],
['name' => 'configuration#isConfig', 'url' => '/isconfig', 'verb' => 'GET'],
['name' => 'announcement#acknowledge', 'url' => '/announcements/acknowledge', 'verb' => 'POST'],
['name' => 'view#statistique', 'url' => '/statistique', 'verb' => 'GET'],
['name' => 'view#legalnotice', 'url' => '/legalnotice', 'verb' => 'GET'],
['name' => 'view#france', 'url' => '/legalnotice/france', 'verb' => 'GET'],
Expand Down
2 changes: 2 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,8 @@ button.electronic-invoice-help:focus-visible {
.gestion-workspace-dialog h2 { font-size: 22px; line-height: 1.4; margin: 0 0 16px; }
.gestion-workspace-dialog p { margin-block: 12px; line-height: 1.6; }
.gestion-workspace-dialog button { min-height: 44px; }
.gestion-announcement-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.gestion-announcement-actions .button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px; border-radius: var(--border-radius-element, 8px); text-decoration: none; }
.gestion-history { list-style: none; padding: 0; }
.gestion-history li { padding: 16px 0; border-bottom: 1px solid var(--color-border); overflow-wrap: anywhere; }
.gestion-history li p { margin: 4px 0; color: var(--color-text-maxcontrast); }
Expand Down
21 changes: 21 additions & 0 deletions documentation/source/developer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,27 @@ PR fonctionnelle.
Version et publication
----------------------

Annonce à tous les utilisateurs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

La version ``3.4.8`` prépare un appel à bêta-testeurs pour l'application Qonto,
en vue d'une intégration complète avec Gestion. L'annonce apparaît à l'ouverture
de Gestion dès cette version, pour chaque utilisateur authentifié, même lorsque
plusieurs personnes partagent la même société. Le bouton de participation ouvre
le logiciel de messagerie ; Gestion n'envoie pas d'e-mail automatiquement.

Le déclencheur est ``AnnouncementService::VERSION``. Pour une future annonce,
choisissez une nouvelle version, adaptez le texte traduisible dans
``templates/content/changelog.php`` et publiez une version de Gestion au moins
égale au déclencheur. Un simple correctif ultérieur ne réaffiche pas l'annonce
aux utilisateurs qui l'ont déjà fermée. Aucun tag ni aucune publication du store
n'est nécessaire pour préparer ces changements sur ``master``.

L'acquittement est enregistré dans les préférences de l'utilisateur seulement
après fermeture et confirmation du serveur, par une requête authentifiée avec
protection CSRF. Recharger la page sans fermer le message ne le marque pas comme
lu. Ce mécanisme est distinct de l'ancien champ ``changelog`` des sociétés.

La source de vérité de la version est ``appinfo/info.xml``. L'interface et la
documentation Sphinx lisent cette valeur automatiquement. Lors d'une
publication, vérifiez également les métadonnées du paquet et le tag Git.
Expand Down
4 changes: 4 additions & 0 deletions l10n/fr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
OC.L10N.register(
"gestion",
{
"Qonto application: beta testers wanted" : "Application Qonto : recherche de bêta-testeurs",
"I am looking for beta testers for the Qonto application, with the aim of fully integrating it with Gestion." : "Je recherche des bêta-testeurs pour l’application Qonto, en vue de son intégration complète avec Gestion.",
"Your feedback will help shape the integration and test real-world workflows. If you would like to take part, contact me and tell me how you use Qonto and Gestion." : "Vos retours aideront à concevoir cette intégration et à la tester en conditions réelles. Pour participer, contactez-moi en précisant votre utilisation de Qonto et de Gestion.",
"Join the beta testing" : "Participer aux bêta-tests",
"Last name" : "Nom",
"First name" : "Prénom",
"Limited company" : "Siret",
Expand Down
5 changes: 5 additions & 0 deletions l10n/fr.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ "translations": {
"Qonto application: beta testers wanted" : "Application Qonto : recherche de bêta-testeurs",
"I am looking for beta testers for the Qonto application, with the aim of fully integrating it with Gestion." : "Je recherche des bêta-testeurs pour l’application Qonto, en vue de son intégration complète avec Gestion.",
"Your feedback will help shape the integration and test real-world workflows. If you would like to take part, contact me and tell me how you use Qonto and Gestion." : "Vos retours aideront à concevoir cette intégration et à la tester en conditions réelles. Pour participer, contactez-moi en précisant votre utilisation de Qonto et de Gestion.",
"Join the beta testing" : "Participer aux bêta-tests",

"Last name" : "Nom",
"First name" : "Prénom",
"Limited company" : "Siret",
Expand Down
27 changes: 27 additions & 0 deletions lib/Controller/AnnouncementController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace OCA\Gestion\Controller;

use OCA\Gestion\Service\AnnouncementService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\IRequest;

class AnnouncementController extends Controller {
public function __construct($AppName, IRequest $request, private AnnouncementService $announcementService) {
parent::__construct($AppName, $request);
}

/**
* @NoAdminRequired
*/
#[NoAdminRequired]
public function acknowledge(string $version): DataResponse {
try {
$this->announcementService->acknowledge($version);
return new DataResponse(['acknowledged' => true]);
} catch (\InvalidArgumentException $e) {
return new DataResponse(['message' => $e->getMessage()], 400);
}
}
}
32 changes: 32 additions & 0 deletions lib/Service/AnnouncementService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace OCA\Gestion\Service;

use OCP\App\IAppManager;
use OCP\IConfig;

class AnnouncementService {
// Change this version only when a new announcement must be shown to everyone.
public const VERSION = '3.4.8';
private const SEEN_KEY = 'announcement_seen';

public function __construct(private IConfig $config, private IAppManager $appManager, private $UserId) {
}

public function pendingVersion(): string {
if (!$this->UserId || version_compare($this->appManager->getAppVersion('gestion'), self::VERSION, '<')) {
return '';
}
$seen = $this->config->getUserValue($this->UserId, 'gestion', self::SEEN_KEY, '');
return $seen !== '' && version_compare($seen, self::VERSION, '>=') ? '' : self::VERSION;
}

public function acknowledge(string $version): void {
if (!$this->UserId || $version !== self::VERSION || version_compare($this->appManager->getAppVersion('gestion'), self::VERSION, '<')) {
throw new \InvalidArgumentException('Invalid announcement version.');
}
$seen = $this->config->getUserValue($this->UserId, 'gestion', self::SEEN_KEY, '');
if ($seen === '' || version_compare($seen, $version, '<')) {
$this->config->setUserValue($this->UserId, 'gestion', self::SEEN_KEY, $version);
}
}
}
4 changes: 3 additions & 1 deletion lib/Service/TemplateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public function __construct(
DataService $dataService,
FileService $fileService,
NavigationService $navigationService,
ContentSecurityPolicy $csp
ContentSecurityPolicy $csp,
private AnnouncementService $announcementService
) {
$this->userId = $UserId;
$this->appManager = $appManager;
Expand All @@ -36,6 +37,7 @@ private function baseParams(): array {
return [
'path' => $this->userId,
'appVersion' => $this->appManager->getAppVersion('gestion'),
'announcementVersion' => $this->announcementService->pendingVersion(),
'url' => $this->navigationService->getNavigationLink(),
'CompaniesList' => $this->companyService->getCompaniesList(),
'CurrentCompany' => $this->companyService->getCurrentCompany(),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gestion",
"version": "3.4.7",
"version": "3.4.8",
"description": "Application pour gérer votre micro entreprise, client, facture, devis",
"author": "Benjamin AIMARD",
"contributors": [
Expand Down
26 changes: 26 additions & 0 deletions src/js/modules/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ function applyLockedState() {
}

document.addEventListener('DOMContentLoaded', () => {
const announcement = document.getElementById('gestion-announcement');
if (announcement) {
const close = announcement.querySelector('[data-dismiss-announcement]');
const dismiss = async () => {
if (close.disabled) return;
close.disabled = true;
try {
await request('/announcements/acknowledge', {version: announcement.dataset.announcementVersion});
announcement.close();
announcement.remove();
} catch {
close.disabled = false;
showError(t('gestion', 'The operation could not be completed.'));
}
};
close.addEventListener('click', dismiss);
announcement.addEventListener('cancel', event => { event.preventDefault(); dismiss(); });
announcement.addEventListener('keydown', event => {
if (event.key === 'Escape') {
event.preventDefault();
event.stopPropagation();
dismiss();
}
});
announcement.showModal();
}
applyLockedState();
// Keep action menus outside table clipping, including on the final row.
let openActions = null;
Expand Down
13 changes: 13 additions & 0 deletions templates/content/changelog.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
<?php if (!empty($_['announcementVersion'])): ?>
<dialog id="gestion-announcement" class="gestion-workspace-dialog" data-announcement-version="<?php p($_['announcementVersion']); ?>" aria-labelledby="gestion-announcement-title" aria-describedby="gestion-announcement-description">
<h2 id="gestion-announcement-title"><?php p($l->t('Qonto application: beta testers wanted')); ?></h2>
<div id="gestion-announcement-description">
<p><?php p($l->t('I am looking for beta testers for the Qonto application, with the aim of fully integrating it with Gestion.')); ?></p>
<p><?php p($l->t('Your feedback will help shape the integration and test real-world workflows. If you would like to take part, contact me and tell me how you use Qonto and Gestion.')); ?></p>
</div>
<div class="gestion-announcement-actions">
<a class="button primary" href="mailto:contact@cybercorp.fr?subject=Gestion%20-%20Qonto%20beta%20testing"><?php p($l->t('Join the beta testing')); ?></a>
<button type="button" data-dismiss-announcement autofocus><?php p($l->t('Close')); ?></button>
</div>
</dialog>
<?php endif; ?>
<div style="display: none;" id="modalConfig" class="modal">
<div class="modal-content">
<span class="modalClose">&times;</span>
Expand Down
85 changes: 85 additions & 0 deletions tests/Browser/announcements.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Opt-in on a disposable Nextcloud instance, with two ordinary test accounts.
const { chromium } = require('playwright');
const assert = require('node:assert/strict');

(async () => {
const base = process.env.NEXTCLOUD_TEST_URL || 'http://127.0.0.1:8080';
const alice = process.env.NEXTCLOUD_TEST_USER;
const bob = process.env.NEXTCLOUD_SECOND_TEST_USER;
const password = process.env.NEXTCLOUD_TEST_PASSWORD;
const bobEmail = process.env.NEXTCLOUD_SECOND_TEST_EMAIL;
assert.ok(alice && bob && password && bobEmail, 'Provide two fresh disposable accounts, their shared test password and the second account email.');
const browser = await chromium.launch({ executablePath: process.env.CHROMIUM_PATH || '/usr/bin/chromium', args: ['--no-sandbox', '--disable-dev-shm-usage'] });
const errors = [];
const login = async (context, user) => {
const page = await context.newPage();
page.on('pageerror', error => errors.push(error.message));
await page.goto(base + '/index.php/apps/gestion/config');
await page.locator('[name=user]').fill(user);
await page.locator('[name=password]').fill(password);
await page.locator('button[type=submit]').click();
await page.waitForURL('**/apps/gestion/**');
return page;
};
const api = (page, path, data, token = true, method = 'POST') => page.evaluate(async ({path, data, token, method}) => {
const response = await fetch(OC.generateUrl('/apps/gestion' + path), {
method, headers: {'Content-Type': 'application/json', ...(token ? {requesttoken: OC.requestToken} : {})},
body: JSON.stringify(data),
});
return {status: response.status, data: await response.json().catch(() => null)};
}, {path, data, token, method});
const centered = async page => {
const b = await page.locator('#gestion-announcement').evaluate(el => {
const r = el.getBoundingClientRect();
return {x:r.x,y:r.y,w:r.width,h:r.height,vw:innerWidth,vh:innerHeight,overflow:el.scrollWidth > el.clientWidth};
});
assert.ok(Math.abs(b.x+b.w/2-b.vw/2)<2 && Math.abs(b.y+b.h/2-b.vh/2)<2, JSON.stringify(b));
assert.equal(b.overflow,false);
};
try {
const aContext = await browser.newContext({viewport:{width:1440,height:900}});
const a = await login(aContext, alice);
await a.locator('#gestion-announcement[open]').waitFor();
assert.match(await a.locator('#gestion-announcement').innerText(), /Qonto/);
assert.match(await a.locator('#gestion-announcement a').getAttribute('href'), /^mailto:contact@cybercorp\.fr\?/);
await centered(a);
for (const viewport of [{width:390,height:844},{width:844,height:390},{width:320,height:568}]) {
await a.setViewportSize(viewport);
await centered(a);
}
await a.reload();
await a.locator('#gestion-announcement[open]').waitFor();
if (process.env.NEXTCLOUD_TEST_SCREENSHOT) await a.screenshot({path:process.env.NEXTCLOUD_TEST_SCREENSHOT});
assert.equal((await api(a, '/announcements/acknowledge', {version:'3.4.9'})).status,400);
assert.equal((await api(a, '/announcements/acknowledge', {version:'3.4.8'},false)).status,412);
const company = await a.locator('#CurrentCompany-select').inputValue();
const share = await api(a, '/addShareUser', {email:bobEmail});
assert.equal(share.data.status,'success',JSON.stringify(share));
await a.route('**/announcements/acknowledge', route => route.fulfill({status:503,contentType:'application/json',body:'{}'}));
await a.locator('[data-dismiss-announcement]').click();
await a.waitForFunction(() => !document.querySelector('[data-dismiss-announcement]').disabled);
assert.ok(await a.locator('#gestion-announcement[open]').isVisible());
await a.unroute('**/announcements/acknowledge');
await a.locator('[data-dismiss-announcement]').click();
await a.locator('#gestion-announcement').waitFor({state:'detached'});
await a.reload();
assert.equal(await a.locator('#gestion-announcement').count(),0);
const bContext = await browser.newContext({viewport:{width:390,height:844}});
const b = await login(bContext,bob);
await b.locator('#gestion-announcement[open]').waitFor();
assert.equal(await b.locator('#CurrentCompany-select').inputValue(),company, 'Both users access the same company');
await b.keyboard.press('Escape');
await b.locator('#gestion-announcement').waitFor({state:'detached'});
await b.reload();
assert.equal(await b.locator('#gestion-announcement').count(),0);
const fresh = await browser.newContext();
const again = await login(fresh,alice);
assert.equal(await again.locator('#gestion-announcement').count(),0,'Acknowledgement survives a new browser session');
const anonymous = await browser.newContext();
const unauthenticated = await anonymous.request.post(base+'/index.php/apps/gestion/announcements/acknowledge',{data:{version:'3.4.8'},maxRedirects:0});
assert.ok([303,401,412].includes(unauthenticated.status()),String(unauthenticated.status()));
assert.equal((await api(a,'/deleteCompany',{},true,'DELETE')).status,200);
assert.deepEqual(errors,[]);
console.log('Announcement checks passed: two ordinary users sharing a company, independent acknowledgement, reload without dismissal, persistence, invalid version, CSRF/login required, retry after failure, Close/Escape, desktop/mobile centering. No email sent.');
} finally { await browser.close(); }
})().catch(error => { console.error(error); process.exitCode = 1; });
2 changes: 2 additions & 0 deletions tests/Browser/contact-import.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const dismissAnnouncement = require('./dismiss-announcement.cjs');
// Run against a disposable instance with a standard user and an accessible fixture contact.
const { chromium } = require('playwright');
const assert = require('node:assert/strict');
Expand All @@ -21,6 +22,7 @@ const assert = require('node:assert/strict');
await page.locator('[name=password]').fill(password);
await page.getByRole('button', { name: 'Log in', exact: true }).click();
await page.waitForURL('**/apps/gestion/**');
await dismissAnnouncement(page);
const profile = await page.evaluate(async () => (await (await fetch('/ocs/v2.php/cloud/user?format=json', { headers: { 'OCS-APIRequest': 'true', requesttoken: OC.requestToken } })).json()).ocs.data);
assert.ok(Array.isArray(profile.groups) && !profile.groups.includes('admin'), 'This regression must run as a non-administrator.');
const api = (path, data, method = 'POST', invalidToken = false) => page.evaluate(async ({ path, data, method, invalidToken }) => {
Expand Down
9 changes: 9 additions & 0 deletions tests/Browser/dismiss-announcement.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Unrelated UI scenarios dismiss the real announcement before exercising their feature.
module.exports = async function dismissAnnouncement(page) {
await page.waitForLoadState('domcontentloaded');
const dialog = page.locator('#gestion-announcement');
if (await dialog.count()) {
await dialog.locator('[data-dismiss-announcement]').click();
await dialog.waitFor({state: 'detached'});
}
};
2 changes: 2 additions & 0 deletions tests/Browser/documents.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const dismissAnnouncement = require('./dismiss-announcement.cjs');
// Opt-in on a disposable instance. Creates a company, customer, product, quote and invoice.
const { chromium } = require('playwright');
const assert = require('node:assert/strict');
Expand Down Expand Up @@ -26,6 +27,7 @@ const fs = require('node:fs');
await page.locator('[name=password]').fill(process.env.NEXTCLOUD_TEST_PASSWORD);
await page.getByRole('button', { name: 'Log in', exact: true }).click();
await page.waitForURL('**/apps/gestion/**');
await dismissAnnouncement(page);
const api = (path, data, method = 'POST') => page.evaluate(async ({ path, data, method }) => {
const response = await fetch(OC.generateUrl('/apps/gestion' + path), {
method, headers: { 'Content-Type': 'application/json', requesttoken: OC.requestToken },
Expand Down
Loading
Loading