diff --git a/helpers/utils/composables.ts b/helpers/utils/composables.ts index 2360885c6..7dad49e91 100644 --- a/helpers/utils/composables.ts +++ b/helpers/utils/composables.ts @@ -89,6 +89,13 @@ export function pluckRef(ref: Ref, key: K): Ref { }) } +export function pluckMultipleFromRef>( + sourceRef: Ref, + keys: K +): { [key in K[number]]: Ref } { + return Object.fromEntries(keys.map((x) => [x, pluckRef(sourceRef, x)])) as any +} + /** * A composable that provides the ability to run streams * and subscribe to them and respect the component lifecycle. diff --git a/newstore/RESTSession.ts b/newstore/RESTSession.ts index 9ac9aaf9c..1e90e79be 100644 --- a/newstore/RESTSession.ts +++ b/newstore/RESTSession.ts @@ -171,6 +171,14 @@ const dispatchers = defineDispatchers({ }, } }, + setParams(curr: RESTSession, { entries }: { entries: HoppRESTParam[] }) { + return { + request: { + ...curr.request, + params: entries, + }, + } + }, addParam(curr: RESTSession, { newParam }: { newParam: HoppRESTParam }) { return { request: { @@ -273,6 +281,14 @@ const dispatchers = defineDispatchers({ }, } }, + setHeaders(curr: RESTSession, { entries }: { entries: HoppRESTHeader[] }) { + return { + request: { + ...curr.request, + headers: entries, + }, + } + }, addHeader(curr: RESTSession, { entry }: { entry: HoppRESTHeader }) { return { request: { @@ -395,6 +411,15 @@ export function setRESTRequestName(newName: string) { }) } +export function setRESTParams(entries: HoppRESTParam[]) { + restSessionStore.dispatch({ + dispatcher: "setParams", + payload: { + entries, + }, + }) +} + export function addRESTParam(newParam: HoppRESTParam) { restSessionStore.dispatch({ dispatcher: "addParam", @@ -439,6 +464,15 @@ export function updateRESTMethod(newMethod: string) { }) } +export function setRESTHeaders(entries: HoppRESTHeader[]) { + restSessionStore.dispatch({ + dispatcher: "setHeaders", + payload: { + entries, + }, + }) +} + export function addRESTHeader(entry: HoppRESTHeader) { restSessionStore.dispatch({ dispatcher: "addHeader", diff --git a/pages/index.vue b/pages/index.vue index 14d329333..6f0ba4d13 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -77,7 +77,13 @@