Compare commits
2 Commits
chore/dock
...
fix/propos
| Author | SHA1 | Date | |
|---|---|---|---|
| add688602a | |||
| 3f3c717185 |
@@ -7,8 +7,7 @@ WORKDIR /app
|
|||||||
ENV npm_config_update_notifier=false \
|
ENV npm_config_update_notifier=false \
|
||||||
npm_config_audit=false \
|
npm_config_audit=false \
|
||||||
npm_config_fund=false \
|
npm_config_fund=false \
|
||||||
npm_config_progress=false \
|
npm_config_progress=false
|
||||||
ASTRO_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
# (Optionnel mais propre) git + certificats
|
# (Optionnel mais propre) git + certificats
|
||||||
RUN apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true update \
|
RUN apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true update \
|
||||||
@@ -17,8 +16,7 @@ RUN apt-get -o Acquire::Retries=5 -o Acquire::ForceIPv4=true update \
|
|||||||
|
|
||||||
# Déps d’abord (cache Docker)
|
# Déps d’abord (cache Docker)
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
RUN npm ci --no-audit --no-fund
|
||||||
npm ci --no-audit --no-fund
|
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -416,21 +416,25 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
groups,
|
groups,
|
||||||
raw: text,
|
raw: text,
|
||||||
};
|
};
|
||||||
})().catch(() => ({
|
})().catch((err) => {
|
||||||
ok: false,
|
console.warn("[proposer] whoami fetch failed", err);
|
||||||
user: "",
|
return {
|
||||||
name: "",
|
ok: false,
|
||||||
email: "",
|
user: "",
|
||||||
groups: [],
|
name: "",
|
||||||
raw: "",
|
email: "",
|
||||||
}));
|
groups: [],
|
||||||
|
raw: "",
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return _authInfoPromise;
|
return _authInfoPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Promise unique : est-on editor ?
|
// Promise unique : est-on editor ?
|
||||||
|
// ⚠️ On reste fail-closed, mais NON destructif (on ne supprime pas sur erreur réseau)
|
||||||
const isEditorP = giteaReady
|
const isEditorP = giteaReady
|
||||||
? getAuthInfo().then((info) => info.groups.includes(PROPOSE_REQUIRED_GROUP)).catch(() => false)
|
? getAuthInfo().then((info) => info.groups.includes(PROPOSE_REQUIRED_GROUP))
|
||||||
: Promise.resolve(false);
|
: Promise.resolve(false);
|
||||||
|
|
||||||
const quoteBlock = (s) =>
|
const quoteBlock = (s) =>
|
||||||
@@ -501,6 +505,24 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
// ==========================
|
// ==========================
|
||||||
const paras = Array.from(document.querySelectorAll('.reading p[id^="p-"]'));
|
const paras = Array.from(document.querySelectorAll('.reading p[id^="p-"]'));
|
||||||
|
|
||||||
|
// Petit helper : fail-closed mais réversible (hide ≠ remove)
|
||||||
|
function hidePropose(el) {
|
||||||
|
try {
|
||||||
|
el.hidden = true;
|
||||||
|
el.style.display = "none";
|
||||||
|
el.setAttribute("aria-hidden", "true");
|
||||||
|
el.setAttribute("tabindex", "-1");
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
function showPropose(el) {
|
||||||
|
try {
|
||||||
|
el.hidden = false;
|
||||||
|
el.style.display = "";
|
||||||
|
el.removeAttribute("aria-hidden");
|
||||||
|
el.removeAttribute("tabindex");
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
for (const p of paras) {
|
for (const p of paras) {
|
||||||
if (p.querySelector(".para-tools")) continue;
|
if (p.querySelector(".para-tools")) continue;
|
||||||
|
|
||||||
@@ -547,16 +569,16 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
propose.textContent = "Proposer";
|
propose.textContent = "Proposer";
|
||||||
propose.setAttribute("aria-label", "Proposer une correction sur Gitea");
|
propose.setAttribute("aria-label", "Proposer une correction sur Gitea");
|
||||||
|
|
||||||
// ✅ fail-closed DUR : inline-style (ne peut pas être overridé par ton CSS)
|
// ✅ fail-closed (mais NON destructif)
|
||||||
propose.style.display = "none";
|
|
||||||
propose.dataset.requiresGroup = PROPOSE_REQUIRED_GROUP;
|
propose.dataset.requiresGroup = PROPOSE_REQUIRED_GROUP;
|
||||||
|
hidePropose(propose);
|
||||||
|
|
||||||
const raw = (p.textContent || "").trim().replace(/\s+/g, " ");
|
const raw = (p.textContent || "").trim().replace(/\s+/g, " ");
|
||||||
const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
|
const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
|
||||||
|
|
||||||
const issueUrl = buildIssueURL(p.id, raw, excerpt);
|
const issueUrl = buildIssueURL(p.id, raw, excerpt);
|
||||||
|
|
||||||
// Lien fallback (si JS casse totalement)
|
// Lien fallback (si JS modal casse totalement)
|
||||||
propose.href = issueUrl;
|
propose.href = issueUrl;
|
||||||
|
|
||||||
// ✅ Marqueurs pour ProposeModal (interception 2 étapes)
|
// ✅ Marqueurs pour ProposeModal (interception 2 étapes)
|
||||||
@@ -600,16 +622,18 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Après insertion : on autorise Proposer seulement si groupe editors
|
// ✅ Après insertion : on autorise Proposer seulement si groupe editors
|
||||||
|
// - ok=false => remove (pas d’UI “Proposer” pour les non-éditeurs)
|
||||||
|
// - erreur fetch => on garde HIDDEN (non destructif) ; un reload pourra réussir
|
||||||
if (giteaReady) {
|
if (giteaReady) {
|
||||||
isEditorP.then((ok) => {
|
isEditorP.then((ok) => {
|
||||||
const els = document.querySelectorAll(".para-propose");
|
const els = document.querySelectorAll(".para-propose");
|
||||||
for (const el of els) {
|
for (const el of els) {
|
||||||
if (ok) el.style.display = "";
|
if (ok) showPropose(el);
|
||||||
else el.remove();
|
else el.remove();
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch((err) => {
|
||||||
// fail-closed
|
console.warn("[proposer] gate failed; keeping Proposer hidden", err);
|
||||||
document.querySelectorAll(".para-propose").forEach((el) => el.remove());
|
document.querySelectorAll(".para-propose").forEach((el) => hidePropose(el));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user