Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Add iconSvgInline to TemplateFileCreator
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Mar 20, 2024
commit 66e77d41c87e75447ac10090e1e7629e7b221cac
1 change: 1 addition & 0 deletions apps/files/lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* label: string,
* extension: string,
* iconClass: ?string,
* iconSvgInline: ?string,
* mimetypes: string[],
* ratio: ?float,
* actionLabel: string,
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/newMenu/newFromTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export function registerTemplateEntries() {
addNewFileMenuEntry({
id: `template-new-${provider.app}-${index}`,
displayName: provider.label,
// TODO: migrate to inline svg
iconClass: provider.iconClass || 'icon-file',
iconSvgInline: provider.iconSvgInline,
enabled(context: Folder): boolean {
return (context.permissions & Permission.CREATE) !== 0
},
Expand Down
1 change: 1 addition & 0 deletions apps/files/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export interface TemplateFile {
label: string
extension: string
iconClass?: string
iconSvgInline?: string
mimetypes: string[]
ratio?: number
templates?: Record<string, unknown>[]
Expand Down
14 changes: 13 additions & 1 deletion lib/public/Files/Template/TemplateFileCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ final class TemplateFileCreator implements \JsonSerializable {
protected $fileExtension;
/** @var ?string $iconClass */
protected $iconClass;
/** @var ?string $iconSvgInline */
protected $iconSvgInline;
/** @var ?float $ratio */
protected $ratio = null;
protected $order = 100;
Expand Down Expand Up @@ -66,12 +68,21 @@ public function getAppId(): string {

/**
* @since 21.0.0
* @deprecated 29.0.0
*/
public function setIconClass(string $iconClass): TemplateFileCreator {
$this->iconClass = $iconClass;
return $this;
}

/**
* @since 29.0.0
*/
public function setIconSvgInline(string $iconSvgInline): TemplateFileCreator {
$this->iconSvgInline = $iconSvgInline;
return $this;
}

/**
* @since 21.0.0
*/
Expand Down Expand Up @@ -128,14 +139,15 @@ public function getActionLabel(): string {

/**
* @since 21.0.0
* @return array{app: string, label: string, extension: string, iconClass: ?string, mimetypes: string[], ratio: ?float, actionLabel: string}
* @return array{app: string, label: string, extension: string, iconClass: ?string, iconSvgInline: ?string, mimetypes: string[], ratio: ?float, actionLabel: string}
*/
public function jsonSerialize(): array {
return [
'app' => $this->appId,
'label' => $this->actionName,
'extension' => $this->fileExtension,
'iconClass' => $this->iconClass,
'iconSvgInline' => $this->iconSvgInline,
'mimetypes' => $this->mimetypes,
'ratio' => $this->ratio,
'actionLabel' => $this->actionLabel,
Expand Down