...
 
Commits (2)
import discourseComputed from "discourse-common/utils/decorators";
import NavItem from "discourse/models/nav-item";
import { inject as service } from "@ember/service";
import Component from "@ember/component";
......@@ -47,7 +48,7 @@ export default Component.extend({
}, {});
}
return Discourse.NavItem.buildList(category, {
return NavItem.buildList(category, {
filterMode,
noSubcategories,
persistedQueryParams: params
......
......@@ -7,6 +7,7 @@ import { propertyGreaterThan, propertyLessThan } from "discourse/lib/computed";
import { on, observes } from "discourse-common/utils/decorators";
import { sanitizeAsync } from "discourse/lib/text";
import { iconHTML } from "discourse-common/lib/icon-library";
import Post from "discourse/models/post";
function customTagArray(fieldName) {
return Ember.computed(fieldName, function() {
......@@ -59,19 +60,19 @@ export default Controller.extend(ModalFunctionality, {
refresh(postId, postVersion) {
this.set("loading", true);
Discourse.Post.loadRevision(postId, postVersion).then(result => {
Post.loadRevision(postId, postVersion).then(result => {
this.setProperties({ loading: false, model: result });
});
},
hide(postId, postVersion) {
Discourse.Post.hideRevision(postId, postVersion).then(() =>
Post.hideRevision(postId, postVersion).then(() =>
this.refresh(postId, postVersion)
);
},
show(postId, postVersion) {
Discourse.Post.showRevision(postId, postVersion).then(() =>
Post.showRevision(postId, postVersion).then(() =>
this.refresh(postId, postVersion)
);
},
......
......@@ -185,7 +185,7 @@ NavItem.reopenClass({
}
items = items
.map(i => Discourse.NavItem.fromText(i, args))
.map(i => NavItem.fromText(i, args))
.filter(
i => i !== null && !(category && i.get("name").indexOf("categor") === 0)
);
......
......@@ -16,7 +16,7 @@ import Composer from "discourse/models/composer";
import { Promise } from "rsvp";
const Post = RestModel.extend({
// TODO: Remove this once one instantiate all `Discourse.Post` models via the store.
// TODO: Remove this once one instantiate all `Post` models via the store.
siteSettings: Ember.computed({
get() {
return Discourse.SiteSettings;
......@@ -320,7 +320,7 @@ const Post = RestModel.extend({
// need to wait to hear back from server (stuff may not be loaded)
return Discourse.Post.updateBookmark(this.id, this.bookmarked)
return Post.updateBookmark(this.id, this.bookmarked)
.then(result => {
this.set("topic.bookmarked", result.topic_bookmarked);
this.appEvents.trigger("page:bookmark-post-toggled", this);
......@@ -417,7 +417,7 @@ Post.reopenClass({
loadQuote(postId) {
return ajax(`/posts/${postId}.json`).then(result => {
const post = Discourse.Post.create(result);
const post = Post.create(result);
return Quote.build(post, post.raw, { raw: true, full: true });
});
},
......
......@@ -85,14 +85,13 @@ JS
def whitelisted?(path)
@@whitelisted ||= Set.new(
["discourse/models/nav-item",
[
"discourse/routes/discourse",
"discourse/models/category",
"discourse/models/site",
"discourse/models/user",
"discourse/models/session",
"discourse/models/model",
"discourse/models/post"
"discourse/models/model"
]
)
......
......@@ -2,6 +2,7 @@ import EmberObject from "@ember/object";
import { currentUser } from "helpers/qunit-helpers";
import AppEvents from "discourse/services/app-events";
import Composer from "discourse/models/composer";
import Post from "discourse/models/post";
import createStore from "helpers/create-store";
QUnit.module("model:composer");
......@@ -247,7 +248,7 @@ QUnit.test("editingFirstPost", assert => {
const composer = createComposer();
assert.ok(!composer.get("editingFirstPost"), "it's false by default");
const post = Discourse.Post.create({ id: 123, post_number: 2 });
const post = Post.create({ id: 123, post_number: 2 });
composer.setProperties({ post: post, action: Composer.EDIT });
assert.ok(
!composer.get("editingFirstPost"),
......@@ -265,7 +266,7 @@ QUnit.test("clearState", assert => {
const composer = createComposer({
originalText: "asdf",
reply: "asdf2",
post: Discourse.Post.create({ id: 1 }),
post: Post.create({ id: 1 }),
title: "wat"
});
......@@ -329,7 +330,7 @@ QUnit.test("Title length for static page topics as admin", assert => {
Discourse.SiteSettings.max_topic_title_length = 10;
const composer = createComposer();
const post = Discourse.Post.create({
const post = Post.create({
id: 123,
post_number: 2,
static_doc: true
......
import { run } from "@ember/runloop";
import createStore from "helpers/create-store";
import NavItem from "discourse/models/nav-item";
QUnit.module("Discourse.NavItem", {
QUnit.module("NavItem", {
beforeEach() {
run(function() {
const asianCategory = Discourse.Category.create({
......@@ -17,11 +18,7 @@ QUnit.test("href", assert => {
assert.expect(4);
function href(text, expected, label) {
assert.equal(
Discourse.NavItem.fromText(text, {}).get("href"),
expected,
label
);
assert.equal(NavItem.fromText(text, {}).get("href"), expected, label);
}
href("latest", "/latest", "latest");
......
QUnit.module("model:post-stream");
import Post from "discourse/models/post";
import createStore from "helpers/create-store";
QUnit.module("model:post-stream");
const buildStream = function(id, stream) {
const store = createStore();
const topic = store.createRecord("topic", { id, chunk_size: 5 });
......@@ -173,7 +174,7 @@ QUnit.test("updateFromJson", assert => {
});
assert.equal(postStream.get("posts.length"), 1, "it loaded the posts");
assert.containsInstance(postStream.get("posts"), Discourse.Post);
assert.containsInstance(postStream.get("posts"), Post);
assert.equal(postStream.get("extra_property"), 12);
});
......
QUnit.module("Discourse.Post");
import Post from "discourse/models/post";
QUnit.module("model: Post");
var buildPost = function(args) {
return Discourse.Post.create(
return Post.create(
_.merge(
{
id: 1,
......@@ -14,13 +16,13 @@ var buildPost = function(args) {
};
QUnit.test("defaults", assert => {
var post = Discourse.Post.create({ id: 1 });
var post = Post.create({ id: 1 });
assert.blank(post.get("deleted_at"), "it has no deleted_at by default");
assert.blank(post.get("deleted_by"), "there is no deleted_by by default");
});
QUnit.test("new_user", assert => {
var post = Discourse.Post.create({ trust_level: 0 });
var post = Post.create({ trust_level: 0 });
assert.ok(post.get("new_user"), "post is from a new user");
post.set("trust_level", 1);
......@@ -28,7 +30,7 @@ QUnit.test("new_user", assert => {
});
QUnit.test("firstPost", assert => {
var post = Discourse.Post.create({ post_number: 1 });
var post = Post.create({ post_number: 1 });
assert.ok(post.get("firstPost"), "it's the first post");
post.set("post_number", 10);
......@@ -36,13 +38,13 @@ QUnit.test("firstPost", assert => {
});
QUnit.test("updateFromPost", assert => {
var post = Discourse.Post.create({
var post = Post.create({
post_number: 1,
raw: "hello world"
});
post.updateFromPost(
Discourse.Post.create({
Post.create({
raw: "different raw",
wat: function() {
return 123;
......