live/outdated label on rules

This commit is contained in:
aecsocket
2026-08-12 09:29:23 +00:00
parent 04d00c0ba0
commit 26e1d645b8
3 changed files with 26 additions and 3 deletions
@@ -269,9 +269,20 @@
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<h2 class="m-0 text-lg font-bold text-contrast">{{ rule.name }}</h2>
<p class="m-0 text-sm text-secondary">
Priority {{ rule.priority }} · Revision {{ rule.revision }}
</p>
<div class="mt-1 flex items-center gap-2 text-sm text-secondary">
<span>Priority {{ rule.priority }}</span>
<span aria-hidden="true">·</span>
<span
class="rounded-full border px-2 py-0.5 text-xs font-semibold"
:class="
isRuleLive(rule)
? 'border-green/60 bg-highlight-green text-green'
: 'border-orange/60 bg-highlight-orange text-orange'
"
>
{{ isRuleLive(rule) ? 'Live' : 'Outdated' }}
</span>
</div>
</div>
<div class="flex gap-2">
<Button :disabled="isScanning" @click="openEditModal(rule)">
@@ -586,6 +597,10 @@ const previewExamples = computed(() =>
}),
)
function isRuleLive(rule: Labrinth.TechReview.Internal.DelphiRule): boolean {
return rule.current_revision === undefined || rule.revision === rule.current_revision
}
function getSeverityBadgeColor(severity: Labrinth.TechReview.Internal.DelphiSeverity): string {
switch (severity) {
case 'malware':
@@ -41,6 +41,7 @@ pub struct DelphiRule {
pub rule: String,
pub priority: i32,
pub revision: i64,
pub current_revision: i64,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub created_by: Option<i64>,
@@ -218,6 +219,9 @@ pub async fn get_rules(
delphi_rule.rule,
delphi_rule.priority,
delphi_rule.revision,
(
SELECT revision FROM delphi_rule_revisions LIMIT 1
) AS "current_revision!",
delphi_rule.created_at,
delphi_rule.updated_at,
delphi_rule.created_by,
@@ -337,6 +341,7 @@ pub async fn get_rules(
rule: rule.rule,
priority: rule.priority,
revision: rule.revision,
current_revision: rule.current_revision,
created_at: rule.created_at,
updated_at: rule.updated_at,
created_by: rule.created_by,
@@ -507,6 +512,7 @@ pub async fn create_rule(
rule: rule.rule,
priority: rule.priority,
revision: rule.revision,
current_revision: rule.revision - 1,
created_at: rule.created_at,
updated_at: rule.updated_at,
created_by: rule.created_by,
@@ -587,6 +593,7 @@ pub async fn update_rule(
rule: rule.rule,
priority: rule.priority,
revision: rule.revision,
current_revision: rule.revision - 1,
created_at: rule.created_at,
updated_at: rule.updated_at,
created_by: rule.created_by,
@@ -2273,6 +2273,7 @@ export namespace Labrinth {
rule: string
priority: number
revision: number
current_revision?: number
created_at: string
updated_at: string
created_by: number | null