Repository navigation
feat: surfacing flags in modview #8240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
+3,245
−1,127
Draft
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
393aca3
flag rules backend model
aecsocket 4bed0f5
project flag routes
aecsocket 6873520
add rule editor frontend and rhai eval
aecsocket 2f29c7e
wip: project flags can scan files for patterns
aecsocket 799d773
persist scan patterns for rules
aecsocket 600a114
more flag context
aecsocket 8b68be6
listing and starting runs
aecsocket 8907718
wip: consumer task for reading scan reqs
aecsocket 660fc91
persist flag run results in db
aecsocket 6b81dc1
run rule result persistence
aecsocket 2676af9
route to fetch project flags
aecsocket 35a2845
Merge branch 'main' into boris/dev-1493-flag-rules-backend
aecsocket 05ef0eb
list runs/delete runs but keep active flags
aecsocket 5d4347d
Merge branch 'main' into boris/dev-1493-flag-rules-backend
aecsocket c97cefb
allow kafka scans to not have a run_id
aecsocket 7961dc1
sqlx prepare
aecsocket 13efdcd
feat: surface project flags in modview
tdgao d28b4db
pnpm prepr
tdgao 6d34d54
track how many scan jobs we have + how many kafka consumers
aecsocket 62ee613
sqlx prepare
aecsocket 927d974
default auto_resolve on add_gallery_images issue targets
clrxbl f1e1c63
Merge branch 'main' into boris/dev-1493-flag-rules-backend
aecsocket 6411b67
scan size limits with env var
aecsocket cff217f
strip out run application
aecsocket 6048e29
use a pending jobs ledger
aecsocket 0b873b4
prepr
aecsocket 811116b
disable source map uploads
aecsocket 77b3634
address comments
aecsocket d82d20e
Merge branch 'boris/dev-1493-flag-rules-backend' into truman/surfacin…
tdgao 524537f
remove mock data
tdgao 84c3aee
feat: better flag rule run view and restructure files
tdgao 888ed51
feat: better rules page
tdgao 1481a5f
Merge branch 'main' into truman/surfacing-flags-in-modview
tdgao e2b2df2
fix: merge
tdgao b121073
feat: better run is scanning badge
tdgao 09cb86b
feat: update scan badge again
tdgao de52d71
feat: flagged rules count, show schema by project id, better search p…
tdgao 5ac199f
feat: better flag card
tdgao 86014e2
feat: move errors to be error notifications, and add TODO for backend…
tdgao 73c9c8d
polish
tdgao acc3ed3
avoid querying full queue for now
tdgao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
apps/frontend/src/components/project-review/flag-list/flag-card.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <template> | ||
| <article | ||
| class="flex min-w-0 flex-col gap-2 rounded-xl border border-solid border-surface-3 bg-surface-2 p-2.5 text-sm" | ||
| > | ||
| <div class="flex items-center gap-2"> | ||
| <h3 class="m-0 flex min-w-0 flex-1 items-center gap-1.5 text-sm font-medium text-contrast"> | ||
| <TagCategoryFlagIcon class="size-4 shrink-0 text-purple" aria-hidden="true" /> | ||
| <span class="min-w-0 break-words">{{ flag.name || flag.key }}</span> | ||
| </h3> | ||
| <ButtonLink | ||
| v-tooltip="'View flag rule'" | ||
| type="quiet" | ||
| size="xs" | ||
| class="-my-1 -mr-1 !size-7 shrink-0 !rounded-full !p-0" | ||
| href="/moderation/project-flag" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| aria-label="View flag rule" | ||
| > | ||
| <ExternalIcon class="!size-3.5 !min-h-0 !min-w-0" aria-hidden="true" /> | ||
| </ButtonLink> | ||
| </div> | ||
| <p v-if="flag.reason" class="m-0 whitespace-pre-wrap break-words text-primary"> | ||
| {{ flag.reason }} | ||
| </p> | ||
| <div v-if="flag.location" class="flex"> | ||
| <Button | ||
| size="xs" | ||
| type="quiet" | ||
| class="!h-auto !min-h-0 !rounded-full !bg-surface-3 !px-2.5 !py-1 !text-xs !font-medium hover:!bg-surface-4" | ||
| @click="emit('reveal', flag.location.review_panel_key)" | ||
| > | ||
| <PanelTopIcon class="!size-3.5 shrink-0" aria-hidden="true" /> | ||
| {{ locationTitle || flag.location.review_panel_key }} | ||
| </Button> | ||
| </div> | ||
| </article> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import type { ProjectFlag } from '@modrinth/api-client' | ||
| import { ExternalIcon, PanelTopIcon, TagCategoryFlagIcon } from '@modrinth/assets' | ||
| import { Button, ButtonLink } from '@modrinth/ui' | ||
|
|
||
| defineProps<{ flag: ProjectFlag; locationTitle?: string }>() | ||
| const emit = defineEmits<{ reveal: [key: string] }>() | ||
| </script> | ||
31 changes: 31 additions & 0 deletions
31
apps/frontend/src/components/project-review/flag-list/index.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <template> | ||
| <div class="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto"> | ||
| <FlagCard | ||
| v-for="flag in flags" | ||
| :key="flag.key" | ||
| :flag="flag" | ||
| :location-title="locationTitle(flag.location?.review_panel_key)" | ||
| @reveal="revealPanel" | ||
| /> | ||
| <p v-if="isPending" class="m-0 text-sm text-secondary">Loading flags...</p> | ||
| <p v-else-if="isError" class="m-0 text-sm text-red">Failed to load project flags.</p> | ||
| <p v-else-if="!flags.length" class="m-0 text-sm text-secondary"> | ||
| No flags on this project. | ||
| </p> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { injectReviewFlags } from '~/providers/project-review/review-flags' | ||
| import { injectReviewPanels } from '~/providers/project-review/review-panels' | ||
|
|
||
| import { injectReviewContext } from '../review-panel/context' | ||
| import FlagCard from './flag-card.vue' | ||
|
|
||
| const { flags, isPending, isError } = injectReviewFlags() | ||
| const panels = injectReviewPanels() | ||
| const { revealPanel } = injectReviewContext() | ||
| function locationTitle(key: string | undefined) { | ||
| return key ? panels.resolve({ kind: 'panel', key })?.panel.title : undefined | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
apps/frontend/src/components/project-review/review-panel/flags-count-badge.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <template> | ||
| <span | ||
| v-if="flags.length" | ||
| class="pointer-events-none flex shrink-0 items-center gap-0.5 text-xs font-medium leading-none text-purple" | ||
| :aria-label="`${flags.length} flags`" | ||
| > | ||
| <TagCategoryFlagIcon class="size-3.5 shrink-0 text-purple" aria-hidden="true" /> | ||
| <span aria-hidden="true">{{ flags.length }}</span> | ||
| </span> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { TagCategoryFlagIcon } from '@modrinth/assets' | ||
| import { computed } from 'vue' | ||
|
|
||
| import { injectReviewFlags } from '~/providers/project-review/review-flags' | ||
|
|
||
| const props = defineProps<{ panelKey?: string }>() | ||
| const reviewFlags = injectReviewFlags(null) | ||
| const flags = computed(() => (props.panelKey ? (reviewFlags?.forPanel(props.panelKey) ?? []) : [])) | ||
| </script> |
56 changes: 56 additions & 0 deletions
56
apps/frontend/src/components/project-review/review-panel/flags.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <template> | ||
| <div v-if="flags.length" class="flex flex-wrap gap-1"> | ||
| <Tooltip | ||
| v-for="flag in flags" | ||
| :key="flag.key" | ||
| interactive | ||
| panel-class="w-[min(20rem,calc(100vw-1rem))] !border-0 !bg-transparent !p-0 font-normal !shadow-none [&_.tooltip-arrow]:!border-surface-3 [&_.tooltip-arrow]:!bg-surface-2" | ||
| > | ||
| <span class="inline-flex items-center gap-1.5 text-sm font-medium text-contrast"> | ||
| <TagCategoryFlagIcon class="size-4 shrink-0 text-purple" aria-hidden="true" /> | ||
| {{ flag.name || flag.key }} | ||
| </span> | ||
| <template #popper> | ||
| <FlagCard | ||
| :flag="flag" | ||
| :location-title="locationTitle(flag.location?.review_panel_key)" | ||
| @reveal="reviewContext.revealPanel" | ||
| @pointerenter="setPreviewHovered(true)" | ||
| @pointerleave="setPreviewHovered(false)" | ||
| @pointerdown.stop | ||
| /> | ||
| </template> | ||
| </Tooltip> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { TagCategoryFlagIcon } from '@modrinth/assets' | ||
| import { Tooltip } from '@modrinth/ui' | ||
| import { computed, onBeforeUnmount } from 'vue' | ||
|
|
||
| import { injectReviewFlags } from '~/providers/project-review/review-flags' | ||
| import { injectReviewPanels } from '~/providers/project-review/review-panels' | ||
|
|
||
| import FlagCard from '../flag-list/flag-card.vue' | ||
| import { injectReviewContext } from './context' | ||
|
|
||
| const props = defineProps<{ panelKey?: string; panelId: string }>() | ||
| const reviewFlags = injectReviewFlags(null) | ||
| const panels = injectReviewPanels() | ||
| const reviewContext = injectReviewContext() | ||
| const flags = computed(() => (props.panelKey ? (reviewFlags?.forPanel(props.panelKey) ?? []) : [])) | ||
| let previewHovered = false | ||
|
|
||
| function locationTitle(key: string | undefined) { | ||
| return key ? panels.resolve({ kind: 'panel', key })?.panel.title : undefined | ||
| } | ||
|
|
||
| function setPreviewHovered(hovered: boolean) { | ||
| if (previewHovered === hovered) return | ||
| previewHovered = hovered | ||
| reviewContext.setDropdownOpen(props.panelId, hovered) | ||
| } | ||
|
|
||
| onBeforeUnmount(() => setPreviewHovered(false)) | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/frontend/src/components/project-review/review-panel/re-review-findings-count-badge.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.