Skip to content

Commit

Permalink
Chromatic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Jan 16, 2024
1 parent 2301ced commit 6df4dcb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 33 deletions.
5 changes: 3 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ const preview: Preview = {
},
},
},
// Provide the MSW addon loader globally
loaders: [mswLoader],
};

// Provide the MSW addon loader globally
export const loaders = [mswLoader];

export let decorators = [mockDateDecorator];

export default preview;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@
"engine": 18,
"browserslist": "> 0.25%, not dead",
"msw": {
"workerDirectory": "public"
"workerDirectory": "./public"
}
}
46 changes: 23 additions & 23 deletions src/common/dialog/RevisionsDialog.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { onMount } from "svelte";
import { _ } from "svelte-i18n";
import { getMe } from "../../api/orgAndUser.js";
import {
Expand All @@ -25,23 +26,31 @@
return b.version - a.version;
}) ?? null;
let getMePromise = getMe();
function retryGetMe() {
getMePromise = getMe();
let user;
let loading = false;
let error;
async function load() {
loading = true;
try {
user = await getMe();
} catch {
error = true;
}
loading = false;
}
onMount(load);
</script>

{#await getMePromise}
<Loader active>
<Loader active={loading}>
{#if error}
<div class="mcontent">
<header>
<h3>{$_("dialogRevisionsDialog.heading")}</h3>
<PremiumBadge />
</header>
<ErrorMessage message={$_("dialogRevisionsDialog.error")}
><Button caution action on:click={load}>Retry</Button></ErrorMessage
>
</div>
</Loader>
{:then user}
<Loader active={false}>
{:else}
<div class="mcontent">
<header>
<h3>{$_("dialogRevisionsDialog.heading")}</h3>
Expand Down Expand Up @@ -115,17 +124,8 @@
/>
{/if}
</div>
</Loader>
{:catch}
<Loader active={false}>
<div class="mcontent">
<ErrorMessage message={$_("dialogRevisionsDialog.error")}
><Button caution action on:click={retryGetMe}>Retry</Button
></ErrorMessage
>
</div>
</Loader>
{/await}
{/if}
</Loader>

<style>
.mcontent {
Expand Down
35 changes: 29 additions & 6 deletions src/common/dialog/stories/RevisionsDialog.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
component: RevisionsDialog,
parameters: {
layout: "centered",
chromatic: { delay: 300 },
msw: {
handlers: [revisionControl.success, mockGetMe.data],
},
chromatic: { delay: 1000 },
},
argTypes: {
enabled: {
Expand Down Expand Up @@ -75,13 +72,39 @@
await expect(downloadButtons[0]).toHaveAttribute("target", "download");
});
}}
parameters={{
msw: {
handlers: [revisionControl.success, mockGetMe.data],
},
}}
/>
<Story
name="With Zero Revisions"
args={{ ...args, revisions: [] }}
parameters={{
msw: {
handlers: [revisionControl.success, mockGetMe.data],
},
}}
/>
<Story name="With Zero Revisions" args={{ ...args, revisions: [] }} />
<Story
name="With Many Revisions"
args={{ ...args, revisions: manyRevisions }}
parameters={{
msw: {
handlers: [revisionControl.success, mockGetMe.data],
},
}}
/>
<Story
name="Disabled Revision Control"
args={{ ...args, enabled: false }}
parameters={{
msw: {
handlers: [revisionControl.success, mockGetMe.data],
},
}}
/>
<Story name="Disabled Revision Control" args={{ ...args, enabled: false }} />
<Story
name="With Change Loading"
{args}
Expand Down
4 changes: 3 additions & 1 deletion src/manager/orgsAndUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ export function getUpgradeURL(org) {
}

export async function triggerPremiumUpgradeFlow(org) {
window?.open(getUpgradeUrl(org));
if (org) {
window?.open(getUpgradeUrl(org));
}
}

// TODO: Handle flow for purchasing premium credits (#342)
Expand Down

0 comments on commit 6df4dcb

Please sign in to comment.