fix: account preferences being overwritten, region notification, add autofocus to functions

This commit is contained in:
Arman committed 2023-12-10 18:44:35 +01:00
1 parent 6f6a631933
commit df330ced51
8 files changed
+41 -2

No files matched your search

@@ -27,6 +27,7 @@
label="Name"
id="name"
placeholder="Function name"
autofocus
bind:value={$createFunction.name}
required />
@@ -59,6 +59,7 @@
label="Name"
id="name"
placeholder="Function name"
autofocus
bind:value={$createFunction.name}
required />
{#if !showCustomId}
@@ -39,6 +39,7 @@
label="Name"
id="name"
placeholder="Function name"
autofocus
bind:value={$templateConfig.name}
required />
{#await loadRuntimes()}
@@ -16,6 +16,7 @@
id="name"
placeholder="Project name"
bind:value={$createProject.name}
autofocus
required />
{#if !showCustomId}
@@ -32,6 +32,25 @@
console.log(error);
}
}
async function unNotifyRegion(selectedRegion: Region) {
try {
let newPrefs = { ...prefs };
newPrefs.notifications = newPrefs.notifications ?? [];
newPrefs.notifications = [...newPrefs.notifications, selectedRegion.$id];
newPrefs.notifications = newPrefs.notifications.filter(
(region: string) => region !== selectedRegion.$id
);
const response = await sdk.forConsole.account.updatePrefs(newPrefs);
prefs = response.prefs;
addNotification({
type: 'info',
isHtml: true,
message: `You won't be notified anymore when the <b>${selectedRegion.name}</b> region is available`
});
} catch (error) {
console.log(error);
}
}
$: notifications = prefs?.notifications ?? [];
</script>
@@ -72,6 +91,17 @@
<span class="icon-bell" aria-hidden="true" />
<span class="text">Notify me</span>
</Pill>
{:else}
<Pill
selected
button
event="region_notify"
on:click={() => {
unNotifyRegion(region);
}}>
<span class="icon-check" aria-hidden="true" />
<span class="text">Notify me</span>
</Pill>
{/if}
{:else}
<Flag
@@ -11,7 +11,9 @@ export const load: LayoutLoad = async ({ params, depends }) => {
try {
const project = await sdk.forConsole.projects.get(params.project);
sdk.forConsole.account.updatePrefs({ organization: project.teamId });
const prefs = await sdk.forConsole.account.getPrefs();
const newPrefs = { ...prefs, organization: project.teamId };
sdk.forConsole.account.updatePrefs(newPrefs);
preferences.loadTeamPrefs(project.teamId);
if (isCloud) {
@@ -27,6 +27,7 @@
label="Name"
id="name"
placeholder="Function name"
autofocus
bind:value={$createFunction.name}
required />
<InputText
@@ -73,7 +73,9 @@
throw new Error((await res.json()).message);
} else {
await sdk.forConsole.account.createEmailSession(mail, pass);
await sdk.forConsole.account.updatePrefs({ code });
const prefs = await sdk.forConsole.account.getPrefs();
const newPrefs = { ...prefs, code };
await sdk.forConsole.account.updatePrefs(newPrefs);
await invalidate(Dependencies.ACCOUNT);
await goto(`${base}/console`);
trackEvent('submit_account_create', { code: code });