Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 2, 2024
2 parents 473f0cf + 1859a56 commit d6ece9d
Show file tree
Hide file tree
Showing 102 changed files with 4,905 additions and 6,282 deletions.
2 changes: 1 addition & 1 deletion src/addons/AddOnPin.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" context="module">
import { writable, type Writable } from "svelte/store";
import type { AddOnListItem } from "./types.ts";
import type { AddOnListItem } from "./types";
export const pinned: Writable<AddOnListItem[]> = writable([]);
</script>
Expand Down
11 changes: 1 addition & 10 deletions src/addons/browser/AddOnList.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
<script lang="ts" context="module">
import type { AddOnListItem } from "../types.ts";
export interface AddOnList {
items?: AddOnListItem[];
loading: boolean;
error?: string | null;
}
</script>

<script lang="ts">
import { _ } from "svelte-i18n";
import Button from "../../common/Button.svelte";
Expand All @@ -16,6 +6,7 @@
import Loader from "../../common/Loader.svelte";
import ListItem from "./AddOnListItem.svelte";
import type { AddOnListItem } from "../types";
export let items: AddOnListItem[];
export let loading: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/addons/browser/AddOnListItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import AddOnPin from "../AddOnPin.svelte";
import AddOnPopularity from "../Popularity.svelte";
import type { AddOnListItem } from "../types.js";
import type { AddOnListItem } from "../types";
import PremiumBadge from "../../premium-credits/PremiumBadge.svelte";
export let addon: AddOnListItem;
Expand Down
4 changes: 2 additions & 2 deletions src/addons/browser/Browser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script lang="ts">
import { _ } from "svelte-i18n";
import AddOnList from "./AddOnList.svelte";
import type { AddOnListItem } from "../types.ts";
import type { AddOnListItem } from "../types";
import Filters from "./Filters.svelte";
import Categories from "./Categories.svelte";
import { buildParams, buildUrl, filter } from "./browser";
Expand Down Expand Up @@ -52,7 +52,7 @@
return data;
})
.catch((err) => {
error = err;
error = err.detail;
loading = false;
return {};
});
Expand Down
4 changes: 2 additions & 2 deletions src/addons/browser/stories/AddOnList.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts" context="module">
import { Story, Template } from "@storybook/addon-svelte-csf";
import defaultAddons from "../../fixtures/addons.json";
import { addonsList } from "../../../test/fixtures/addons";
import AddOnList from "../AddOnList.svelte";
const args = {
items: defaultAddons,
items: addonsList.results,
loading: false,
error: null,
};
Expand Down
2 changes: 1 addition & 1 deletion src/addons/browser/stories/Browser.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Browser from "../Browser.svelte";
const args = { visible: true };
import { addons } from "./mockData";
import { addons } from "../../../test/handlers/addons";
export const meta = {
title: "Add-Ons / Browser",
Expand Down
21 changes: 0 additions & 21 deletions src/addons/browser/stories/mockData.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/addons/dispatch/Dispatch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import { onMount, tick } from "svelte";
import { _ } from "svelte-i18n";
import type { AddOnListItem } from "../types.ts";
import type { Event } from "../runs/ScheduledEvent.svelte";
import type { AddOnListItem, Event } from "../types";
import Button from "../../common/Button.svelte";
import Drawer from "../../common/Drawer.svelte";
Expand Down
9 changes: 2 additions & 7 deletions src/addons/dispatch/Form.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
<script context="module" lang="ts">
import type { Event } from "../runs/ScheduledEvent.svelte";
import { writable } from "svelte/store";
export const values = writable({ event: "disabled", selection: null });
export interface eventOptions {
name: string;
events: string[];
}
</script>

<script lang="ts">
Expand All @@ -16,11 +10,12 @@
import { _ } from "svelte-i18n";
import { autofield } from "./fields/index.js";
import type { Event, EventOptions } from "../types";
import Button from "../../common/Button.svelte";
export let properties: any = {};
export let required = [];
export let eventOptions: eventOptions;
export let eventOptions: EventOptions;
export let event: Event = null;
const ajv = new Ajv();
Expand Down
4 changes: 2 additions & 2 deletions src/addons/dispatch/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { _ } from "svelte-i18n";
import type { AddOnListItem } from "../types.ts";
import type { AddOnListItem } from "../types";
import BackArrow from "../../common/icons/BackArrow.svelte";
import Button from "../../common/Button.svelte";
import GitHubIcon from "svelte-octicons/lib/MarkGithub16.svelte";
Expand All @@ -13,7 +13,7 @@
export let addon: AddOnListItem;
$: author = addon.repository.split("/")[0];
$: author = addon.repository?.split("/")[0];
$: isPremium = addon?.parameters.categories?.includes("premium") ?? false;
async function onShare() {
Expand Down
4 changes: 2 additions & 2 deletions src/addons/dispatch/ScheduledInset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { _ } from "svelte-i18n";
import { onMount } from "svelte";
import type { AddOnListItem } from "../types.ts";
import ScheduledEvent, { type Event } from "../runs/ScheduledEvent.svelte";
import type { AddOnListItem, Event } from "../types";
import ScheduledEvent from "../runs/ScheduledEvent.svelte";
import { baseApiUrl } from "../../api/base.js";
Expand Down
71 changes: 25 additions & 46 deletions src/addons/dispatch/stories/Dispatch.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
<script lang="ts" context="module">
import { rest } from "msw";
import { Story, Template } from "@storybook/addon-svelte-csf";
import Dispatch from "../Dispatch.svelte";
import addons from "../../fixtures/addons.json";
import * as eventFixture from "../../fixtures/event.json";
import { baseApiUrl } from "../../../api/base";
import {
addonsList,
event as eventFixture,
scheduled as klaxon,
} from "../../../test/fixtures/addons";
import { scheduled, send, pin } from "../../../test/handlers/addons";
const { addon: klaxon, ...event } = eventFixture;
const mockScheduleUrl = new URL(
"/api/addon_events/:event",
baseApiUrl,
).toString();
const scheduleSuccess = rest.all(mockScheduleUrl, (req, res, ctx) =>
res(ctx.json({})),
);
const scheduleLoading = rest.all(mockScheduleUrl, (req, res, ctx) =>
res(ctx.delay("infinite")),
);
const scheduleError = rest.all(mockScheduleUrl, (req, res, ctx) =>
res(ctx.status(400, "Something went wrong")),
);
const mockSendUrl = new URL("/api/addon_runs/", baseApiUrl).toString();
const sendSuccess = rest.all(mockSendUrl, (req, res, ctx) =>
res(ctx.json({})),
);
const sendLoading = rest.all(mockSendUrl, (req, res, ctx) =>
res(ctx.delay("infinite")),
);
const sendError = rest.all(mockSendUrl, (req, res, ctx) =>
res(ctx.status(400, "Something went wrong")),
);
const mockPinUrl = new URL("/api/addons/:id", baseApiUrl).toString();
const pinSuccess = rest.all(mockPinUrl, (req, res, ctx) => res(ctx.json({})));
const pinLoading = rest.all(mockPinUrl, (req, res, ctx) =>
res(ctx.delay("infinite")),
);
const pinError = rest.all(mockPinUrl, (req, res, ctx) =>
res(ctx.status(400, "Something went wrong")),
);
const { addon, ...event } = eventFixture;
const addons = addonsList.results;
let args = {
visible: true,
Expand All @@ -62,21 +31,31 @@

<Story
name="Success"
args={{ visible: true, addon: klaxon, event }}
parameters={{ msw: { handlers: [scheduleSuccess, sendSuccess, pinSuccess] } }}
args={{ visible: true, addon: klaxon.results[0].addon, event }}
parameters={{
msw: { handlers: [scheduled.data, send.success, pin.success] },
}}
/>
<Story
name="Error"
args={{ visible: true, addon: klaxon, event }}
parameters={{ msw: { handlers: [scheduleError, sendError, pinError] } }}
args={{ visible: true, addon: klaxon.results[0].addon, event }}
parameters={{ msw: { handlers: [scheduled.error, send.error, pin.error] } }}
/>
<Story
name="Loading"
args={{ visible: true, addon: klaxon, event }}
parameters={{ msw: { handlers: [scheduleLoading, sendLoading, pinLoading] } }}
args={{ visible: true, addon: klaxon.results[0].addon, event }}
parameters={{
msw: { handlers: [scheduled.loading, send.loading, pin.loading] },
}}
/>

<Story name="Klaxon" args={{ visible: true, addon: klaxon, event }} />
<Story
name="Klaxon"
args={{ visible: true, addon: klaxon.results[0].addon, event }}
parameters={{
msw: { handlers: [scheduled.loading, send.loading, pin.loading] },
}}
/>

<Story name="PDF Exporter" args={{ ...args, addon: addons[0] }} />

Expand Down
4 changes: 3 additions & 1 deletion src/addons/dispatch/stories/Form.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import Form, { values } from "../Form.svelte";
import * as addons from "../../fixtures/addons.json";
import { addonsList } from "../../../test/fixtures/addons";
const addons = addonsList.results;
export const meta = {
title: "Add-Ons / Dispatch / Form",
Expand Down
4 changes: 3 additions & 1 deletion src/addons/dispatch/stories/Header.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import Header from "../Header.svelte";
import * as addons from "../../fixtures/addons.json";
import { addonsList } from "../../../test/fixtures/addons";
const addons = addonsList.results;
export const meta = {
title: "Add-Ons / Dispatch / Header",
Expand Down
4 changes: 3 additions & 1 deletion src/addons/dispatch/stories/Premium.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import Premium from "../Premium.svelte";
import addons from "../../fixtures/addons.json";
import { addonsList } from "../../../test/fixtures/addons";
const addons = addonsList.results;
const individualOrg = {
id: 4,
Expand Down
3 changes: 1 addition & 2 deletions src/addons/dispatch/stories/ScheduledInset.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { Story, Template } from "@storybook/addon-svelte-csf";
import ScheduledInset from "../ScheduledInset.svelte";
import addon from "../../fixtures/addon.json";
import klaxon from "../../fixtures/klaxon-scheduled.json";
import { addon, scheduled as klaxon } from "../../../test/fixtures/addons";
export const meta = {
title: "Add-Ons / Dispatch / Scheduled Inset",
Expand Down
Loading

0 comments on commit d6ece9d

Please sign in to comment.