@octarq/plugin-links 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,7 @@
1
1
  import { Panel, AreaChart, useTranslation, useOverviewData, type StatKV } from "@octarq/plugin-sdk";
2
- import { useIncludeBot } from "../store";
3
- import { BotToggle } from "../components/BotToggle";
4
2
 
5
3
  export default function ClicksChartWidget() {
6
- const [includeBot, setIncludeBot] = useIncludeBot();
7
- const o = useOverviewData(includeBot);
4
+ const o = useOverviewData();
8
5
  const { t } = useTranslation();
9
6
 
10
7
  if (!o || o.series === undefined) return null;
@@ -13,9 +10,7 @@ export default function ClicksChartWidget() {
13
10
  const clicks30d = (o.clicks30d as number) ?? 0;
14
11
  const botClicks30d = (o.botClicks30d as number) ?? 0;
15
12
 
16
- const botLabel = includeBot
17
- ? t("links.botInclLabel", { count: botClicks30d })
18
- : t("links.botHiddenLabel", { count: botClicks30d });
13
+ const botLabel = t("links.botHiddenLabel", { count: botClicks30d });
19
14
 
20
15
  return (
21
16
  <Panel
@@ -26,7 +21,6 @@ export default function ClicksChartWidget() {
26
21
  <span className="text-sm text-muted-foreground">
27
22
  {t("links.clicksTotal", { count: clicks30d })} · {botLabel}
28
23
  </span>
29
- <BotToggle value={includeBot} onChange={setIncludeBot} />
30
24
  </div>
31
25
  }
32
26
  >
@@ -1,9 +1,7 @@
1
1
  import { Panel, BarList, useTranslation, useOverviewData, type StatKV } from "@octarq/plugin-sdk";
2
- import { useIncludeBot } from "../store";
3
2
 
4
3
  export default function DevicesPanelWidget() {
5
- const [includeBot] = useIncludeBot();
6
- const o = useOverviewData(includeBot);
4
+ const o = useOverviewData();
7
5
  const { t } = useTranslation();
8
6
 
9
7
  if (!o || o.devices === undefined) return null;
@@ -11,7 +9,7 @@ export default function DevicesPanelWidget() {
11
9
  const devices = (o.devices as StatKV[]) ?? [];
12
10
 
13
11
  return (
14
- <Panel title={`${t("links.devices")}${includeBot ? " " + t("links.inclBots") : ""}`}>
12
+ <Panel title={`${t("links.devices")}`}>
15
13
  <BarList rows={devices} />
16
14
  </Panel>
17
15
  );
@@ -1,19 +1,16 @@
1
1
  import { Panel, BarList, useTranslation, useOverviewData, type StatKV } from "@octarq/plugin-sdk";
2
- import { useIncludeBot } from "../store";
3
2
 
4
3
  export default function TopCitiesPanelWidget() {
5
- const [includeBot] = useIncludeBot();
6
- const o = useOverviewData(includeBot);
4
+ const o = useOverviewData();
7
5
  const { t } = useTranslation();
8
6
 
9
7
  if (!o || o.cities === undefined) return null;
10
8
 
11
9
  const cities = (o.cities as StatKV[]) ?? [];
12
- // cities only spans the last 30 days; clicks30d is the matching window.
13
10
  const hasClicksInWindow = (o.clicks30d ?? 0) > 0;
14
11
 
15
12
  return (
16
- <Panel title={`${t("links.topCities")}${includeBot ? " " + t("links.inclBots") : ""}`}>
13
+ <Panel title={`${t("links.topCities")}`}>
17
14
  <BarList rows={cities} empty={
18
15
  hasClicksInWindow ? (
19
16
  <span>
@@ -53,24 +53,20 @@ describe("TopLinksPanelWidget title priority", () => {
53
53
  </MemoryRouter>
54
54
  );
55
55
 
56
- // Link 1: title priority
57
56
  const titleEl = screen.getByText("Summer Promotion");
58
57
  expect(titleEl).toBeDefined();
59
58
  expect(titleEl.className).toContain("text-foreground");
60
59
  expect(titleEl.className).toContain("font-medium");
61
60
 
62
- // Link 1: secondary slug
63
61
  const secondarySlug = screen.getByText("go.octarq.com/promo-2026");
64
62
  expect(secondarySlug).toBeDefined();
65
63
  expect(secondarySlug.className).toContain("text-muted-foreground");
66
64
 
67
- // Link 1: tags (first 2 badges visible + overflow badge "+1")
68
65
  expect(screen.getByTitle("marketing")).toBeDefined();
69
66
  expect(screen.getByTitle("summer")).toBeDefined();
70
- expect(screen.getByTitle("campaign")).toBeDefined(); // overflow title
67
+ expect(screen.getByTitle("campaign")).toBeDefined();
71
68
  expect(screen.getByText("+1")).toBeDefined();
72
69
 
73
- // Link 2: fallback to slug when title is empty
74
70
  expect(screen.getByText("untitled-link")).toBeDefined();
75
71
  expect(screen.getByText("/untitled-link")).toBeDefined();
76
72
  });
@@ -27,7 +27,7 @@ export default function TopLinksPanelWidget() {
27
27
  <button
28
28
  key={l.id}
29
29
  onClick={() => nav("/links")}
30
- className="flex w-full items-center justify-between rounded-xl px-3 py-2 text-left text-sm hover:bg-surface-hover transition-colors"
30
+ className="flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-sm hover:bg-surface-hover transition-colors"
31
31
  >
32
32
  <div className="min-w-0 flex-1 pr-2">
33
33
  <div className="flex items-center gap-1.5 min-w-0">
@@ -1,18 +0,0 @@
1
- import { useTranslation } from "@octarq/plugin-sdk";
2
-
3
- export function BotToggle({ value, onChange }: { value: boolean; onChange: (v: boolean) => void }) {
4
- const { t } = useTranslation();
5
- return (
6
- <button
7
- onClick={() => onChange(!value)}
8
- title={value ? t("links.hideBotTraffic") : t("links.showBotTraffic")}
9
- className={`flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium transition ${
10
- value
11
- ? "bg-warning-bg text-warning-fg border border-warning-border hover:brightness-95"
12
- : "bg-surface-hover text-muted-foreground hover:bg-surface-hover"
13
- }`}
14
- >
15
- <span>{value ? t("links.botsOn") : t("links.botsOff")}</span>
16
- </button>
17
- );
18
- }
package/store.ts DELETED
@@ -1,21 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- let globalIncludeBot = false;
4
- const listeners = new Set<(val: boolean) => void>();
5
-
6
- export function setIncludeBot(val: boolean) {
7
- globalIncludeBot = val;
8
- listeners.forEach((l) => l(val));
9
- }
10
-
11
- export function useIncludeBot(): [boolean, (val: boolean) => void] {
12
- const [includeBot, setLocal] = useState(globalIncludeBot);
13
- useEffect(() => {
14
- const listener = (val: boolean) => setLocal(val);
15
- listeners.add(listener);
16
- return () => {
17
- listeners.delete(listener);
18
- };
19
- }, []);
20
- return [includeBot, setIncludeBot];
21
- }