-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Created a way to toggle specific buttons on specific states #39
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b40e40
feat: Created a way to toggle specific buttons on specific states
Tommylans 5d8167e
feat: Processed comments and added utils for the record types we are …
Tommylans c2cdcc0
fix: Linting removed fragment
Tommylans a57ba29
refactor: Changed some namings and splitted waiting for input function
Tommylans 42ebf13
Merge branch 'main' into feature/TBX-56
berendsliedrecht File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/toolbox-core/src/utils/records/ConnectionsUtil.ts
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 @@ | ||
import type { ConnectionRecord } from '@aries-framework/core' | ||
|
||
import { DidExchangeState } from '@aries-framework/core' | ||
|
||
export class ConnectionsUtil { | ||
private static loadingStates: DidExchangeState[] = [ | ||
DidExchangeState.ResponseSent, | ||
DidExchangeState.RequestSent, | ||
DidExchangeState.InvitationSent, | ||
] | ||
|
||
public static acceptStates: DidExchangeState[] = [DidExchangeState.InvitationReceived] | ||
|
||
public static isConnectionWaitingForResponse(connection: ConnectionRecord): boolean { | ||
return ConnectionsUtil.loadingStates.includes(connection.state) | ||
} | ||
|
||
public static isConnectionWaitingForAcceptInput(connection: ConnectionRecord): boolean { | ||
return ConnectionsUtil.acceptStates.includes(connection.state) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/toolbox-core/src/utils/records/CredentialsUtil.ts
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,23 @@ | ||
import type { CredentialExchangeRecord } from '@aries-framework/core' | ||
|
||
import { CredentialState } from '@aries-framework/core' | ||
|
||
export class CredentialsUtil { | ||
private static loadingStates: CredentialState[] = [CredentialState.RequestSent, CredentialState.OfferSent] | ||
|
||
private static acceptStates: CredentialState[] = [CredentialState.OfferReceived, CredentialState.CredentialReceived] | ||
|
||
private static declineStates: CredentialState[] = [CredentialState.OfferReceived] | ||
|
||
public static isCredentialWaitingForResponse(credential: CredentialExchangeRecord): boolean { | ||
return CredentialsUtil.loadingStates.includes(credential.state) | ||
} | ||
|
||
public static isCredentialWaitingForAcceptInput(credential: CredentialExchangeRecord): boolean { | ||
return CredentialsUtil.acceptStates.includes(credential.state) | ||
} | ||
|
||
public static isCredentialWaitingForDeclineInput(credential: CredentialExchangeRecord): boolean { | ||
return CredentialsUtil.declineStates.includes(credential.state) | ||
} | ||
} |
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,22 @@ | ||
import type { ProofExchangeRecord } from '@aries-framework/core' | ||
|
||
import { ProofState } from '@aries-framework/core' | ||
|
||
export class ProofsUtil { | ||
private static loadingStates: ProofState[] = [ProofState.PresentationSent, ProofState.RequestSent] | ||
|
||
private static acceptStates: ProofState[] = [ProofState.RequestReceived] | ||
private static declineStates: ProofState[] = [ProofState.RequestReceived] | ||
|
||
public static isProofWaitingForResponse(proof: ProofExchangeRecord): boolean { | ||
return ProofsUtil.loadingStates.includes(proof.state) | ||
} | ||
|
||
public static isProofWaitingForAcceptInput(proof: ProofExchangeRecord): boolean { | ||
return ProofsUtil.acceptStates.includes(proof.state) | ||
} | ||
|
||
public static isProofWaitingForDeclineInput(proof: ProofExchangeRecord): boolean { | ||
return ProofsUtil.declineStates.includes(proof.state) | ||
} | ||
} |
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,38 @@ | ||
import { ActionIcon, Group, Loader } from '@mantine/core' | ||
import { IconCheck, IconTrash, IconX } from '@tabler/icons' | ||
import React from 'react' | ||
|
||
interface RecordActionsProps { | ||
onDelete?: () => void | ||
onDecline?: () => void | ||
onAccept?: () => void | ||
isLoading?: boolean | ||
} | ||
|
||
export const RecordActions = ({ onAccept, onDecline, onDelete, isLoading }: RecordActionsProps) => { | ||
const actions = [ | ||
onAccept && ( | ||
<ActionIcon key="accept" color="green" onClick={onAccept}> | ||
<IconCheck size={16} stroke={1.5} /> | ||
</ActionIcon> | ||
), | ||
|
||
onDecline && ( | ||
<ActionIcon key="reject" color="red" onClick={onDecline}> | ||
<IconX size={16} stroke={1.5} /> | ||
</ActionIcon> | ||
), | ||
|
||
onDelete && ( | ||
<ActionIcon key="delete" color="red" onClick={onDelete}> | ||
<IconTrash size={16} stroke={1.5} /> | ||
</ActionIcon> | ||
), | ||
].filter(Boolean) | ||
|
||
return ( | ||
<Group spacing={0} position="right"> | ||
{isLoading ? <Loader size={20} /> : actions} | ||
</Group> | ||
) | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too sure how, but it might be nice if we can always have the agent be defined when we are in the toolbox view (after initialization). Could you create an issue for that? We can resolve it in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created the Issue #43