Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use imported LanguageDropdown #164

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 0 additions & 5 deletions js/src/forum/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import Composer from './components/Composer/Composer';
import ComposerPreview from './components/Composer/ComposerPreview';
import FeaturedBlogItem from './components/FeaturedBlogItem';
import ForumNav from './components/ForumNav';
import Language from './components/LanguageDropdown/Language';
import LanguageDropdown from './components/LanguageDropdown/LanguageDropdown';
import BlogPostSettingsModal from './components/Modals/BlogPostSettingsModal';
import RenameArticleModal from './components/Modals/RenameArticleModal';
import BlogItem from './pages/BlogItem';
Expand All @@ -25,9 +23,6 @@ export default () => {
'v17development/blog/components/Composer/Composer': Composer,
'v17development/blog/components/Composer/ComposerPreview': ComposerPreview,

'v17development/blog/components/LanguageDropdown/Language': Language,
'v17development/blog/components/LanguageDropdown/LanguageDropdown': LanguageDropdown,

'v17development/blog/components/Modals/BlogPostSettingsModal': BlogPostSettingsModal,
'v17development/blog/components/Modals/RenameArticleModal': RenameArticleModal,

Expand Down
31 changes: 0 additions & 31 deletions js/src/forum/components/LanguageDropdown/Language.js

This file was deleted.

46 changes: 0 additions & 46 deletions js/src/forum/components/LanguageDropdown/LanguageDropdown.js

This file was deleted.

18 changes: 15 additions & 3 deletions js/src/forum/pages/BlogComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import RenameArticleModal from '../components/Modals/RenameArticleModal';
import TagDiscussionModal from 'flarum/tags/components/TagDiscussionModal';
import BlogPostSettingsModal from '../components/Modals/BlogPostSettingsModal';
import Composer from '../components/Composer/Composer';
import LanguageDropdown from '../components/LanguageDropdown/LanguageDropdown';
import ItemList from 'flarum/common/utils/ItemList';
import Stream from 'flarum/common/utils/Stream';
import { components } from '@fof-discussion-language';

export default class BlogComposer extends Page {
oninit(vnode) {
Expand All @@ -32,7 +33,7 @@ export default class BlogComposer extends Page {
this.bodyClass = 'BlogItemPage BlogItemPage--composer';

// Article data
this.articleLanguage = m.route.param('lang') ? m.route.param('lang') : app.translator.locale;
this.articleLanguage = new Stream(m.route.param('lang') ? m.route.param('lang') : app.translator.locale);
this.article = app.store.createRecord('discussions');
this.blogMeta = null;

Expand Down Expand Up @@ -153,6 +154,11 @@ export default class BlogComposer extends Page {

const blogImage = this.blogMeta && this.blogMeta.featuredImage() ? `url(${this.blogMeta.featuredImage()})` : defaultImage;

let LanguageDropdown;
if ('fof-discussion-language' in flarum.extensions) {
LanguageDropdown = components.LanguageDropdown;
}

items.add(
'content',
<div className="FlarumBlog-Article-Content">
Expand All @@ -168,7 +174,13 @@ export default class BlogComposer extends Page {
<div className={'FlarumBlog-Article-Content-Edit-Button'}>
<div className={this.languages.length === 0 ? 'FlarumBlog-Article-Content-Edit-Dropdown' : 'FlarumBlog-Article-Content-EditButtons'}>
{this.languages !== null && this.languages.length >= 1 && (
<LanguageDropdown selected={this.articleLanguage} onclick={(language) => (this.articleLanguage = language)} />
<LanguageDropdown
selected={this.articleLanguage()}
onclick={(language) => {
this.articleLanguage(language);
m.redraw();
}}
/>
)}

<Button className={'Button'} onclick={(e) => this.openBlogSettings(e)} icon={'fas fa-pencil-alt'} loading={this.isSaving}>
Expand Down
7 changes: 6 additions & 1 deletion js/src/forum/pages/BlogOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Page from 'flarum/common/components/Page';
import Button from 'flarum/common/components/Button';
import BlogCategories from '../components/BlogCategories';
import Link from 'flarum/common/components/Link';
import LanguageDropdown from '../components/LanguageDropdown/LanguageDropdown';
import { components } from '@fof-discussion-language';
import ForumNav from '../components/ForumNav';
import BlogOverviewItem from '../components/BlogOverviewItem';
import FeaturedBlogItem from '../components/FeaturedBlogItem';
Expand Down Expand Up @@ -138,6 +138,11 @@ export default class BlogOverview extends Page {
? `url(${app.forum.attribute('baseUrl') + '/assets/' + app.forum.attribute('blogDefaultImage')})`
: null;

let LanguageDropdown;
if ('fof-discussion-language' in flarum.extensions) {
LanguageDropdown = components.LanguageDropdown;
}

return [
app.forum.attribute('blogAddHero') == true && IndexPage.prototype.hero(),
<div className={'FlarumBlogOverview'}>
Expand Down
4 changes: 2 additions & 2 deletions js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const config = require("flarum-webpack-config");
const config = require('flarum-webpack-config');

module.exports = config({
useExtensions: ["fof-upload"],
useExtensions: ['fof-upload', 'fof-discussion-language'],
});
Loading