Capybara
Yeah I'm not too sure how to do stuff like that yet, and especially with extensions.
I think, in this case with the Masquerade extension, we would first need to figure out what the correct target location identifier is within the Masquerade framework.
(*Sorry...๐
I still don't know the correct terms.)
I'm thinking the target location identifier that you might be needing to achieve this, may possibly be something we could find hidden within the Masquerade extension documents(ยฟ?)
So I just had a quick look, although I'm really not sure exactly what I should be looking for aye.
What do think?
(Here's some of the Masquerade documents I checked.)
/* masquerade/src/forum/mutateUserHero.js */
import { extend } from 'flarum/common/extend';
import app from 'flarum/forum/app';
import UserCard from 'flarum/forum/components/UserCard';
import TypeFactory from './types/TypeFactory';
export default function mutateUserHero() {
extend(UserCard.prototype, 'infoItems', function (items) {
const answers = app.forum.attribute('canViewMasquerade') ? this.attrs.user.bioFields() || [] : [];
items.add(
'masquerade-bio',
<div>
{answers.map((answer) => {
const field = answer.attribute('field');
const type = TypeFactory.typeForField({
field,
value: answer.content(),
});
return type.answerField();
})}
</div>
);
});
}
/* masquerade/js/src/forum/index.js */
import app from 'flarum/forum/app';
import User from 'flarum/common/models/User';
import Field from './../lib/models/Field';
import Answer from './../lib/models/Answer';
import Model from 'flarum/common/Model';
import addProfilePane from './addProfilePane';
import mutateUserHero from './mutateUserHero';
// Exports
import ProfileConfigurePane from './panes/ProfileConfigurePane';
import ProfilePane from './panes/ProfilePane';
import RootMasqueradePane from './panes/RootMasqueradePane';
import BaseField from './types/BaseField';
import BooleanField from './types/BooleanField';
import EmailField from './types/EmailField';
import SelectField from './types/SelectField';
import TypeFactory from './types/TypeFactory';
import UrlField from './types/UrlField';
app.initializers.add('fof-masquerade', (app) => {
app.store.models['masquerade-field'] = Field;
app.store.models['masquerade-answer'] = Answer;
User.prototype.bioFields = Model.hasMany('bioFields');
User.prototype.masqueradeAnswers = Model.hasMany('masqueradeAnswers');
User.prototype.canEditMasqueradeProfile = Model.attribute('canEditMasqueradeProfile');
addProfilePane();
mutateUserHero();
});
const components = {
ProfileConfigurePane,
ProfilePane,
RootMasqueradePane,
};
const types = {
BaseField,
BooleanField,
EmailField,
SelectField,
TypeFactory,
UrlField,
};
export { components, types };
/* masquerade/js/src/forum/addProfilePane.js */
import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import LinkButton from 'flarum/common/components/LinkButton';
import UserPage from 'flarum/forum/components/UserPage';
import RootMasqueradePane from './panes/RootMasqueradePane';
export default function addProfilePane() {
app.routes['fof-masquerade'] = {
path: '/u/:username/masquerade',
resolver: {
onmatch() {
if (!app.forum.attribute('canViewMasquerade')) throw new Error();
return RootMasqueradePane;
},
},
};
extend(UserPage.prototype, 'navItems', function (items) {
if (app.forum.attribute('canViewMasquerade') || this.user.canEditMasqueradeProfile()) {
const edit = this.user.canEditMasqueradeProfile();
items.add(
'masquerade',
LinkButton.component(
{
href: app.route('fof-masquerade', { username: this.user.slug() }),
icon: 'far fa-id-card',
'data-editProfile': edit,
},
app.translator.trans(`fof-masquerade.forum.buttons.${edit ? 'edit' : 'view'}-profile`)
),
200
);
}
});
}
Masquerade Docs