mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 09:04:55 +00:00
* Begin external projects moderator database frontend * add copy link button * begin project page permissions settings * MEL database backend routes * include filename in external files * wip: when uploading a version file, fetch its overrides as a list * wip: override license checks * improve FileHost ref counting * file host read capability * scan files when inserting version file * add dependency sha1 field * clean up version files * wip: attributions * update s3 file host * attribution scanning basic works * works * insert attribution info after resolving * add routes * remove dep sha1 stuff * prepr * wip: override file sources * add files_missing_attributions to versions * return extended version info + attributed at/by * hook up frontend to backend (mostly) * expose version date published * withholding version visibility * frontend work * prepr * use api-client for img upload * moar frontend * prepr * Add schema to attribution resolution and Flame project results * sqlx prepare * changes * remove feature flag, fix optional proof images * fix schema * fmt * fix deletion and file fetch * prepare * fix admonition * update frontend stuff to new schema * prepr * attribution on dependencies * fixes * sqlx prepare * fixes * routes * fix routes * Version grandfathering * prepare * wip: bulk routes * pushing what i've got rn * include link in NoPermission * change hash insert to bulk route * query flame even if entry in MEL * delete file with weird name * Prioritise putting override files in existing groups even with ExternalLicense * fix how hex bytes are handled in route * feat: coolbot moderation changes (#6215) * Update moderator checklist * move permissions stage order * Updated nagContext.versions to v3, added nag for permissions * Update permissions.vue default messages * prepr --------- Co-authored-by: coolbot100s <76798835+coolbot100s@users.noreply.github.com> * QA * prepr * should group by project * return attribution resolution correctly * updated by moderator info * Track what moderator reviewed an attribution moderation status * default deser FMA field * new version page * clean up fetching + add a couple missing features * qa items * prepr * provide moderation package stuff with DI * format? * don't redact moderated_at * move supplementary resources * Reorganize moderation messages. * Quick replies for external content permissions. * prepare * QA * allow exempting projects * Ignore Flame projects which 404 * fix ci * fix cross project attribution stuff * Fix permission error * change what files get cscanned * add more logging * QA Jun 22 * fix * idempotency * Expose route for rescanning * update blog link --------- Co-authored-by: aecsocket <aecsocket@tutanota.com> Co-authored-by: coolbot100s <76798835+coolbot100s@users.noreply.github.com> Co-authored-by: aecsocket <43144841+aecsocket@users.noreply.github.com>
105 lines
2.1 KiB
Vue
105 lines
2.1 KiB
Vue
<template>
|
|
<label :class="{ 'long-style': longStyle }" @drop.prevent="handleDrop" @dragover.prevent>
|
|
<slot />
|
|
{{ prompt }}
|
|
<input
|
|
type="file"
|
|
:multiple="multiple"
|
|
:accept="accept"
|
|
:disabled="disabled"
|
|
@change="handleChange"
|
|
/>
|
|
</label>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { fileIsValid } from '@modrinth/utils'
|
|
import { ref } from 'vue'
|
|
|
|
import { useFormatBytes } from '../../composables'
|
|
|
|
const props = withDefaults(
|
|
defineProps<{
|
|
prompt?: string
|
|
multiple?: boolean
|
|
accept?: string
|
|
/**
|
|
* The max file size in bytes
|
|
*/
|
|
maxSize?: number | null
|
|
showIcon?: boolean
|
|
shouldAlwaysReset?: boolean
|
|
longStyle?: boolean
|
|
disabled?: boolean
|
|
}>(),
|
|
{
|
|
prompt: 'Select file',
|
|
multiple: false,
|
|
showIcon: true,
|
|
shouldAlwaysReset: false,
|
|
longStyle: false,
|
|
disabled: false,
|
|
},
|
|
)
|
|
|
|
const emit = defineEmits<{ change: [files: File[]] }>()
|
|
|
|
const formatBytes = useFormatBytes()
|
|
|
|
const files = ref<File[]>([])
|
|
|
|
function addFiles(incoming: FileList, shouldNotReset = false) {
|
|
if (!shouldNotReset || props.shouldAlwaysReset) {
|
|
files.value = Array.from(incoming)
|
|
}
|
|
const validationOptions = { maxSize: props.maxSize, alertOnInvalid: true }
|
|
files.value = files.value.filter((file) => fileIsValid(file, validationOptions, formatBytes))
|
|
if (files.value.length > 0) {
|
|
emit('change', files.value)
|
|
}
|
|
}
|
|
|
|
function handleDrop(e: DragEvent) {
|
|
addFiles(e.dataTransfer!.files)
|
|
}
|
|
|
|
function handleChange(e: Event) {
|
|
const input = e.target as HTMLInputElement
|
|
if (!input.files) return
|
|
addFiles(input.files)
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
label {
|
|
flex-direction: unset;
|
|
max-height: unset;
|
|
&:focus-within {
|
|
outline: 0.25rem solid var(--color-focus-ring);
|
|
}
|
|
|
|
svg {
|
|
height: 1rem;
|
|
}
|
|
input {
|
|
position: absolute;
|
|
height: 1px;
|
|
width: 1px;
|
|
overflow: hidden;
|
|
clip: rect(1px, 1px, 1px, 1px);
|
|
}
|
|
&.long-style {
|
|
display: flex;
|
|
padding: 1.5rem 2rem;
|
|
justify-content: center;
|
|
align-items: center;
|
|
grid-gap: 0.5rem;
|
|
background-color: var(--color-button-bg);
|
|
border-radius: var(--radius-sm);
|
|
border: dashed 2px var(--color-secondary);
|
|
cursor: pointer;
|
|
color: var(--color-contrast);
|
|
}
|
|
}
|
|
</style>
|