feat: one „Umowy” entry for Arbiter, Lexicon and Scribe (issue #53)
Decision 1 of 18.11: the chat is the only screen for contracts. Lexicon and Scribe lose their consoles and become service modules (seed + idempotent revision 0019, as Arbiter in 0017). The sidebar and the catalogue show the three as ONE entry, „Umowy”, which opens the chat (#/umowy), for whoever may use at least one of them; they stay in the launcher for the chat to call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Lexicon and Scribe become service modules: the chat is the only screen for contracts.
|
||||
|
||||
Decision 1 of 18.11 (issue #53): Arbiter, Lexicon and Scribe are one module „Umowy” under the chat;
|
||||
the logic stays in each module and the chat calls it. Arbiter left the menu in `0017`; Lexicon and
|
||||
Scribe no longer have a console at all, so they leave the menu and the catalogue the same way. The
|
||||
console shows the three as one entry, „Umowy”, which opens the chat (CONTRACTS in app.js).
|
||||
|
||||
Only the seeded rows (slugs `lexicon`, `scribe`) change, and setting `in_menu` false again is a
|
||||
no-op, so this is idempotent. Downgrade puts them back in the menu. Nothing is granted.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision = "0019"
|
||||
down_revision = "0018"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
_module = sa.table("module", sa.column("slug", sa.String), sa.column("in_menu", sa.Boolean))
|
||||
_SLUGS = ("lexicon", "scribe")
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.get_bind().execute(_module.update().where(_module.c.slug.in_(_SLUGS)).values(in_menu=False))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.get_bind().execute(_module.update().where(_module.c.slug.in_(_SLUGS)).values(in_menu=True))
|
||||
@@ -135,6 +135,9 @@ FAMILY: list[dict] = [
|
||||
# (Open Color green, its CLAUDE.md). In English the tagline reads "The clause library and
|
||||
# standards". The slug is its path (/lexicon), schema, roles and MODULE_SLUG.
|
||||
"slug": "lexicon", "name": "Lexicon", "hue": "green", "glyph": "file", "sort_order": 70,
|
||||
# No console of its own (decision of 18.11, issue #53): a service the chat calls; the
|
||||
# catalogue and the menu show the three contract modules as one entry, „Umowy”.
|
||||
"in_menu": False,
|
||||
"category": "Umowy",
|
||||
"tagline": "Biblioteka klauzul.",
|
||||
"description": (
|
||||
@@ -172,6 +175,9 @@ FAMILY: list[dict] = [
|
||||
# (Open Color lime, its CLAUDE.md). In English the tagline reads "Drafting documents from
|
||||
# templates and clauses". The slug is its path (/scribe), schema, roles and MODULE_SLUG.
|
||||
"slug": "scribe", "name": "Scribe", "hue": "lime", "glyph": "file", "sort_order": 110,
|
||||
# No console of its own (decision of 18.11, issue #53): a service the chat calls; the
|
||||
# catalogue and the menu show the three contract modules as one entry, „Umowy”.
|
||||
"in_menu": False,
|
||||
"category": "Dokumenty", "status": ModuleStatus.live.value,
|
||||
"tagline": "Tworzenie dokumentów z szablonów i klauzul.",
|
||||
"description": (
|
||||
|
||||
@@ -231,9 +231,11 @@ class TestServiceModules:
|
||||
from app.seed import FAMILY
|
||||
flags = {e["slug"]: e.get("in_menu", True) for e in FAMILY}
|
||||
assert flags["galena"] is False and flags["arbiter"] is False
|
||||
# Issue #53: the three contract modules are services, shown as one „Umowy” entry.
|
||||
assert flags["lexicon"] is False and flags["scribe"] is False
|
||||
# Panorama left the platform: no longer seeded; 0018 hides an existing row.
|
||||
assert "panorama" not in flags
|
||||
assert all(flags[s] for s in flags if s not in ("galena", "arbiter"))
|
||||
assert all(flags[s] for s in flags if s not in ("galena", "arbiter", "lexicon", "scribe"))
|
||||
|
||||
def test_the_catalogue_hides_it_from_people_not_administrators(self):
|
||||
body = inspect.getsource(marketplace.browse)
|
||||
|
||||
@@ -93,3 +93,24 @@ def test_panorama_is_off_the_platform():
|
||||
assert "panorama" not in ADDED_AFTER_FIRST_SEED
|
||||
assert "panorama" not in frontdoor.MODULES
|
||||
assert b"/panorama" not in frontdoor.NOT_FOUND
|
||||
|
||||
|
||||
def test_0019_makes_lexicon_and_scribe_services_and_back(monkeypatch):
|
||||
"""Issue #53: no console of their own; the catalogue shows one „Umowy” entry for the three."""
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"revision_0019", BACKEND / "alembic" / "versions" / "0019_contracts_one_entry.py")
|
||||
rev = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(rev)
|
||||
assert (rev.revision, rev.down_revision) == ("0019", "0018")
|
||||
up, = _run(rev, monkeypatch, "upgrade")
|
||||
assert up.startswith("UPDATE module SET in_menu=false")
|
||||
assert "module.slug IN ('lexicon', 'scribe')" in up
|
||||
down, = _run(rev, monkeypatch, "downgrade")
|
||||
assert down.startswith("UPDATE module SET in_menu=true") and "('lexicon', 'scribe')" in down
|
||||
|
||||
|
||||
def test_the_console_shows_one_contracts_entry():
|
||||
console = (BACKEND.parent / "frontend" / "app.js").read_text(encoding="utf-8")
|
||||
assert "const CONTRACTS = ['arbiter', 'lexicon', 'scribe'];" in console
|
||||
assert "contractsNavItem(cur) + mods.map(modItem)" in console
|
||||
assert "d.modules.filter((m) => !CONTRACTS.includes(m.slug))" in console
|
||||
|
||||
+21
-4
@@ -407,6 +407,7 @@ const I18N = {
|
||||
'Do podpisu prawnika': 'Awaiting lawyer sign-off',
|
||||
'Wygasa w 60 dni': 'Expiring within 60 days',
|
||||
'Obowiązujące umowy': 'Contracts in force',
|
||||
'Umowy': 'Contracts',
|
||||
'Do zrobienia': 'To do',
|
||||
// The modules' own tiles (dredd-core's stats contract): the label comes in the module's language and
|
||||
// the contract has no second one, so the module's words are translated here, on Home's shelf.
|
||||
@@ -1275,7 +1276,7 @@ function renderNav() {
|
||||
+ (frame.slug === m.slug && !modCol ? '<div class="modnav" id="modNav" data-no-i18n></div>' : '');
|
||||
$('nav').innerHTML = NAV.map((n) => navItem(n, cur)).join('')
|
||||
+ (mods.length || state.launcher.some(embeddable)
|
||||
? navGroup('apps', 'Aplikacje', mods.map(modItem).join('')
|
||||
? navGroup('apps', 'Aplikacje', contractsNavItem(cur) + mods.map(modItem).join('')
|
||||
+ `<button type="button" class="nav-item nav-tune" onclick="openNavPrefs()">${svg(ICN.settings)}<span>Dostosuj listę</span></button>`, !!frame.slug)
|
||||
: '');
|
||||
$('navFoot').innerHTML = SECTIONS.filter((s) => !s.admin || isAdmin()).map((s) =>
|
||||
@@ -1350,6 +1351,7 @@ async function router() {
|
||||
else if (!seg.length) await refreshLauncher(); // Home is the launcher: always show it current
|
||||
try {
|
||||
if (!seg.length) await viewHome(C);
|
||||
else if (seg[0] === 'umowy') await viewHome(C); // „Umowy” is the chat (CONTRACTS)
|
||||
else if (seg[0] === 'marketplace' && seg[1]) await viewModule(C, seg[1]);
|
||||
else if (seg[0] === 'marketplace') await viewMarketplace(C, q);
|
||||
else if (seg[0] === 'requests') await viewMyRequests(C);
|
||||
@@ -5103,6 +5105,7 @@ const CATALOG_EN = {
|
||||
'Ocena i ankiety': 'Reviews and surveys',
|
||||
'Prawo': 'Law',
|
||||
'Umowy': 'Contracts',
|
||||
'Analiza umów, biblioteka klauzul i projekty umów — w czacie.': 'Contract analysis, the clause library and contract drafts, in the chat.',
|
||||
'Pulpit': 'Dashboard',
|
||||
// galena
|
||||
'Dysk w chmurze z pełną historią zmian w repozytoriach git.': 'A cloud drive with the full history of every change, in git repositories.',
|
||||
@@ -5158,7 +5161,7 @@ function accessChip(m) {
|
||||
}
|
||||
|
||||
function marketCard(m) {
|
||||
return `<a class="mcard" href="#/marketplace/${enc(m.slug)}">
|
||||
return `<a class="mcard" href="${m === CONTRACTS_ENTRY ? '#/umowy' : '#/marketplace/' + enc(m.slug)}">
|
||||
<div class="mtop">${moduleIcon(m, 44)}<div class="mtxt">
|
||||
<div class="mname">${dat(m.name)}</div>
|
||||
${m.category ? `<div class="tiny faint">${dat(catalogText(m.category))}</div>` : ''}</div></div>
|
||||
@@ -5170,6 +5173,11 @@ function marketCard(m) {
|
||||
async function viewMarketplace(C, q) {
|
||||
const d = await api('GET', withQuery('/marketplace', { q: q.q, category: q.category }));
|
||||
setCrumb([{ label: 'Moduły' }]);
|
||||
// One card for the three contract modules (CONTRACTS), which open as the chat, not one each.
|
||||
const umowy = hasContracts() && (!q.category || q.category === CONTRACTS_ENTRY.category)
|
||||
&& (!q.q || `Umowy
|
||||
${CONTRACTS_ENTRY.tagline}`.toLowerCase().includes(q.q.trim().toLowerCase()));
|
||||
const cards = (umowy ? [CONTRACTS_ENTRY] : []).concat(d.modules.filter((m) => !CONTRACTS.includes(m.slug)));
|
||||
|
||||
const catHref = (c) => withQuery('#/marketplace', { q: q.q, category: c });
|
||||
const contact = setting('support_contact');
|
||||
@@ -5180,8 +5188,8 @@ async function viewMarketplace(C, q) {
|
||||
<a class="chip ${!q.category ? 'on' : ''}" href="${esc(catHref(''))}">Wszystkie</a>
|
||||
${d.categories.map((c) => `<a class="chip ${q.category === c ? 'on' : ''}" href="${esc(catHref(c))}">${dat(catalogText(c))}</a>`).join('')}
|
||||
</div></div>`
|
||||
+ (d.modules.length
|
||||
? `<div class="mcards">${d.modules.map(marketCard).join('')}</div>`
|
||||
+ (cards.length
|
||||
? `<div class="mcards">${cards.map(marketCard).join('')}</div>`
|
||||
: '<div class="empty">Brak modułów.</div>')
|
||||
+ (contact ? `<div class="faint tiny" style="margin-top:16px"><span>Potrzebujesz dostępu? Kontakt:</span> ${dat(contact)}</div>` : '');
|
||||
|
||||
@@ -7562,6 +7570,15 @@ function navHidden() {
|
||||
/* A service module (`in_menu` false, e.g. Galena) is in the launcher — its links, frame and stats
|
||||
tiles work — but has no sidebar entry of its own; nor does it appear in "Customise the list". */
|
||||
const inMenu = (m) => m.in_menu !== false;
|
||||
/* Decision 1 of 18.11 (issue #53): the chat is the only screen for contracts. Arbiter, Lexicon and
|
||||
Scribe are service modules the chat calls, shown together as ONE entry, „Umowy”, which opens the
|
||||
chat — in the sidebar and in the catalogue, for whoever may use at least one of the three. */
|
||||
const CONTRACTS = ['arbiter', 'lexicon', 'scribe'];
|
||||
const CONTRACTS_ENTRY = { slug: 'umowy', name: 'Umowy', hue: 'indigo', glyph: 'shield', category: 'Umowy', status: 'live', launchable: true,
|
||||
tagline: 'Analiza umów, biblioteka klauzul i projekty umów — w czacie.' };
|
||||
const hasContracts = () => state.launcher.some((m) => CONTRACTS.includes(m.slug));
|
||||
const contractsNavItem = (cur) => (hasContracts()
|
||||
? `<a class="nav-item ${cur === '#/umowy' ? 'on' : ''}" href="#/umowy">${moduleIcon(CONTRACTS_ENTRY, 18)}<span>Umowy</span></a>` : '');
|
||||
// The open module stays listed even when hidden: its nav lives only under its own entry.
|
||||
const navModules = () => state.launcher.filter((m) => embeddable(m)
|
||||
&& (m.slug === frame.slug || (inMenu(m) && !navHidden().includes(m.slug))));
|
||||
|
||||
Reference in New Issue
Block a user