Use the official Discourse icon as a fallback
Show the bundled square icon for Discourse in the Add and Manage lists, and seed dashboard tiles with it until a forum's own favicon is resolved.
This commit is contained in:
1 parent
f341c228b8
commit
59d5b65e1a
6 files changed
+56
-7
No files matched your search
@@ -5,9 +5,6 @@ import {
|
||||
HOME_ASSISTANT_ICON_BACKGROUND,
|
||||
} from './home-assistant';
|
||||
|
||||
const PENCIL_ICON_PATH =
|
||||
'm16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10';
|
||||
|
||||
const CALENDAR_ICON_PATH =
|
||||
'M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5';
|
||||
|
||||
@@ -16,6 +13,10 @@ const BITCOIN_ICON_PATH =
|
||||
|
||||
export const FEEDBIN_ICON_URL = '/img/icons/feedbin.png';
|
||||
|
||||
// Official Discourse square icon, used for the Add/Manage lists and as the
|
||||
// dashboard tile's fallback until a forum's own favicon is resolved.
|
||||
export const DISCOURSE_ICON_URL = '/img/icons/discourse.svg';
|
||||
|
||||
// Metadata for every integration the app knows about. `hasSettings` controls
|
||||
// whether the Manage screen exposes an edit affordance; `reconnectable` marks
|
||||
// integrations with an auth token that can be refreshed; `supportsMultiple`
|
||||
@@ -26,8 +27,7 @@ export const INTEGRATIONS = [
|
||||
label: 'Discourse',
|
||||
description: 'Notifications from your discussion forums',
|
||||
colorClass: 'bg-indigo-500',
|
||||
iconPath: PENCIL_ICON_PATH,
|
||||
iconFill: false,
|
||||
iconUrl: DISCOURSE_ICON_URL,
|
||||
available: true,
|
||||
supportsMultiple: true,
|
||||
hasSettings: false,
|
||||
|
||||
+16
-1
@@ -1,7 +1,7 @@
|
||||
import Service, { service } from '@ember/service';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { SITE_GROUPS } from '../config/sites';
|
||||
import { FEEDBIN_ICON_URL } from '../config/integrations';
|
||||
import { DISCOURSE_ICON_URL, FEEDBIN_ICON_URL } from '../config/integrations';
|
||||
import { FEEDBIN_DEFAULT_URL } from '../config/feedbin';
|
||||
import {
|
||||
GITHUB_DEFAULT_URL,
|
||||
@@ -83,6 +83,21 @@ export default class SitesService extends Service {
|
||||
buildSite(key, integration) {
|
||||
this.integrationsById.set(key, integration);
|
||||
|
||||
// Discourse tiles start with the official icon so the tile is never empty;
|
||||
// `url` stays set so `resolveIcons` can replace it with the forum's own
|
||||
// favicon once (and if) one is discovered.
|
||||
if (integration.type === 'discourse') {
|
||||
return {
|
||||
id: key,
|
||||
type: 'discourse',
|
||||
groupId: this.groupIdForType('discourse'),
|
||||
label: labelForUrl(integration.url),
|
||||
url: integration.url,
|
||||
href: hrefForIntegration(integration),
|
||||
icon: { dataUrl: DISCOURSE_ICON_URL, maskable: true },
|
||||
};
|
||||
}
|
||||
|
||||
// Feedbin uses a bundled maskable icon and links to the configured
|
||||
// instance (the default Feedbin URL unless self-hosted). Leaving `url`
|
||||
// unset also keeps `resolveIcons` from replacing the bundled art with a
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="60" height="60" rx="10" fill="white" style="fill:white;fill-opacity:1;"/>
|
||||
<path d="M30.8855 10C20.5828 10 11.9082 18.357 11.9082 28.6687V48L30.8819 47.9817C41.1846 47.9817 49.5409 39.3026 49.5409 28.9945C49.5409 18.6864 41.1773 10 30.8855 10Z" fill="black" style="fill:black;fill-opacity:1;"/>
|
||||
<path d="M31.0684 17.2259C26.9934 17.2283 23.2203 19.3756 21.1354 22.8786C19.0505 26.3817 18.9615 30.7239 20.9011 34.3096L18.8083 41.045L26.3232 39.3465C30.6265 41.2863 35.6761 40.4151 39.0815 37.1452C42.4869 33.8754 43.5646 28.8632 41.8044 24.4816C40.0442 20.0999 35.7993 17.2282 31.0794 17.2259H31.0684Z" fill="#FFF9AE" style="fill:#FFF9AE;fill:color(display-p3 1.0000 0.9765 0.6824);fill-opacity:1;"/>
|
||||
<path d="M40.1116 35.9582C36.8266 40.1044 31.1487 41.4921 26.3232 39.3282L18.8083 41.0486L26.4585 40.1445C31.5301 43.1169 38.0236 41.8091 41.5506 37.1049C45.0776 32.4006 44.5156 25.7974 40.2443 21.7576C43.4512 25.9645 43.3966 31.8121 40.1116 35.9582Z" fill="#00AEEF" style="fill:#00AEEF;fill:color(display-p3 0.0000 0.6824 0.9373);fill-opacity:1;"/>
|
||||
<path d="M39.4647 33.7601C36.6304 38.2266 31.1286 40.1999 26.1037 38.5521L18.8083 41.0486L26.3232 39.3465C31.6752 41.7653 37.9894 39.7853 41.0042 34.7428C44.0189 29.7003 42.7763 23.1976 38.115 19.6235C41.7431 23.4724 42.2989 29.2936 39.4647 33.7601Z" fill="#00A94F" style="fill:#00A94F;fill:color(display-p3 0.0000 0.6627 0.3098);fill-opacity:1;"/>
|
||||
<path d="M21.5926 34.5658C19.4981 29.5146 21.2242 23.6859 25.7308 20.5915C30.2375 17.4971 36.294 17.982 40.2516 21.754C36.5863 16.9414 29.8341 15.7667 24.7603 19.0589C19.6865 22.351 18.0044 28.9984 20.9011 34.3096L18.8083 41.045L21.5926 34.5658Z" fill="#F15D22" style="fill:#F15D22;fill:color(display-p3 0.9451 0.3647 0.1333);fill-opacity:1;"/>
|
||||
<path d="M20.9008 34.3096C18.302 29.5068 19.4135 23.5398 23.5671 19.9962C27.7207 16.4525 33.7852 16.2972 38.1146 19.6235C33.9616 15.2483 27.1454 14.8005 22.4563 18.595C17.7671 22.3894 16.7795 29.152 20.1873 34.1302L18.8117 41.0486L20.9008 34.3096Z" fill="#D0232B" style="fill:#D0232B;fill:color(display-p3 0.8157 0.1373 0.1686);fill-opacity:1;"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -76,6 +76,9 @@ module(
|
||||
.dom()
|
||||
.containsText('Unread notifications from your Gitea instances');
|
||||
|
||||
assert
|
||||
.dom('[data-add="discourse"] img[src="/img/icons/discourse.svg"]')
|
||||
.exists();
|
||||
assert
|
||||
.dom('[data-add="feedbin"] img[src="/img/icons/feedbin.png"]')
|
||||
.exists();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'dashtab/tests/helpers';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { DISCOURSE_ICON_URL } from 'dashtab/config/integrations';
|
||||
|
||||
class FakeSitesService {
|
||||
@tracked all = [];
|
||||
@@ -173,6 +174,8 @@ module('Unit | Service | integrations', function (hooks) {
|
||||
const discourseRow = rows.find((row) => row.id === 'discourse-a');
|
||||
assert.strictEqual(discourseRow.label, 'Discourse');
|
||||
assert.strictEqual(discourseRow.byline, 'a.example.com');
|
||||
assert.strictEqual(discourseRow.iconUrl, DISCOURSE_ICON_URL);
|
||||
// A resolved instance icon takes precedence over the bundled fallback.
|
||||
assert.deepEqual(discourseRow.icon, {
|
||||
dataUrl: 'data:image/png;base64,a',
|
||||
maskable: true,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'dashtab/tests/helpers';
|
||||
import { DISCOURSE_ICON_URL } from 'dashtab/config/integrations';
|
||||
|
||||
module('Unit | Service | sites', function (hooks) {
|
||||
setupTest(hooks);
|
||||
@@ -53,6 +54,23 @@ module('Unit | Service | sites', function (hooks) {
|
||||
assert.strictEqual(item.groupId, 'discourse');
|
||||
});
|
||||
|
||||
test('a Discourse site falls back to the bundled official icon', async function (assert) {
|
||||
const storage = this.owner.lookup('service:storage');
|
||||
await storage.set('integrations', 'discourse-abc', {
|
||||
type: 'discourse',
|
||||
status: 'active',
|
||||
url: 'https://forum.example.com',
|
||||
apiKey: 'key',
|
||||
});
|
||||
|
||||
const service = this.owner.lookup('service:sites');
|
||||
await service.ready;
|
||||
|
||||
const [item] = service.all;
|
||||
assert.strictEqual(item.icon.dataUrl, DISCOURSE_ICON_URL);
|
||||
assert.true(item.icon.maskable);
|
||||
});
|
||||
|
||||
test('load builds the Feedbin site with a bundled maskable icon', async function (assert) {
|
||||
const storage = this.owner.lookup('service:storage');
|
||||
await storage.set('integrations', 'feedbin', {
|
||||
@@ -351,7 +369,8 @@ module('Unit | Service | sites', function (hooks) {
|
||||
|
||||
await service.refreshIcon('https://other.example.com');
|
||||
|
||||
assert.notOk(service.all[0].icon);
|
||||
// The bundled fallback is left untouched when nothing matches.
|
||||
assert.strictEqual(service.all[0].icon.dataUrl, DISCOURSE_ICON_URL);
|
||||
});
|
||||
|
||||
test('removeSource deletes the integration and reloads', async function (assert) {
|
||||
|
||||
Reference in new issue
Block a user