Skip to content

Commit

Permalink
Merge pull request #1053 from nextcloud-libraries/feat/view-natural-sort
Browse files Browse the repository at this point in the history
feat: Allow views to be naturally sorted
  • Loading branch information
Pytal authored Aug 17, 2024
2 parents fefad1a + d653bc4 commit bc97504
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/navigation/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ interface ViewData {
getContents: (path: string) => Promise<ContentsWithRoot>
/** The view icon as an inline svg */
icon: string
/** The view order */
order: number

/**
* The view order.
* If not set will be natural sorted by view name.
*/
order?: number

/**
* Custom params to give to the router on click
Expand Down Expand Up @@ -199,8 +203,8 @@ const isValidView = function(view: ViewData): boolean {
throw new Error('View icon is required and must be a valid svg string')
}

if (!('order' in view) || typeof view.order !== 'number') {
throw new Error('View order is required and must be a number')
if ('order' in view && typeof view.order !== 'number') {
throw new Error('View order must be a number')
}

// Optional properties
Expand Down

0 comments on commit bc97504

Please sign in to comment.