Skip to content

Commit

Permalink
feat: label removed rule as invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
ntnyq committed Oct 17, 2024
1 parent 27654d5 commit 6f95d8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
14 changes: 8 additions & 6 deletions app/components/RuleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function capitalize(str?: string) {
<div v-if="shown" max-h="50vh">
<div flex="~ items-center gap-2" p3>
<NuxtLink
v-if="!rule.invalid"
btn-action-sm
:to="rule.docs?.url" target="_blank" rel="noopener noreferrer"
title="Docs"
Expand Down Expand Up @@ -115,23 +116,24 @@ function capitalize(str?: string) {
<div
:class="[
rule.deprecated ? 'line-through' : '',
rule.invalid ? 'text-red' : '',
gridView ? 'op50 text-sm' : 'op75 ws-nowrap of-hidden text-ellipsis line-clamp-1',
]"
>
{{ capitalize(rule.docs?.description) }}
{{ rule.invalid ? 'Invalid rule has no description' : capitalize(rule.docs?.description) }}
</div>
<div v-if="!gridView && rule.deprecated" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
DEPRECATED
<div v-if="!gridView && (rule.invalid || rule.deprecated)" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
{{ rule.invalid ? 'INVALID' : 'DEPRECATED' }}
</div>
</div>
<div
v-if="gridView && (rule.deprecated || rule.fixable || rule.docs?.recommended)"
v-if="gridView && (rule.invalid || rule.deprecated || rule.fixable || rule.docs?.recommended)"
flex flex-auto flex-col items-start justify-end
>
<div flex="~ gap-2" mt1>
<div v-if="rule.deprecated" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
DEPRECATED
<div v-if="rule.invalid || rule.deprecated" border="~ red/25 rounded" bg-red:5 px1 text-xs text-red>
{{ rule.invalid ? 'INVALID' : 'DEPRECATED' }}
</div>
<div
v-if="rule.docs?.recommended"
Expand Down
7 changes: 5 additions & 2 deletions app/composables/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ export function ensureDataFetch() {

export const payload = computed(() => Object.freeze(resolvePayload(data.value!)))

export function getRuleFromName(name: string): RuleInfo | undefined {
return payload.value.rules[name]
export function getRuleFromName(name: string): RuleInfo {
return payload.value.rules[name] || {
name,
invalid: true,
}
}

export function getRuleStates(name: string): RuleConfigStates | undefined {
Expand Down
4 changes: 4 additions & 0 deletions shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export interface PayloadMeta {
export interface RuleInfo extends RuleMetaData<any, any> {
name: string
plugin: string
/**
* The rule may be removed
*/
invalid?: boolean
}

export interface FiltersConfigsPage {
Expand Down

0 comments on commit 6f95d8c

Please sign in to comment.