mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 03:48:23 +00:00
DEV: Update glimmer menu to use value transformer (#30930)
- Use the `smallUserAttrs` function in the new glimmer menu - Replace the sugar syntax `@data` with `this.args` to fix tests
This commit is contained in:
parent
7b76d25946
commit
6aa492254f
@ -9,12 +9,13 @@ import { and, eq } from "truth-helpers";
|
||||
import AdminPostMenu from "discourse/components/admin-post-menu";
|
||||
import DeleteTopicDisallowedModal from "discourse/components/modal/delete-topic-disallowed";
|
||||
import PluginOutlet from "discourse/components/plugin-outlet";
|
||||
import SmallUserList from "discourse/components/small-user-list";
|
||||
import SmallUserList, {
|
||||
smallUserAttrs,
|
||||
} from "discourse/components/small-user-list";
|
||||
import UserTip from "discourse/components/user-tip";
|
||||
import concatClass from "discourse/helpers/concat-class";
|
||||
import DAG from "discourse/lib/dag";
|
||||
import { applyMutableValueTransformer } from "discourse/lib/transformer";
|
||||
import { userPath } from "discourse/lib/url";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import PostMenuButtonConfig from "./menu/button-config";
|
||||
import PostMenuButtonWrapper from "./menu/button-wrapper";
|
||||
@ -64,16 +65,6 @@ const coreButtonComponents = new Map([
|
||||
[buttonKeys.SHOW_MORE, PostMenuShowMoreButton],
|
||||
]);
|
||||
|
||||
function smallUserAttributes(user) {
|
||||
return {
|
||||
template: user.avatar_template,
|
||||
username: user.username,
|
||||
post_url: user.post_url,
|
||||
url: userPath(user.username_lower),
|
||||
unknown: user.unknown,
|
||||
};
|
||||
}
|
||||
|
||||
const defaultDagOptions = {
|
||||
defaultPosition: { before: buttonKeys.SHOW_MORE },
|
||||
throwErrorOnCycle: false,
|
||||
@ -565,7 +556,7 @@ export default class PostMenu extends Component {
|
||||
post_action_type_id: LIKE_ACTION,
|
||||
});
|
||||
|
||||
this.likedUsers = users.map(smallUserAttributes);
|
||||
this.likedUsers = users.map(smallUserAttrs);
|
||||
this.totalLikedUsers = users.totalRows;
|
||||
this.isWhoLikedVisible = true;
|
||||
}
|
||||
@ -575,7 +566,7 @@ export default class PostMenu extends Component {
|
||||
id: this.args.post.id,
|
||||
});
|
||||
|
||||
this.readers = users.map(smallUserAttributes);
|
||||
this.readers = users.map(smallUserAttrs);
|
||||
this.totalReaders = users.totalRows;
|
||||
this.isWhoReadVisible = true;
|
||||
}
|
||||
|
@ -1,12 +1,26 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { hash } from "@ember/helper";
|
||||
import { service } from "@ember/service";
|
||||
import PluginOutlet from "discourse/components/plugin-outlet";
|
||||
import avatar from "discourse/helpers/bound-avatar-template";
|
||||
import getURL from "discourse/lib/get-url";
|
||||
import { smallUserAttrs } from "discourse/lib/user-list-attrs";
|
||||
import { applyValueTransformer } from "discourse/lib/transformer";
|
||||
import { userPath } from "discourse/lib/url";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export function smallUserAttrs(user) {
|
||||
const defaultAttrs = {
|
||||
template: user.avatar_template,
|
||||
username: user.username,
|
||||
post_url: user.post_url,
|
||||
url: userPath(user.username_lower),
|
||||
unknown: user.unknown,
|
||||
};
|
||||
|
||||
return applyValueTransformer("small-user-attrs", defaultAttrs, {
|
||||
user,
|
||||
});
|
||||
}
|
||||
|
||||
export default class SmallUserList extends Component {
|
||||
@service currentUser;
|
||||
|
||||
@ -30,10 +44,7 @@ export default class SmallUserList extends Component {
|
||||
|
||||
<template>
|
||||
{{#if this.users}}
|
||||
<PluginOutlet
|
||||
@name="small-user-list-internal"
|
||||
@outletArgs={{hash data=@data}}
|
||||
>
|
||||
<PluginOutlet @name="small-user-list-internal" @outletArgs={{this.args}}>
|
||||
<div class="clearfix small-user-list" ...attributes>
|
||||
<span
|
||||
class="small-user-list-content"
|
||||
|
@ -1,16 +0,0 @@
|
||||
import { applyValueTransformer } from "discourse/lib/transformer";
|
||||
import { userPath } from "discourse/lib/url";
|
||||
|
||||
export function smallUserAttrs(user) {
|
||||
const defaultAttrs = {
|
||||
template: user.avatar_template,
|
||||
username: user.username,
|
||||
post_url: user.post_url,
|
||||
url: userPath(user.username_lower),
|
||||
unknown: user.unknown,
|
||||
};
|
||||
|
||||
return applyValueTransformer("small-user-attrs", defaultAttrs, {
|
||||
user,
|
||||
});
|
||||
}
|
@ -4,10 +4,10 @@ import { Promise } from "rsvp";
|
||||
import { h } from "virtual-dom";
|
||||
import AdminPostMenu from "discourse/components/admin-post-menu";
|
||||
import DeleteTopicDisallowedModal from "discourse/components/modal/delete-topic-disallowed";
|
||||
import { smallUserAttrs } from "discourse/components/small-user-list";
|
||||
import { formattedReminderTime } from "discourse/lib/bookmark";
|
||||
import discourseLater from "discourse/lib/later";
|
||||
import { recentlyCopied, showAlert } from "discourse/lib/post-action-feedback";
|
||||
import { smallUserAttrs } from "discourse/lib/user-list-attrs";
|
||||
import {
|
||||
NO_REMINDER_ICON,
|
||||
WITH_REMINDER_ICON,
|
||||
|
Loading…
x
Reference in New Issue
Block a user