Skip to content

Commit 9d8a7f7

Browse files
authored
Merge pull request #1443 from nextcloud-libraries/chore/column-interface
refactor(column): use interfaces rather than instances
2 parents 5279304 + 467618d commit 9d8a7f7

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

lib/navigation/column.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { IView } from './view.ts'
88

99
import { checkOptionalProperty } from '../utils/objectValidation.ts'
1010

11-
interface ColumnData {
11+
export interface IColumn {
1212
/** Unique column ID */
1313
id: string
1414
/** Translated column title */
@@ -24,11 +24,11 @@ interface ColumnData {
2424
summary?: (node: INode[], view: IView) => string
2525
}
2626

27-
export class Column implements ColumnData {
27+
export class Column implements IColumn {
2828

29-
private _column: ColumnData
29+
private _column: IColumn
3030

31-
constructor(column: ColumnData) {
31+
constructor(column: IColumn) {
3232
validateColumn(column)
3333
this._column = column
3434
}
@@ -61,7 +61,7 @@ export class Column implements ColumnData {
6161
* @param column - the column to check
6262
* @throws {Error} if the column is not valid
6363
*/
64-
export function validateColumn(column: ColumnData): void {
64+
export function validateColumn(column: IColumn): void {
6565
if (typeof column !== 'object' || column === null) {
6666
throw new Error('View column must be an object')
6767
}

lib/navigation/view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
*/
55

66
import type { IFolder, INode } from '../node/index.ts'
7+
import type { IColumn } from './column.ts'
78

89
import isSvg from 'is-svg'
9-
import { Column, validateColumn } from './column.ts'
10+
import { validateColumn } from './column.ts'
1011
import { checkOptionalProperty } from '../utils/objectValidation.ts'
1112

1213
export type ContentsWithRoot = {
@@ -82,7 +83,7 @@ export interface IView {
8283
* This view column(s). Name and actions are
8384
* by default always included
8485
*/
85-
columns?: Column[]
86+
columns?: IColumn[]
8687

8788
/** The parent unique ID */
8889
parent?: string

0 commit comments

Comments
 (0)