-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from HunnySajid/feat/cred-chain
Feat/cred chain
- Loading branch information
Showing
10 changed files
with
266 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,89 @@ | ||
import { useIntl } from "react-intl"; | ||
import { ICredential } from "@config/types"; | ||
import Collapsible from "react-collapsible"; | ||
import { Flex, Box, IconButton } from "@components/ui"; | ||
import OpenFile from "@components/shared/icons/open-file"; | ||
|
||
interface ITriggerItem { | ||
title: string; | ||
onClickTrigger?: (idx: string) => void; | ||
idx: string; | ||
} | ||
|
||
function TriggerItem({ title, onClickTrigger, idx }: ITriggerItem) { | ||
return ( | ||
<Flex $cursorPointer $flexGap={1}> | ||
{title}{" "} | ||
<IconButton | ||
onClick={(e) => { | ||
if (onClickTrigger) { | ||
onClickTrigger(idx); | ||
} | ||
e?.stopPropagation(); | ||
}} | ||
> | ||
<OpenFile size={3} /> | ||
</IconButton> | ||
</Flex> | ||
); | ||
} | ||
|
||
export function CredentialRecursiveChain({ | ||
credential, | ||
openMessage, | ||
closeMessage, | ||
idx, | ||
exploreChain, | ||
}: { | ||
credential: ICredential; | ||
openMessage?: string | React.ReactElement; | ||
closeMessage?: string | React.ReactElement; | ||
idx: string; | ||
exploreChain?: (id: string) => void; | ||
}): JSX.Element { | ||
const { formatMessage } = useIntl(); | ||
|
||
if (credential?.chains?.length === 0) | ||
return ( | ||
<TriggerItem | ||
idx={idx} | ||
title={credential?.schema?.title} | ||
onClickTrigger={exploreChain} | ||
/> | ||
); | ||
|
||
return ( | ||
<Collapsible | ||
trigger={ | ||
openMessage ?? ( | ||
<TriggerItem | ||
idx={idx} | ||
title={`> ${credential?.schema?.title}`} | ||
onClickTrigger={exploreChain} | ||
/> | ||
) | ||
} | ||
triggerWhenOpen={ | ||
closeMessage ?? ( | ||
<TriggerItem | ||
idx={idx} | ||
title={credential?.schema?.title} | ||
onClickTrigger={exploreChain} | ||
/> | ||
) | ||
} | ||
> | ||
{credential?.chains?.map((chain, index) => ( | ||
<> | ||
<Box marginY={2} marginX={3} key={index}> | ||
<CredentialRecursiveChain | ||
credential={chain} | ||
idx={`${idx}.${index}`} | ||
exploreChain={exploreChain} | ||
/> | ||
</Box> | ||
</> | ||
))} | ||
</Collapsible> | ||
); | ||
} |
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,40 @@ | ||
export default function BackArrow({ | ||
size, | ||
scale = 4, | ||
}: { | ||
size: number; | ||
scale?: number; | ||
}) { | ||
return ( | ||
<svg | ||
fill="currentColor" | ||
width={size * scale} | ||
height={size * scale} | ||
viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M9 22H15C20 22 22 20 22 15V9C22 4 20 2 15 2H9C4 2 2 4 2 9V15C2 20 4 22 9 22Z" | ||
stroke="#292D32" | ||
stroke-width="1.5" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
<path | ||
d="M9.00002 15.3802H13.92C15.62 15.3802 17 14.0002 17 12.3002C17 10.6002 15.62 9.22021 13.92 9.22021H7.15002" | ||
stroke="#292D32" | ||
stroke-width="1.5" | ||
stroke-miterlimit="10" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
<path | ||
d="M8.57 10.7701L7 9.19012L8.57 7.62012" | ||
stroke="#292D32" | ||
stroke-width="1.5" | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
/> | ||
</svg> | ||
); | ||
} |
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,26 @@ | ||
export default function OpenFile({ | ||
size, | ||
scale = 4, | ||
}: { | ||
size: number; | ||
scale?: number; | ||
}) { | ||
return ( | ||
<svg | ||
fill="currentColor" | ||
width={size * scale} | ||
height={size * scale} | ||
viewBox="0 0 512 512" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<g fill-rule="evenodd" transform="translate(42.667 42.667)"> | ||
<path d="M178.0832,42.6666667 L221.594,77.0716667 L191.217,107.448667 L163.24992,85.3333333 L42.6666667,85.3333333 L42.6666667,296.106667 L82.0209067,170.666667 L341.333333,170.666667 L341.333,170.665667 L384,170.665667 L437.333333,170.666667 L372.583253,384 L-2.13162821e-14,384 L-2.13162821e-14,42.6666667 L178.0832,42.6666667 Z M379.79136,213.333333 L113.354027,213.333333 L73.1874133,341.333333 L340.95808,341.333333 L379.79136,213.333333 Z" /> | ||
|
||
<path | ||
fill-rule="nonzero" | ||
d="M384,7.10542736e-15 L384,149.333333 L341.333333,149.333333 L341.332777,72.836 L264.836777,149.332777 L204.496777,149.333333 L311.162777,42.666 L234.666667,42.6666667 L234.666667,7.10542736e-15 L384,7.10542736e-15 Z" | ||
/> | ||
</g> | ||
</svg> | ||
); | ||
} |
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