WIP: Add a Market Ticker settings section and drop the dashboard integration buttons

Add a Market Ticker section (Lucide chart-no-axes-combined icon) under Integrations that manages market ticker integrations. Bitcoin shows in the shared grid with settings/remove when enabled, and an 'Add Bitcoin Price Ticker' button otherwise.

Remove the dashboard Add/Manage Integrations buttons and the Manage Integrations dialog now that every integration is managed from Settings.

Shorten the Bitcoin description to 'Live BTC price'.
This commit is contained in:
raucao committed 2026-11-06 17:22:15 +04:00
1 parent f485093ab0
commit 6578c2d3f3
12 files changed
+260 -356

No files matched your search

-38
View File
@@ -1,38 +0,0 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { on } from '@ember/modifier';
import { service } from '@ember/service';
import AddList from './settings/integrations/add-list.gjs';
import ManageList from './settings/integrations/manage-list.gjs';
export default class IntegrationsToolbarComponent extends Component {
@service modal;
@action
openAdd() {
this.modal.open({ component: AddList, size: 'md' });
}
@action
openManage() {
this.modal.open({ component: ManageList, size: 'xl' });
}
<template>
<button
type="button"
{{on "click" this.openAdd}}
class="rounded-md px-2.5 py-1.5 text-white border border-white hover:bg-gray-950/10"
>
Add Integration
</button>
<button
type="button"
{{on "click" this.openManage}}
class="rounded-md px-2.5 py-1.5 text-white border border-white hover:bg-gray-950/10"
>
Manage Integrations
</button>
</template>
}
@@ -0,0 +1,97 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { service } from '@ember/service';
import { formFor } from '../../../../config/integration-forms';
import { MARKET_TICKER_TYPES } from '../../../../config/market-ticker';
import IntegrationGrid from './integration-grid.gjs';
// The dashboard market tickers (currently just Bitcoin), managed like the
// calendar sources. New asset integrations are added to MARKET_TICKER_TYPES.
export default class SettingsMarketTickerSection extends Component {
@service integrations;
@service modal;
get rows() {
return this.integrations.rows.filter((row) =>
MARKET_TICKER_TYPES.includes(row.type)
);
}
// Market ticker integrations that are available and not connected yet.
get addable() {
return this.integrations.all.filter(
(integration) =>
MARKET_TICKER_TYPES.includes(integration.id) &&
integration.available &&
!(
integration.supportsMultiple === false && integration.instances.length
)
);
}
@action
edit(row) {
const component = formFor(row.type);
if (!component) {
return;
}
this.modal.open({
component,
props: { mode: 'edit', integration: row },
size: 'md',
});
}
@action
async remove(row) {
await this.integrations.remove(row);
}
@action
add(integration) {
const component = formFor(integration.id);
if (!component) {
return;
}
this.modal.open({ component, props: { mode: 'add' }, size: 'md' });
}
<template>
<div class="min-h-0 flex-1 overflow-y-auto px-6 py-6">
<p class="max-w-prose text-sm text-gray-500">
Track asset prices on your dashboard.
</p>
<div class="mt-4">
<IntegrationGrid
@rows={{this.rows}}
@onEdit={{this.edit}}
@onRemove={{this.remove}}
@emptyLabel="No market tickers enabled yet."
/>
</div>
{{#if this.addable.length}}
<div class="mt-6 flex flex-wrap gap-2">
{{#each this.addable as |integration|}}
<button
type="button"
data-test-add={{integration.id}}
{{on "click" (fn this.add integration)}}
class="rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
>
Add
{{integration.label}}
</button>
{{/each}}
</div>
{{/if}}
</div>
</template>
}
@@ -1,118 +0,0 @@
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { service } from '@ember/service';
import { formFor } from '../../../config/integration-forms';
import { CALENDAR_TYPES } from '../../../config/calendar';
import { SITE_LINK_TYPES } from '../../../config/sites';
import Avatar from './avatar.gjs';
export default class SettingsIntegrationsManageList extends Component {
@service integrations;
@service modal;
get rows() {
// Calendars and site links are managed from their own settings sections.
return this.integrations.rows.filter(
(row) =>
!CALENDAR_TYPES.includes(row.type) &&
!SITE_LINK_TYPES.includes(row.type)
);
}
get hasMovedIntegrations() {
return this.integrations.rows.some(
(row) =>
CALENDAR_TYPES.includes(row.type) || SITE_LINK_TYPES.includes(row.type)
);
}
@action
edit(row) {
const component = formFor(row.type);
if (!component) {
return;
}
this.modal.replace({
component,
props: { mode: 'edit', integration: row },
size: 'md',
});
}
@action
async remove(row) {
await this.integrations.remove(row);
}
<template>
<div class="p-6">
<h3
id={{if @titleId @titleId "modal-title"}}
class="text-base font-semibold leading-6 text-gray-900"
>Manage Integrations</h3>
<div class="mt-2">
<p class="text-sm text-gray-500">
Review your connected integrations and adjust their settings.
</p>
</div>
{{#if this.rows.length}}
<div class="mt-4 min-h-72 max-h-[80vh] overflow-y-auto">
{{#each this.rows as |row|}}
<div
data-instance={{row.id}}
data-integration={{row.type}}
class="flex items-center gap-3 border-b border-gray-100 py-3 last:border-b-0"
>
<Avatar @integration={{row}} />
<div class="flex-auto text-left">
<p class="text-sm font-medium text-gray-700">{{row.label}}</p>
<p class="text-sm text-gray-500">{{row.byline}}</p>
{{#if row.error}}
<p class="text-sm text-red-600">{{row.error}}</p>
{{/if}}
</div>
{{#if row.hasSettings}}
<button
type="button"
data-test-settings
{{on "click" (fn this.edit row)}}
class="rounded-md px-2.5 py-1.5 text-sm font-semibold text-gray-700 ring-1 ring-inset ring-gray-300 hover:bg-gray-100"
>
Settings
</button>
{{/if}}
<button
type="button"
data-test-remove
{{on "click" (fn this.remove row)}}
class="rounded-md px-2.5 py-1.5 text-sm font-semibold text-red-600 ring-1 ring-inset ring-red-200 hover:bg-red-50"
>
Remove
</button>
</div>
{{/each}}
</div>
{{else}}
<div class="mt-6 rounded-xl bg-gray-50 p-6 text-center">
<p class="text-sm text-gray-500">
You don't have any other integrations connected yet.
</p>
<p class="mt-1 text-sm text-gray-400">
{{#if this.hasMovedIntegrations}}
Calendars and site links are managed in Settings.
{{else}}
Use "Add Integration" to connect one.
{{/if}}
</p>
</div>
{{/if}}
</div>
</template>
}
+1 -1
View File
@@ -43,7 +43,7 @@ export const INTEGRATIONS = [
{
id: 'bitcoin',
label: 'Bitcoin Price Ticker',
description: 'Live BTC price on your dashboard',
description: 'Live BTC price',
colorClass: 'bg-[#F7931A]',
iconPath: BITCOIN_ICON_PATH,
iconTransform: BITCOIN_ICON_TRANSFORM,
+4
View File
@@ -0,0 +1,4 @@
// The integration types that render as dashboard market tickers. New assets
// get added here as their integrations are built, the same way calendar types
// are grouped in `config/calendar.js`.
export const MARKET_TICKER_TYPES = ['bitcoin'];
+2
View File
@@ -1,4 +1,5 @@
import Events from '../components/settings/global-settings/sections/events.gjs';
import MarketTicker from '../components/settings/global-settings/sections/market-ticker.gjs';
import ProtocolGateway from '../components/settings/global-settings/sections/protocol-gateway.gjs';
import SiteLinks from '../components/settings/global-settings/sections/site-links.gjs';
@@ -8,6 +9,7 @@ import SiteLinks from '../components/settings/global-settings/sections/site-link
const CONTENT = {
'site-links': SiteLinks,
events: Events,
'market-ticker': MarketTicker,
'protocol-gateway': ProtocolGateway,
};
+16 -1
View File
@@ -4,7 +4,8 @@
// `icon` is an array of SVG path `d` strings (24x24 viewBox, stroke based) so
// the nav can stay data driven without a separate icon component. Icons come
// from Feather (https://feathericons.com) where an equivalent exists; the
// paint brush and globe are Heroicons because Feather has no match.
// paint brush and globe are Heroicons and the chart icon is Lucide, because
// Feather has no match.
export const SETTINGS_GROUPS = [
{
@@ -44,6 +45,20 @@ export const SETTINGS_GROUPS = [
'M3 10h18',
],
},
{
id: 'market-ticker',
label: 'Market Ticker',
description: 'Track asset prices on your dashboard.',
// Lucide chart-no-axes-combined.
icon: [
'M12 16v5',
'M16 14.639V21',
'M20 10.656V21',
'm22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15',
'M4 18.463V21',
'M8 14.656V21',
],
},
],
},
{
-7
View File
@@ -2,19 +2,12 @@ import { pageTitle } from 'ember-page-title';
import DefaultClock from '../components/default-clock.gjs';
import BitcoinTicker from '../components/bitcoin-ticker.gjs';
import SiteLinks from '../components/site-links.gjs';
import IntegrationsToolbar from '../components/integrations-toolbar.gjs';
import SettingsButton from '../components/settings-button.gjs';
import UpcomingEvents from '../components/upcoming-events.gjs';
<template>
{{pageTitle "New Tab"}}
<div
class="col-start-2 row-start-3 flex items-end justify-center gap-4 pb-12"
>
<IntegrationsToolbar />
</div>
<div class="col-start-1 row-start-1 row-span-2 flex items-start p-12">
<UpcomingEvents />
</div>
@@ -0,0 +1,138 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'dashtab/tests/helpers';
import { render, click } from '@ember/test-helpers';
import { tracked } from '@glimmer/tracking';
import MarketTicker from 'dashtab/components/settings/global-settings/sections/market-ticker';
class FakeSitesService {
@tracked all = [];
integrationFor() {
return undefined;
}
async removeSource() {}
}
class FakeNotificationsService {
stateFor() {
return { error: null, errorType: null };
}
}
class FakeBitcoinService {
@tracked enabled = false;
@tracked interval = 30000;
@tracked provider = 'coingecko';
disabled = false;
async disable() {
this.disabled = true;
this.enabled = false;
}
}
class FakeCalendarService {
instancesFor() {
return [];
}
}
class FakeModalService {
opened = null;
open(descriptor) {
this.opened = descriptor;
}
replace(descriptor) {
this.opened = descriptor;
}
}
function register(owner, overrides = {}) {
const sites = overrides.sites ?? new FakeSitesService();
const notifications =
overrides.notifications ?? new FakeNotificationsService();
const bitcoin = overrides.bitcoin ?? new FakeBitcoinService();
const calendar = overrides.calendar ?? new FakeCalendarService();
const modal = overrides.modal ?? new FakeModalService();
owner.register('service:sites', sites, { instantiate: false });
owner.register('service:notifications', notifications, {
instantiate: false,
});
owner.register('service:bitcoin', bitcoin, { instantiate: false });
owner.register('service:calendar', calendar, { instantiate: false });
owner.register('service:modal', modal, { instantiate: false });
return { sites, notifications, bitcoin, calendar, modal };
}
module(
'Integration | Component | settings/global-settings/sections/market-ticker',
function (hooks) {
setupRenderingTest(hooks);
test('offers to add Bitcoin when it is not enabled', async function (assert) {
register(this.owner);
await render(<template><MarketTicker /></template>);
assert.dom('[data-test-add="bitcoin"]').exists();
assert
.dom('[data-test-add="bitcoin"]')
.hasText('Add Bitcoin Price Ticker');
assert.dom('[data-instance="bitcoin"]').doesNotExist();
});
test('shows the enabled ticker in the grid instead of the add button', async function (assert) {
const bitcoin = new FakeBitcoinService();
bitcoin.enabled = true;
register(this.owner, { bitcoin });
await render(<template><MarketTicker /></template>);
assert.dom('[data-instance="bitcoin"]').exists();
assert.dom('[data-instance="bitcoin"] [data-test-settings]').exists();
assert.dom('[data-instance="bitcoin"] [data-test-remove]').exists();
assert.dom('[data-test-add="bitcoin"]').doesNotExist();
});
test('editing the ticker opens its form', async function (assert) {
const bitcoin = new FakeBitcoinService();
bitcoin.enabled = true;
const { modal } = register(this.owner, { bitcoin });
await render(<template><MarketTicker /></template>);
await click('[data-instance="bitcoin"] [data-test-settings]');
assert.ok(modal.opened.component);
assert.strictEqual(modal.opened.props.mode, 'edit');
});
test('adding Bitcoin opens its form in add mode', async function (assert) {
const { modal } = register(this.owner);
await render(<template><MarketTicker /></template>);
await click('[data-test-add="bitcoin"]');
assert.ok(modal.opened.component);
assert.strictEqual(modal.opened.props.mode, 'add');
});
test('removing the ticker disables it', async function (assert) {
const bitcoin = new FakeBitcoinService();
bitcoin.enabled = true;
register(this.owner, { bitcoin });
await render(<template><MarketTicker /></template>);
await click('[data-instance="bitcoin"] [data-test-remove]');
assert.true(bitcoin.disabled);
});
}
);
@@ -66,7 +66,7 @@ module(
assert.dom().containsText('Discourse');
assert.dom().containsText('Notifications from your discussion forums');
assert.dom().containsText('Bitcoin Price Ticker');
assert.dom().containsText('Live BTC price on your dashboard');
assert.dom().containsText('Live BTC price');
assert.dom().containsText('Feedbin');
assert.dom().containsText('Unread count from your Feedbin RSS reader');
assert.dom().containsText('GitHub');
@@ -1,189 +0,0 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'dashtab/tests/helpers';
import { render, click } from '@ember/test-helpers';
import { tracked } from '@glimmer/tracking';
import List from 'dashtab/components/settings/integrations/manage-list';
class FakeSitesService {
@tracked all = [];
removed = [];
integrationFor(id) {
return this.records?.[id];
}
async removeSource(id) {
this.removed.push(id);
this.all = this.all.filter((site) => site.id !== id);
}
}
class FakeNotificationsService {
states = {};
stateFor(site) {
return this.states[site.id] ?? { error: null, errorType: null };
}
}
class FakeBitcoinService {
@tracked enabled = false;
@tracked interval = 30000;
@tracked provider = 'coingecko';
disabled = false;
async disable() {
this.disabled = true;
this.enabled = false;
}
}
class FakeCalendarService {
instancesByType = { 'calendar-caldav': [], 'calendar-ics': [] };
instancesFor(type) {
return this.instancesByType[type] ?? [];
}
async remove() {}
}
class FakeModalService {
replaced = null;
open(descriptor) {
this.replaced = descriptor;
}
replace(descriptor) {
this.replaced = descriptor;
}
}
function register(owner, overrides = {}) {
const sites = overrides.sites ?? new FakeSitesService();
const notifications =
overrides.notifications ?? new FakeNotificationsService();
const bitcoin = overrides.bitcoin ?? new FakeBitcoinService();
const calendar = overrides.calendar ?? new FakeCalendarService();
const modal = overrides.modal ?? new FakeModalService();
owner.register('service:sites', sites, { instantiate: false });
owner.register('service:notifications', notifications, {
instantiate: false,
});
owner.register('service:bitcoin', bitcoin, { instantiate: false });
owner.register('service:calendar', calendar, { instantiate: false });
owner.register('service:modal', modal, { instantiate: false });
return { sites, notifications, bitcoin, calendar, modal };
}
module(
'Integration | Component | settings/integrations/manage-list',
function (hooks) {
setupRenderingTest(hooks);
test('it shows an empty state when nothing is active', async function (assert) {
register(this.owner);
await render(<template><List /></template>);
assert.dom('[data-instance]').doesNotExist();
assert
.dom()
.containsText("You don't have any other integrations connected yet");
});
test('it lists the remaining integrations', async function (assert) {
const bitcoin = new FakeBitcoinService();
bitcoin.enabled = true;
register(this.owner, { bitcoin });
await render(<template><List /></template>);
assert.dom('[data-instance="bitcoin"]').exists();
assert
.dom('[data-instance="bitcoin"]')
.containsText('Bitcoin Price Ticker');
});
test('it hides calendars and site links, which are managed in Settings', async function (assert) {
const sites = new FakeSitesService();
sites.all = [
{
id: 'discourse-abc',
type: 'discourse',
label: 'forum.example.com',
url: 'https://forum.example.com',
},
];
const calendar = new FakeCalendarService();
calendar.instancesByType['calendar-ics'] = [
{
id: 'ics-1',
type: 'calendar-ics',
label: 'Holidays',
url: 'https://example.org/h.ics',
},
];
const bitcoin = new FakeBitcoinService();
bitcoin.enabled = true;
register(this.owner, { sites, calendar, bitcoin });
await render(<template><List /></template>);
assert.dom('[data-instance="bitcoin"]').exists();
assert.dom('[data-instance="discourse-abc"]').doesNotExist();
assert.dom('[data-instance="ics-1"]').doesNotExist();
});
test('the empty state points to Settings when calendars or site links exist', async function (assert) {
const sites = new FakeSitesService();
sites.all = [
{
id: 'discourse-abc',
type: 'discourse',
label: 'forum.example.com',
url: 'https://forum.example.com',
},
];
register(this.owner, { sites });
await render(<template><List /></template>);
assert.dom().containsText('managed in Settings');
});
test('editing an integration opens its form', async function (assert) {
const bitcoin = new FakeBitcoinService();
bitcoin.enabled = true;
bitcoin.interval = 60000;
const { modal } = register(this.owner, { bitcoin });
await render(<template><List /></template>);
await click('[data-instance="bitcoin"] [data-test-settings]');
assert.strictEqual(modal.replaced.props.mode, 'edit');
assert.strictEqual(modal.replaced.props.integration.interval, 60000);
});
test('removing an instance removes the source', async function (assert) {
const bitcoin = new FakeBitcoinService();
bitcoin.enabled = true;
register(this.owner, { bitcoin });
await render(<template><List /></template>);
await click('[data-instance="bitcoin"] [data-test-remove]');
assert.true(bitcoin.disabled);
});
}
);
+1 -1
View File
@@ -183,7 +183,7 @@ module('Unit | Service | integrations', function (hooks) {
const bitcoinRow = rows.find((row) => row.type === 'bitcoin');
assert.strictEqual(bitcoinRow.label, 'Bitcoin Price Ticker');
assert.strictEqual(bitcoinRow.byline, 'Live BTC price on your dashboard');
assert.strictEqual(bitcoinRow.byline, 'Live BTC price');
});
test('remove delegates to each integration adapter', async function (assert) {