-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(console): trying fragments for Rules with hudini
- Loading branch information
Showing
8 changed files
with
154 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 26 additions & 25 deletions
51
apps/console/src/routes/(app)/profile/security-key.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
query Rules { | ||
rules(order_by: { createdAt: asc }) @list(name: "Rules") { | ||
action | ||
annotations | ||
appId | ||
description | ||
destination | ||
destinationPort | ||
direction | ||
displayName | ||
protocol | ||
shared | ||
source | ||
sourcePort | ||
throttleRate | ||
updatedAt | ||
updatedBy | ||
weight | ||
...RuleCardFields | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
<script lang="ts"> | ||
import { user } from '$lib/stores/user'; | ||
import { Debug } from '@spectacular/skeleton/components'; | ||
import type { PageData } from './$houdini'; | ||
import RulesCard from './rules.svelte'; | ||
export let data: PageData; | ||
$: ({ Rules: RulesData } = data); | ||
$: rules = $RulesData.data?.rules ?? []; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Datablocks | Settings</title> | ||
<meta name="description" content="Account Settings" /> | ||
<title>Datablocks | Rules</title> | ||
<meta name="description" content="Rules list" /> | ||
</svelte:head> | ||
|
||
<h2 class="h2">Settings</h2> | ||
<Debug data={$user}/> | ||
<h2 class="h2">Rules</h2> | ||
|
||
{#if $RulesData.fetching} | ||
<span>loading...</span> | ||
{:else} | ||
<span>done....</span> | ||
<RulesCard {rules}/> | ||
{/if} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import { fragment, graphql } from '$houdini'; | ||
import type { RuleCardFields } from '$houdini'; | ||
export let rule: RuleCardFields; | ||
$: data = fragment( | ||
rule, | ||
graphql` | ||
fragment RuleCardFields on rules { | ||
id | ||
createdAt | ||
updatedAt | ||
organization | ||
tags | ||
} | ||
`, | ||
); | ||
$: ({ id, createdAt, updatedAt, organization, tags } = $data); | ||
</script> | ||
|
||
<div | ||
class="py-2.5 duration-200" | ||
role="listitem" | ||
> | ||
<div class="relative"> | ||
<div class="flex items-center"> | ||
<p class="font-bold">{id}</p> | ||
<p class="font-bold">{createdAt}</p> | ||
<p class="font-bold">{updatedAt}</p> | ||
<p class="font-bold">{organization}</p> | ||
<p class="font-bold">{tags}</p> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts"> | ||
import type { Rule } from '$houdini'; | ||
import { flip } from 'svelte/animate'; | ||
import { quintOut } from 'svelte/easing'; | ||
import { fade } from 'svelte/transition'; | ||
import RuleItem from './rule.svelte'; | ||
export const defaultDE = { | ||
duration: 450, | ||
easing: quintOut, | ||
}; | ||
export let rules: Rule[]; | ||
export function hasId(obj) { | ||
if (obj == null || typeof obj !== 'object') return false; | ||
return !!('id' in obj); | ||
} | ||
export function toWithId(obj) { | ||
if (hasId(obj)) return obj; | ||
throw new Error('.id is required'); | ||
} | ||
$: rulesWithId = rules.map(toWithId); | ||
</script> | ||
|
||
<div class="divide-y divide-slate-200"> | ||
{#each rulesWithId as rule (rule.id)} | ||
<div transition:fade={defaultDE} animate:flip={defaultDE}> | ||
<RuleItem {rule} /> | ||
</div> | ||
{/each} | ||
</div> |