AuthParams.svelte 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <script lang="ts">
  2. import * as Select from "$lib/components/ui/select";
  3. import { state as _state, updateAuthParams } from "$lib/state.svelte";
  4. import { Input } from "./ui/input";
  5. import type { Authentication } from "$lib/types";
  6. let {
  7. auth = $bindable(),
  8. readonly,
  9. }: { auth: Authentication; readonly: boolean } = $props();
  10. </script>
  11. {#if auth.params.type === "Token"}
  12. <div class="grid grid-cols-[auto_1fr] gap-2 items-center">
  13. <p>Name</p>
  14. <Input
  15. class="w-80"
  16. bind:value={auth.params.value.name}
  17. oninput={() => updateAuthParams(auth.id)}
  18. {readonly}
  19. ></Input>
  20. <p>Value</p>
  21. <Input
  22. class="w-80"
  23. bind:value={auth.params.value.value}
  24. oninput={() => updateAuthParams(auth.id)}
  25. {readonly}
  26. ></Input>
  27. <p class="pr-2">Placement</p>
  28. <Select.Root
  29. type="single"
  30. disabled={readonly}
  31. value={auth.params.value.placement}
  32. >
  33. <Select.Trigger disabled={readonly} class="w-80">
  34. {auth.params.value.placement}
  35. </Select.Trigger>
  36. <Select.Content>
  37. <Select.Item
  38. onclick={() => {
  39. auth.params.value.placement = "Query";
  40. updateAuthParams(auth.id);
  41. }}
  42. value={"Query"}
  43. >
  44. Query
  45. </Select.Item>
  46. <Select.Item
  47. onclick={() => {
  48. auth.params.value.placement = "Header";
  49. updateAuthParams(auth.id);
  50. }}
  51. value={"Header"}
  52. >
  53. Header
  54. </Select.Item>
  55. </Select.Content>
  56. </Select.Root>
  57. </div>
  58. {:else if auth.params.type === "Basic"}
  59. <div class="grid grid-cols-[auto_1fr] gap-2 items-center">
  60. <p>Username</p>
  61. <Input
  62. class="w-80"
  63. bind:value={auth.params.value.user}
  64. oninput={() => updateAuthParams(auth.id)}
  65. {readonly}
  66. ></Input>
  67. <p>Password</p>
  68. <Input
  69. class="w-80"
  70. bind:value={auth.params.value.password}
  71. oninput={() => updateAuthParams(auth.id)}
  72. {readonly}
  73. ></Input>
  74. </div>
  75. {/if}