[go: nahoru, domu]

Skip to content

Commit

Permalink
UBERF-7354 File edit page (hcengineering#5884)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
Signed-off-by: Alexander Platov <alexander.platov@hardcoreeng.com>
  • Loading branch information
aonnikov committed Jun 21, 2024
1 parent 55a030d commit caf3fed
Show file tree
Hide file tree
Showing 69 changed files with 627 additions and 250 deletions.
8 changes: 6 additions & 2 deletions models/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ import {
Prop,
ReadOnly,
TypeBoolean,
TypeFileSize,
TypeIntlString,
TypeNumber,
TypeRecord,
TypeRef,
TypeString,
Expand Down Expand Up @@ -155,7 +155,7 @@ export class TBlob extends TDoc implements Blob {
@ReadOnly()
version!: string

@Prop(TypeNumber(), core.string.BlobSize)
@Prop(TypeFileSize(), core.string.BlobSize)
@ReadOnly()
size!: number
}
Expand Down Expand Up @@ -228,6 +228,10 @@ export class TTypeIntlString extends TType {}
@Model(core.class.TypeNumber, core.class.Type)
export class TTypeNumber extends TType {}

@UX(core.string.BlobSize)
@Model(core.class.TypeFileSize, core.class.Type)
export class TTypeFileSize extends TType {}

@UX(core.string.Markup)
@Model(core.class.TypeMarkup, core.class.Type)
export class TTypeMarkup extends TType {}
Expand Down
2 changes: 2 additions & 0 deletions models/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import {
TTypeCollaborativeDocVersion,
TTypeCollaborativeMarkup,
TTypeDate,
TTypeFileSize,
TTypeHyperlink,
TTypeIntlString,
TTypeMarkup,
Expand Down Expand Up @@ -147,6 +148,7 @@ export function createModel (builder: Builder): void {
TArrOf,
TRefTo,
TTypeDate,
TTypeFileSize,
TTypeTimestamp,
TTypeNumber,
TTypeBoolean,
Expand Down
3 changes: 3 additions & 0 deletions models/drive/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@
"@hcengineering/model": "^0.6.11",
"@hcengineering/model-core": "^0.6.0",
"@hcengineering/model-preference": "^0.6.0",
"@hcengineering/model-print": "^0.6.0",
"@hcengineering/model-tracker": "^0.6.0",
"@hcengineering/model-view": "^0.6.0",
"@hcengineering/model-workbench": "^0.6.1",
"@hcengineering/activity": "^0.6.0",
"@hcengineering/chunter": "^0.6.20",
"@hcengineering/platform": "^0.6.11",
"@hcengineering/drive": "^0.6.0",
"@hcengineering/drive-resources": "^0.6.0",
Expand Down
79 changes: 41 additions & 38 deletions models/drive/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
// limitations under the License.
//

import activity from '@hcengineering/activity'
import chunter from '@hcengineering/chunter'
import core, {
type Blob,
type Domain,
type FindOptions,
type Role,
type RolesAssignment,
type Type,
Account,
AccountRole,
IndexKind,
Ref,
SortingOrder,
DOMAIN_MODEL
SortingOrder
} from '@hcengineering/core'
import { type Drive, type File, type Folder, type Resource, driveId } from '@hcengineering/drive'
import {
Expand All @@ -39,11 +39,13 @@ import {
TypeRecord,
TypeRef,
TypeString,
UX
UX,
Collection
} from '@hcengineering/model'
import { TDoc, TType, TTypedSpace } from '@hcengineering/model-core'
import { TDoc, TTypedSpace } from '@hcengineering/model-core'
import print from '@hcengineering/model-print'
import tracker from '@hcengineering/model-tracker'
import view, { type Viewlet, classPresenter, createAction } from '@hcengineering/model-view'
import view, { type Viewlet, createAction } from '@hcengineering/model-view'
import workbench from '@hcengineering/model-workbench'
import { getEmbeddedLabel } from '@hcengineering/platform'

Expand All @@ -54,14 +56,6 @@ export { drive as default }

export const DOMAIN_DRIVE = 'drive' as Domain

/** @public */
export function TypeFilesize (): Type<number> {
return { _class: drive.class.TypeFileSize, label: drive.string.Size }
}

@Model(drive.class.TypeFileSize, core.class.Type, DOMAIN_MODEL)
export class TTypeFileSize extends TType {}

@Model(drive.class.Drive, core.class.TypedSpace)
@UX(drive.string.Drive)
export class TDrive extends TTypedSpace implements Drive {}
Expand Down Expand Up @@ -98,6 +92,9 @@ export class TResource extends TDoc implements Resource {
@Prop(TypeRef(drive.class.Resource), drive.string.Path)
@ReadOnly()
path!: Ref<Resource>[]

@Prop(Collection(chunter.class.ChatMessage), chunter.string.Comments)
comments?: number
}

@Model(drive.class.Folder, drive.class.Resource, DOMAIN_DRIVE)
Expand Down Expand Up @@ -125,7 +122,6 @@ export class TFile extends TResource implements File {

@Prop(TypeRecord(), drive.string.Metadata)
@ReadOnly()
@Hidden()
metadata?: Record<string, any>

@Prop(TypeRef(drive.class.Folder), drive.string.Parent)
Expand Down Expand Up @@ -207,7 +203,7 @@ function defineDrive (builder: Builder): void {
// Actions

builder.mixin(drive.class.Drive, core.class.Class, view.mixin.IgnoreActions, {
actions: [tracker.action.EditRelatedTargets, tracker.action.NewRelatedIssue]
actions: [tracker.action.EditRelatedTargets, print.action.Print, tracker.action.NewRelatedIssue]
})

createAction(
Expand Down Expand Up @@ -249,9 +245,7 @@ function defineDrive (builder: Builder): void {
}

function defineResource (builder: Builder): void {
builder.createModel(TTypeFileSize, TResource)

classPresenter(builder, drive.class.TypeFileSize, drive.component.FileSizePresenter)
builder.createModel(TResource)

builder.mixin(drive.class.Resource, core.class.Class, view.mixin.ObjectPresenter, {
presenter: drive.component.ResourcePresenter
Expand All @@ -270,15 +264,9 @@ function defineResource (builder: Builder): void {
label: drive.string.Name,
sortingKey: 'name'
},
{
key: '$lookup.file.size',
presenter: drive.component.FileSizePresenter,
label: drive.string.Size,
sortingKey: '$lookup.file.size'
},
{
key: '$lookup.file.modifiedOn'
},
'$lookup.file.size',
'comments',
'$lookup.file.modifiedOn',
'createdBy'
],
/* eslint-disable @typescript-eslint/consistent-type-assertions */
Expand Down Expand Up @@ -332,16 +320,8 @@ function defineResource (builder: Builder): void {
label: drive.string.Name,
sortingKey: 'name'
},
{
key: '$lookup.file.size',
presenter: drive.component.FileSizePresenter,
label: drive.string.Size,
sortingKey: '$lookup.file.size'
},
{
key: '$lookup.file.modifiedOn',
label: core.string.ModifiedDate
},
'$lookup.file.size',
'$lookup.file.modifiedOn',
'createdBy'
],
configOptions: {
Expand Down Expand Up @@ -388,6 +368,7 @@ function defineFolder (builder: Builder): void {
actions: [
view.action.Open,
view.action.OpenInNewTab,
print.action.Print,
tracker.action.EditRelatedTargets,
tracker.action.NewRelatedIssue
]
Expand Down Expand Up @@ -438,12 +419,34 @@ function defineFile (builder: Builder): void {
presenter: drive.component.FilePresenter
})

builder.mixin(drive.class.File, core.class.Class, view.mixin.ObjectEditor, {
editor: drive.component.EditFile
})

builder.mixin(drive.class.File, core.class.Class, view.mixin.ObjectPanel, {
component: drive.component.FilePanel
})

builder.mixin(drive.class.File, core.class.Class, view.mixin.LinkProvider, {
encode: drive.function.FileLinkProvider
})

// Activity

builder.mixin(drive.class.File, core.class.Class, activity.mixin.ActivityDoc, {})

builder.createDoc(activity.class.ActivityExtension, core.space.Model, {
ofClass: drive.class.File,
components: { input: chunter.component.ChatMessageInput }
})

// Actions

builder.mixin(drive.class.File, core.class.Class, view.mixin.IgnoreActions, {
actions: [
view.action.Open,
view.action.OpenInNewTab,
print.action.Print,
tracker.action.EditRelatedTargets,
tracker.action.NewRelatedIssue
]
Expand Down
6 changes: 3 additions & 3 deletions models/drive/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default mergeIds(driveId, drive, {
DriveSpacePresenter: '' as AnyComponent,
DrivePanel: '' as AnyComponent,
DrivePresenter: '' as AnyComponent,
EditFile: '' as AnyComponent,
EditFolder: '' as AnyComponent,
FilePanel: '' as AnyComponent,
FolderPanel: '' as AnyComponent,
FolderPresenter: '' as AnyComponent,
FilePresenter: '' as AnyComponent,
Expand All @@ -46,6 +48,7 @@ export default mergeIds(driveId, drive, {
function: {
DriveLinkProvider: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
FolderLinkProvider: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
FileLinkProvider: '' as Resource<(doc: Doc, props: Record<string, any>) => Promise<Location>>,
CanRenameFile: '' as Resource<ViewActionAvailabilityFunction>,
CanRenameFolder: '' as Resource<ViewActionAvailabilityFunction>
},
Expand Down Expand Up @@ -78,10 +81,7 @@ export default mergeIds(driveId, drive, {
Grid: '' as IntlString,
Name: '' as IntlString,
Description: '' as IntlString,
Size: '' as IntlString,
Type: '' as IntlString,
Metadata: '' as IntlString,
LastModified: '' as IntlString,
Parent: '' as IntlString,
Path: '' as IntlString,
Drives: '' as IntlString,
Expand Down
1 change: 1 addition & 0 deletions models/view/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ export function createModel (builder: Builder): void {
view.component.MarkupEditorPopup,
view.component.MarkupDiffPresenter
)
classPresenter(builder, core.class.TypeFileSize, view.component.FileSizePresenter, view.component.FileSizePresenter)

builder.mixin(core.class.TypeMarkup, core.class.Class, view.mixin.InlineAttributEditor, {
editor: view.component.HTMLEditor
Expand Down
1 change: 1 addition & 0 deletions models/view/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default mergeIds(viewId, view, {
HyperlinkEditor: '' as AnyComponent,
HyperlinkEditorPopup: '' as AnyComponent,
IntlStringPresenter: '' as AnyComponent,
FileSizePresenter: '' as AnyComponent,
NumberEditor: '' as AnyComponent,
NumberPresenter: '' as AnyComponent,
MarkupDiffPresenter: '' as AnyComponent,
Expand Down
3 changes: 2 additions & 1 deletion packages/core/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"ArchiveSpaceDescription": "Grants users ability to archive the space",
"AutoJoin": "Auto join",
"AutoJoinDescr": "Automatically join new employees to this space",
"BlobSize": "Size"
"BlobSize": "Size",
"BlobContentType": "Content type"
}
}
3 changes: 2 additions & 1 deletion packages/core/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"ArchiveSpaceDescription": "Concede a los usuarios la capacidad de archivar el espacio",
"AutoJoin": "Auto unirse",
"AutoJoinDescr": "Unirse automáticamente a los nuevos empleados a este espacio",
"BlobSize": "Tamaño"
"BlobSize": "Tamaño",
"BlobContentType": "Tipo de contenido"
}
}
3 changes: 2 additions & 1 deletion packages/core/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"ArchiveSpaceDescription": "Accorde aux utilisateurs la capacité d'archiver l'espace",
"AutoJoin": "Rejoindre automatiquement",
"AutoJoinDescr": "Ajouter automatiquement les nouveaux employés à cet espace",
"BlobSize": "Taille"
"BlobSize": "Taille",
"BlobContentType": "Type de contenu"
}
}
3 changes: 2 additions & 1 deletion packages/core/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"ArchiveSpaceDescription": "Concede aos usuários a capacidade de arquivar o espaço",
"AutoJoin": "Auto adesão",
"AutoJoinDescr": "Adesão automática de novos funcionários a este espaço",
"BlobSize": "Tamanho"
"BlobSize": "Tamanho",
"BlobContentType": "Tipo de conteúdo"
}
}
3 changes: 2 additions & 1 deletion packages/core/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"ArchiveSpaceDescription": "Дает пользователям разрешение архивировать пространство",
"AutoJoin": "Автоприсоединение",
"AutoJoinDescr": "Автоматически присоединять новых сотрудников к этому пространству",
"BlobSize": "Размер"
"BlobSize": "Размер",
"BlobContentType": "Тип контента"
}
}
3 changes: 2 additions & 1 deletion packages/core/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"ArchiveSpaceDescription": "授予用户归档空间的权限",
"AutoJoin": "自动加入",
"AutoJoinDescr": "自动将新员工加入此空间",
"BlobSize": "大小"
"BlobSize": "大小",
"BlobContentType": "內容類型"
}
}
2 changes: 2 additions & 0 deletions packages/core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default plugin(coreId, {
TypeIntlString: '' as Ref<Class<Type<IntlString>>>,
TypeHyperlink: '' as Ref<Class<Type<Hyperlink>>>,
TypeNumber: '' as Ref<Class<Type<number>>>,
TypeFileSize: '' as Ref<Class<Type<number>>>,
TypeMarkup: '' as Ref<Class<Type<string>>>,
TypeRank: '' as Ref<Class<Type<Rank>>>,
TypeRecord: '' as Ref<Class<Type<Record<any, any>>>>,
Expand Down Expand Up @@ -201,6 +202,7 @@ export default plugin(coreId, {
Array: '' as IntlString,
Name: '' as IntlString,
Enum: '' as IntlString,
Size: '' as IntlString,
Description: '' as IntlString,
ShortDescription: '' as IntlString,
Descriptor: '' as IntlString,
Expand Down
7 changes: 7 additions & 0 deletions packages/model/src/dsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ export function TypeEnum (of: Ref<Enum>): EnumOf {
return { _class: core.class.EnumOf, label: core.string.Enum, of }
}

/**
* @public
*/
export function TypeFileSize (): Type<number> {
return { _class: core.class.TypeFileSize, label: core.string.Size }
}

/**
* @public
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"Next": "Next",
"FailedToPreview": "Failed to preview",
"ContentType": "Content type",
"ContentTypeNotSupported": "Content type not supported"
"ContentTypeNotSupported": "Preview is not available for this content type"
},
"status": {
"FileTooLarge": "File too large"
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"Next": "Siguiente",
"FailedToPreview": "Error al previsualizar",
"ContentType": "Tipo de contenido",
"ContentTypeNotSupported": "Tipo de contenido no admitido"
"ContentTypeNotSupported": "La vista previa no está disponible para este tipo de contenido"
},
"status": {
"FileTooLarge": "Archivo demasiado grande"
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"Next": "Suivant",
"FailedToPreview": "Échec de l'aperçu",
"ContentType": "Type de contenu",
"ContentTypeNotSupported": "Type de contenu non supporté"
"ContentTypeNotSupported": "L'aperçu n'est pas disponible pour ce type de contenu"
},
"status": {
"FileTooLarge": "Fichier trop volumineux"
Expand Down
2 changes: 1 addition & 1 deletion packages/presentation/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"Next": "Seguinte",
"FailedToPreview": "Falha ao pré-visualizar",
"ContentType": "Tipo de conteúdo",
"ContentTypeNotSupported": "Tipo de conteúdo não suportado"
"ContentTypeNotSupported": "A visualização não está disponível para este tipo de conteúdo"
},
"status": {
"FileTooLarge": "Ficheiro demasiado grande"
Expand Down
Loading

0 comments on commit caf3fed

Please sign in to comment.