-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor to use newer frontend extenders
- Loading branch information
Showing
17 changed files
with
98 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
} | ||
], | ||
"require": { | ||
"flarum/core": "^1.2.0" | ||
"flarum/core": "^1.8.3" | ||
}, | ||
"authors": [ | ||
{ | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import commonExtend from '../common/extend'; | ||
|
||
export default [...commonExtend]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Extend from 'flarum/common/extenders'; | ||
import Link from './models/Link'; | ||
|
||
export default [ | ||
new Extend.Store() // | ||
.add('links', Link), | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Model from 'flarum/common/Model'; | ||
|
||
export default class Link extends Model { | ||
title() { | ||
return Model.attribute<string>('title').call(this); | ||
} | ||
|
||
icon() { | ||
return Model.attribute<string>('icon').call(this); | ||
} | ||
|
||
type() { | ||
return Model.attribute<string>('type').call(this); | ||
} | ||
|
||
url() { | ||
return Model.attribute<string>('url').call(this); | ||
} | ||
|
||
position() { | ||
return Model.attribute<number | null | undefined>('position').call(this); | ||
} | ||
|
||
isInternal() { | ||
return Model.attribute<boolean>('isInternal').call(this); | ||
} | ||
|
||
isNewtab() { | ||
return Model.attribute<boolean>('isNewtab').call(this); | ||
} | ||
|
||
useRelMe() { | ||
return Model.attribute<boolean>('useRelMe').call(this); | ||
} | ||
|
||
isChild() { | ||
return Model.attribute<boolean>('isChild').call(this); | ||
} | ||
|
||
parent() { | ||
return Model.hasOne<Link>('parent').call(this); | ||
} | ||
|
||
visibility() { | ||
return Model.attribute<string>('visibility').call(this); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import commonExtend from '../common/extend'; | ||
|
||
export default [...commonExtend]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import app from 'flarum/forum/app'; | ||
import { extend } from 'flarum/common/extend'; | ||
import HeaderPrimary from 'flarum/forum/components/HeaderPrimary'; | ||
import ItemList from 'flarum/common/utils/ItemList'; | ||
import sortLinks from '../common/utils/sortLinks'; | ||
import type Mithril from 'mithril'; | ||
import Link from '../common/models/Link'; | ||
import LinkItem from './components/LinkItem'; | ||
import LinkDropdown from './components/LinkDropdown'; | ||
|
||
export default function extendHeader() { | ||
extend(HeaderPrimary.prototype, 'items', function (items: ItemList<Mithril.Children>) { | ||
const links = app.store.all<Link>('links').filter((link) => !link.isChild()); | ||
const addLink = (parent: Link | null | undefined) => { | ||
const hasChildren = app.store.all<Link>('links').some((link) => link.parent() == parent); | ||
|
||
items.add(`link${parent?.id()}`, hasChildren ? LinkDropdown.component({ link: parent }) : LinkItem.component({ link: parent })); | ||
}; | ||
|
||
sortLinks(links).map(addLink); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import app from 'flarum/forum/app'; | ||
import extendHeader from './extendHeader'; | ||
|
||
export * from './components'; | ||
export * from '../common/utils'; | ||
export * from '../common/models'; | ||
|
||
export { default as extend } from './extend'; | ||
|
||
app.initializers.add('fof-links', () => { | ||
extendHeader(); | ||
}); |