Files
wekan/client/components/main/activityFeed.js
T
Lauri Ojansivu 2cc6b93ed9 Version Control, the activity feed and the email list render titles as Markdown.
Titles, names and labels are Markdown in WeKan - links, emphasis, emoji -
but Board View / Version Control showed "Azure [issues](https://...)"
and the like as text, the all-boards activity feed did the same with the
cards and boards it names, and the email view's sidebar showed its lists
and labels raw ("Demo + Wishes 🌈").

inlineViewer (client/components/main/editor.jade) is the viewer itself -
Markdown, emoji, mentions, and the Admin Panel's security settings for
links and code - laid out inline at the size of the line it is in. These
views use it for every issue, milestone, label, release, wiki page and
board title, the activity sentence and its card and board, and the email
folders and row labels. An attachment's file name in its download link
stays a file name.

A rendered title can hold a link, and a link inside a link is not one:
the titles and labels that open or filter are spans with role=link now,
which Enter and Space open too, and a click on a link inside a title
opens that link instead.

tests/renderedTitles.test.cjs fails on any title-like value interpolated
as text in these views and pins the role=link spans.

Thanks to xet7 !
2026-10-14 23:07:30 +03:00

61 lines
2.5 KiB
JavaScript

import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import { TAPi18n } from '/imports/i18n';
import { formatDateForDisplay } from '/client/lib/dateDisplay';
const { activitySentenceKey, withoutUnfilledPlaceholders, humanActivityType } = require('/models/lib/activityFeed');
const PAGE = 50;
// #2026 / #1377: the all-boards activity feed, a page at a time.
Template.activityFeed.onCreated(function () {
this.entries = new ReactiveVar([]);
this.hasMore = new ReactiveVar(false);
this.load = before => Meteor.call('allBoardsActivityFeed', { limit: PAGE, ...(before ? { before } : {}) }, (error, page) => {
if (error) return;
this.entries.set([...(before ? this.entries.get() : []), ...(page || [])]);
this.hasMore.set((page || []).length === PAGE);
});
this.load();
});
Template.activityFeed.helpers({
entries() { return Template.instance().entries.get(); },
hasMore() { return Template.instance().hasMore.get(); },
timeText() { return this.createdAt ? formatDateForDisplay(new Date(this.createdAt), true) : ''; },
// The same sentence the notifications use for this kind of activity, with
// what it names filled in (models/lib/activityFeed.js feedParams).
description() {
const key = this.sentenceKey || activitySentenceKey(this.activityType);
const params = this.params || { card: this.cardTitle, list: this.listTitle, board: this.boardTitle };
const text = TAPi18n.__(key, params);
// A kind of activity with no sentence of its own reads as its words.
if (text === key) return humanActivityType(this.activityType);
return withoutUnfilledPlaceholders(text);
},
cardUrl() {
return FlowRouter.path('card', { boardId: this.boardId, slug: this.boardSlug, cardId: this.cardId });
},
});
Template.activityFeed.events({
// The card opens from its title, unless a link inside the title was clicked.
'click .js-activity-feed-card'(event) {
const link = event.target.closest && event.target.closest('a[href]');
if (link && event.currentTarget.contains(link)) return;
event.preventDefault();
FlowRouter.go(event.currentTarget.dataset.url);
},
'keydown .js-activity-feed-card'(event) {
if (event.key !== 'Enter' && event.key !== ' ') return;
event.preventDefault();
event.currentTarget.click();
},
'click .js-activity-feed-more'(event, tpl) {
event.preventDefault();
const list = tpl.entries.get();
const last = list[list.length - 1];
if (last) tpl.load(new Date(last.createdAt));
},
});