refactor: iterations

This commit is contained in:
jamesgeorge007
2024-02-04 20:34:23 +05:30
parent 29e25b0ead
commit ab7df212c2
11 changed files with 1235 additions and 187 deletions

View File

@@ -2,7 +2,7 @@ import {
ChildrenResult,
SmartTreeAdapter,
} from "@hoppscotch/ui/dist/src/helpers/treeAdapter"
import { Ref, computed, ref, watchEffect } from "vue"
import { Ref, ref, watchEffect } from "vue"
import { NewWorkspaceService } from "~/services/new-workspace"
import { HandleRef } from "~/services/new-workspace/handle"
import {

View File

@@ -1,13 +1,17 @@
import { pipe } from "fp-ts/function"
import * as O from "fp-ts/Option"
import * as RR from "fp-ts/ReadonlyRecord"
import { HoppRESTRequest } from "@hoppscotch/data"
export const REQUEST_METHOD_LABEL_COLORS = {
get: "var(--success-color)",
post: "var(--warning-color)",
put: "var(--blue-color)",
delete: "var(--cl-error-color)",
default: "#6b7280",
get: "var(--method-get-color)",
post: "var(--method-post-color)",
put: "var(--method-put-color)",
patch: "var(--method-patch-color)",
delete: "var(--method-delete-color)",
head: "var(--method-head-color)",
options: "var(--method-options-color)",
default: "var(--method-default-color)",
} as const
/**
@@ -15,10 +19,18 @@ export const REQUEST_METHOD_LABEL_COLORS = {
* @param request The HoppRESTRequest object to get the value for
* @returns The class value for the given HTTP VERB, if not, a generic verb class
*/
export function getMethodLabelColorClassOf(request: { method: string }) {
export function getMethodLabelColorClassOf(request: HoppRESTRequest) {
return pipe(
REQUEST_METHOD_LABEL_COLORS,
RR.lookup(request.method.toLowerCase()),
O.getOrElseW(() => REQUEST_METHOD_LABEL_COLORS.default)
)
}
export function getMethodLabelColor(method: string) {
return pipe(
REQUEST_METHOD_LABEL_COLORS,
RR.lookup(method.toLowerCase()),
O.getOrElseW(() => REQUEST_METHOD_LABEL_COLORS.default)
)
}