diff --git a/src/routes/applications/[id]/previews/index.svelte b/src/routes/applications/[id]/previews/index.svelte
index 546d9c5d7..e2da7fe16 100644
--- a/src/routes/applications/[id]/previews/index.svelte
+++ b/src/routes/applications/[id]/previews/index.svelte
@@ -11,7 +11,6 @@
}
};
}
-
return {
status: res.status,
error: new Error(`Could not load ${endpoint}`)
@@ -31,6 +30,7 @@
import Explainer from '$lib/components/Explainer.svelte';
import { errorNotification } from '$lib/form';
import { toast } from '@zerodevx/svelte-toast';
+ import BatchSecrets from '../secrets/_BatchSecrets.svelte';
const { id } = $page.params;
async function refreshSecrets() {
@@ -183,3 +183,4 @@
{/if}
+
diff --git a/src/routes/applications/[id]/secrets/_BatchSecrets.svelte b/src/routes/applications/[id]/secrets/_BatchSecrets.svelte
new file mode 100644
index 000000000..38af130c9
--- /dev/null
+++ b/src/routes/applications/[id]/secrets/_BatchSecrets.svelte
@@ -0,0 +1,48 @@
+
+
+
Paste .env file
+
diff --git a/src/routes/applications/[id]/secrets/_Secret.svelte b/src/routes/applications/[id]/secrets/_Secret.svelte
index 12b03cb7b..5c26fcc9e 100644
--- a/src/routes/applications/[id]/secrets/_Secret.svelte
+++ b/src/routes/applications/[id]/secrets/_Secret.svelte
@@ -9,11 +9,11 @@
if (isPRMRSecret) value = PRMRSecret.value;
import { page } from '$app/stores';
- import { del, post } from '$lib/api';
+ import { del } from '$lib/api';
import CopyPasswordField from '$lib/components/CopyPasswordField.svelte';
import { errorNotification } from '$lib/form';
- import { toast } from '@zerodevx/svelte-toast';
import { createEventDispatcher } from 'svelte';
+ import { saveSecret } from './utils';
const dispatch = createEventDispatcher();
const { id } = $page.params;
@@ -30,28 +30,20 @@
return errorNotification(error);
}
}
- async function saveSecret(isNew = false) {
- if (!name) return errorNotification('Name is required.');
- if (!value) return errorNotification('Value is required.');
- try {
- await post(`/applications/${id}/secrets.json`, {
- name,
- value,
- isBuildSecret,
- isPRMRSecret,
- isNew
- });
- dispatch('refresh');
- if (isNewSecret) {
- name = '';
- value = '';
- isBuildSecret = false;
- }
- toast.push('Secret saved.');
- } catch ({ error }) {
- return errorNotification(error);
- }
+
+ async function createSecret(isNew) {
+ saveSecret({
+ isNew,
+ name,
+ value,
+ isBuildSecret,
+ isPRMRSecret,
+ isNewSecret,
+ applicationId: id,
+ dispatch
+ });
}
+
function setSecretValue() {
if (isNewSecret) {
isBuildSecret = !isBuildSecret;
@@ -133,12 +125,14 @@
{#if isNewSecret}
-
+
{:else}
-
+
{#if !isPRMRSecret}
diff --git a/src/routes/applications/[id]/secrets/index.json.ts b/src/routes/applications/[id]/secrets/index.json.ts
index 5085f1187..174427615 100644
--- a/src/routes/applications/[id]/secrets/index.json.ts
+++ b/src/routes/applications/[id]/secrets/index.json.ts
@@ -1,10 +1,10 @@
-import { getTeam, getUserDetails } from '$lib/common';
+import { getUserDetails } from '$lib/common';
import * as db from '$lib/database';
import { ErrorHandler } from '$lib/database';
import type { RequestHandler } from '@sveltejs/kit';
export const get: RequestHandler = async (event) => {
- const { teamId, status, body } = await getUserDetails(event);
+ const { status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
const { id } = event.params;
@@ -24,7 +24,7 @@ export const get: RequestHandler = async (event) => {
};
export const post: RequestHandler = async (event) => {
- const { teamId, status, body } = await getUserDetails(event);
+ const { status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
const { id } = event.params;
@@ -53,7 +53,7 @@ export const post: RequestHandler = async (event) => {
}
};
export const del: RequestHandler = async (event) => {
- const { teamId, status, body } = await getUserDetails(event);
+ const { status, body } = await getUserDetails(event);
if (status === 401) return { status, body };
const { id } = event.params;
diff --git a/src/routes/applications/[id]/secrets/index.svelte b/src/routes/applications/[id]/secrets/index.svelte
index ce1a54b78..a2dfae8ff 100644
--- a/src/routes/applications/[id]/secrets/index.svelte
+++ b/src/routes/applications/[id]/secrets/index.svelte
@@ -26,6 +26,7 @@
import { getDomain } from '$lib/components/common';
import { page } from '$app/stores';
import { get } from '$lib/api';
+ import BatchSecrets from './_BatchSecrets.svelte';
const { id } = $page.params;
@@ -133,4 +134,6 @@
+
+
diff --git a/src/routes/applications/[id]/secrets/utils.ts b/src/routes/applications/[id]/secrets/utils.ts
new file mode 100644
index 000000000..a7d24a39e
--- /dev/null
+++ b/src/routes/applications/[id]/secrets/utils.ts
@@ -0,0 +1,46 @@
+import { toast } from '@zerodevx/svelte-toast';
+import { errorNotification } from '$lib/form';
+import { post } from '$lib/api';
+
+type Props = {
+ isNew: boolean;
+ name: string;
+ value: string;
+ isBuildSecret?: boolean;
+ isPRMRSecret?: boolean;
+ isNewSecret?: boolean;
+ applicationId: string;
+ dispatch: (name: string) => void;
+};
+
+export async function saveSecret({
+ isNew,
+ name,
+ value,
+ isBuildSecret,
+ isPRMRSecret,
+ isNewSecret,
+ applicationId,
+ dispatch
+}: Props): Promise {
+ if (!name) return errorNotification('Name is required.');
+ if (!value) return errorNotification('Value is required.');
+ try {
+ await post(`/applications/${applicationId}/secrets.json`, {
+ name,
+ value,
+ isBuildSecret,
+ isPRMRSecret,
+ isNew: isNew || false
+ });
+ dispatch('refresh');
+ if (isNewSecret) {
+ name = '';
+ value = '';
+ isBuildSecret = false;
+ }
+ toast.push('Secret saved.');
+ } catch ({ error }) {
+ return errorNotification(error);
+ }
+}
|