1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Redesign manage my videos

* Use a table to list my videos for a clearer overview and so it's
   easier to add bulk actions in the future
 * Use a "Manage" video page with a proper URL navigation
 * Add "Stats" and "Studio" in this "Manage" page
This commit is contained in:
Chocobozzz 2025-03-06 09:45:10 +01:00
parent f0f44e1704
commit b295dd5820
No known key found for this signature in database
GPG key ID: 583A612D890159BE
342 changed files with 9452 additions and 6376 deletions

View file

@ -1,4 +1,6 @@
function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
import { Jsonify } from 'type-fest'
export function pick<O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
const result: any = {}
for (const key of keys) {
@ -10,7 +12,7 @@ function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick
return result
}
function omit <O extends object, K extends keyof O> (object: O, keys: K[]): Exclude<O, K> {
export function omit<O extends object, K extends keyof O> (object: O, keys: K[]): Exclude<O, K> {
const result: any = {}
const keysSet = new Set(keys) as Set<string>
@ -23,19 +25,19 @@ function omit <O extends object, K extends keyof O> (object: O, keys: K[]): Excl
return result
}
function objectKeysTyped <O extends object, K extends keyof O> (object: O): K[] {
export function objectKeysTyped<O extends object, K extends keyof O> (object: O): K[] {
return (Object.keys(object) as K[])
}
function getKeys <O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
export function getKeys<O extends object, K extends keyof O> (object: O, keys: K[]): K[] {
return (Object.keys(object) as K[]).filter(k => keys.includes(k))
}
function hasKey <T extends object> (obj: T, k: keyof any): k is keyof T {
export function hasKey<T extends object> (obj: T, k: keyof any): k is keyof T {
return k in obj
}
function sortObjectComparator (key: string, order: 'asc' | 'desc') {
export function sortObjectComparator (key: string, order: 'asc' | 'desc') {
return (a: any, b: any) => {
if (a[key] < b[key]) {
return order === 'asc' ? -1 : 1
@ -49,12 +51,19 @@ function sortObjectComparator (key: string, order: 'asc' | 'desc') {
}
}
function shallowCopy <T> (o: T): T {
export function shallowCopy<T> (o: T): T {
return Object.assign(Object.create(Object.getPrototypeOf(o)), o)
}
function simpleObjectsDeepEqual (a: any, b: any) {
if (a === b) return true
export function exists (value: any) {
return value !== undefined && value !== null
}
// ---------------------------------------------------------------------------
export function simpleObjectsDeepEqual<T, U> (a: Jsonify<T>, b: Jsonify<U>) {
if (a as any === b as any) return true
if (a === undefined && b === undefined) return true
if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) {
return false
@ -73,14 +82,3 @@ function simpleObjectsDeepEqual (a: any, b: any) {
return true
}
export {
pick,
omit,
objectKeysTyped,
getKeys,
hasKey,
shallowCopy,
sortObjectComparator,
simpleObjectsDeepEqual
}

View file

@ -103,6 +103,8 @@ function decorateVideoLink (options: {
p2p?: boolean
api?: boolean
version?: number
}) {
const { url } = options
@ -134,6 +136,8 @@ function decorateVideoLink (options: {
if (options.api !== undefined) params.set('api', options.api ? '1' : '0')
if (options.version !== undefined) params.set('v', options.version + '')
return buildUrl(url, params)
}

View file

@ -1,2 +1,3 @@
export * from './bitrate.js'
export * from './common.js'
export * from './state.js'

View file

@ -0,0 +1,12 @@
import { VideoState, VideoStateType } from '@peertube/peertube-models'
export function canVideoFileBeEdited (state: VideoStateType) {
const validStates = new Set<VideoStateType>([
VideoState.PUBLISHED,
VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED,
VideoState.TO_MOVE_TO_FILE_SYSTEM_FAILED,
VideoState.TRANSCODING_FAILED
])
return validStates.has(state)
}