Skip to content
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 5 commits into from
Dec 9, 2022

Conversation

Tommylans
Copy link
Member

@Tommylans Tommylans commented Dec 6, 2022

Screenshot from 2022-12-06 11-12-31

@Tommylans Tommylans marked this pull request as ready for review December 6, 2022 11:15
Copy link
Member

@berendsliedrecht berendsliedrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small notes. You can merge it, when they are resolved :)

Comment on lines 23 to 39
const actions = [
isAcceptable ? (
<ActionIcon key="accept" color="green">
<IconCheck size={16} stroke={1.5} onClick={onAccept} />
</ActionIcon>
) : null,

isDeclineable ? (
<ActionIcon key="reject" color="red" onClick={onDecline}>
<IconX size={16} stroke={1.5} />
</ActionIcon>
) : null,

<ActionIcon key="delete" color="red" onClick={onDelete}>
<IconTrash size={16} stroke={1.5} />
</ActionIcon>,
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const actions = [
isAcceptable ? (
<ActionIcon key="accept" color="green">
<IconCheck size={16} stroke={1.5} onClick={onAccept} />
</ActionIcon>
) : null,
isDeclineable ? (
<ActionIcon key="reject" color="red" onClick={onDecline}>
<IconX size={16} stroke={1.5} />
</ActionIcon>
) : null,
<ActionIcon key="delete" color="red" onClick={onDelete}>
<IconTrash size={16} stroke={1.5} />
</ActionIcon>,
]
const actions = [
<ActionIcon key="accept" color="green">
<IconCheck size={16} stroke={1.5} onClick={onAccept} />
</ActionIcon>
<ActionIcon key="reject" color="red" onClick={onDecline}>
<IconX size={16} stroke={1.5} />
</ActionIcon>
<ActionIcon key="delete" color="red" onClick={onDelete}>
<IconTrash size={16} stroke={1.5} />
</ActionIcon>,
].filter(Boolean)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change the buttons are always visible right? I see the filter but not really the use of the isLoading variable or did you left this out because the other comment to have a constant of the states?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no it was a mistake. However you can just check if it is acceptable when onAccept is supplied. That would mean one less prop and no mismatch in state. Filtering out null is not required then.

{records.map((record) => {
const recordState = record.state

const isLoading =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to abstract these loading states into an array in a constant file. like const connectionLoadingStates = [DidExchangeState.RequestSent,...]. Same goes for the credential and proof.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a function of like, isRecordWaitingForResponse(record)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idea is to have a list in the RecordActions component with a list of states that are loading?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just a list of the enums which have a state where we are waiting for a response.

The function would take a record and check if its state is in the list. Can work out an example tomorrow if I didn't explain it good enough.

@@ -39,6 +39,7 @@ export const CredentialsScreen = () => {
connections={connectionRecords}
onDelete={(credential) => agent?.credentials.deleteById(credential.id)}
onAccept={(credential) => acceptCredential(credential)}
onDecline={(credential) => agent?.credentials.declineOffer(credential.id)}
Copy link
Member

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.

Copy link
Member Author

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

@berendsliedrecht
Copy link
Member

@Tommylans there are some linting issues. Will review again.

Copy link
Member

@berendsliedrecht berendsliedrecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small things

Comment on lines 23 to 25
return {
isAcceptable: ConnectionUtil.acceptStates.includes(connection.state),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this returned as an object? I would say a boolean is good enough here.

@@ -0,0 +1,27 @@
import type { ConnectionRecord } from '@aries-framework/core'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename it to ConnectionsUtil.ts? The modules are always plural so its a bit nice in sync.

Comment on lines 22 to 24
return {
isAcceptable: CredentialUtil.acceptStates.includes(credential.state),
isDeclineable: CredentialUtil.declineStates.includes(credential.state),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AH I see. I think, how verbose it might seen, two methods would be better. isCredentialWaitingForInputAndIsDeclineOrMaybeSomethingElseThisIsGettingVeryLong. :)

not too sure about that name though,

@berendsliedrecht berendsliedrecht merged commit 8ea9b95 into main Dec 9, 2022
@berendsliedrecht berendsliedrecht deleted the feature/TBX-56 branch December 9, 2022 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants