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: added configuration options to K-menu #109

Merged
merged 28 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5ddaeb4
feat: added configuration options to K-menu
jimezesinachi Sep 23, 2022
225a621
feat: added logic for invitation method switch from K-menu
jimezesinachi Sep 26, 2022
967a190
test: updated tests
jimezesinachi Sep 26, 2022
9ac5fba
test: removed theme logic from setInvitationMethod
jimezesinachi Sep 26, 2022
02dc014
Merge pull request #1 from animo/main
jimezesinachi Sep 26, 2022
7fcf676
fix: fixed use of React hooks incorectly
jimezesinachi Sep 27, 2022
6b2b73d
Merge branch 'feat/add-configuration-screen' of https://github.com/ra…
jimezesinachi Sep 27, 2022
c701866
fix: fixed issue with ConfigurationState use
jimezesinachi Sep 27, 2022
8417fc9
Update client/src/utils/KBar.tsx
jimezesinachi Sep 28, 2022
14cc304
Update client/src/slices/configuration/configurationSlice.ts
jimezesinachi Sep 28, 2022
1840c07
fix: renamed Bcovrin menu object and setLegacyInvitation method
jimezesinachi Sep 28, 2022
29b4a91
fix: actions menu and ConfigurationSlice
jimezesinachi Sep 28, 2022
d3c5d3e
fix: added state logic for credential protocol version switch
jimezesinachi Sep 28, 2022
18234fc
feat: moved ConfigurationSlice logic into ConnectionSlice and added r…
jimezesinachi Sep 29, 2022
cc61008
test: added oob invitation test and removed demo reset call in onboar…
jimezesinachi Oct 3, 2022
14dc22c
Update cypress/e2e/legacy_invitation_usecase_page.cy.ts
jimezesinachi Oct 4, 2022
61dd6a3
separated stage logic into demo/RESET and demo/resetState and removed…
jimezesinachi Oct 4, 2022
7b47a77
Merge branch 'feat/add-configuration-screen' of https://github.com/ra…
jimezesinachi Oct 4, 2022
cd92196
Update client/src/slices/credentials/credentialsSlice.ts
jimezesinachi Oct 4, 2022
b095c64
Update client/src/slices/onboarding/onboardingSlice.ts
jimezesinachi Oct 4, 2022
af7cd9b
Update client/src/store/configureStore.tsx
jimezesinachi Oct 4, 2022
5b685ef
fixed slice reducer logic for demo/resetState and removed commented i…
jimezesinachi Oct 4, 2022
3ecda9b
test: added issue credential protocol version tests
jimezesinachi Oct 5, 2022
4fc5c9a
test: switched issue credential protocol version tests from oob to le…
jimezesinachi Oct 5, 2022
3b5fa91
test: renamed issue credential test assertions and set wait times to …
jimezesinachi Oct 6, 2022
ae67c8a
Update client/src/utils/KBar.tsx
jimezesinachi Oct 6, 2022
f4e3b3b
Update client/src/utils/KBar.tsx
jimezesinachi Oct 6, 2022
41a34c4
Update client/src/utils/KBar.tsx
jimezesinachi Oct 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion client/src/api/ConnectionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import type { AxiosResponse } from 'axios'

import { apiCall } from './BaseUrl'

export const createInvitation = (agentName?: string, agentImageUrl?: string): Promise<AxiosResponse> => {
export const createOobInvitation = (agentName?: string, agentImageUrl?: string): Promise<AxiosResponse> => {
return apiCall.post('/oob/create-invitation', {
autoAcceptConnection: true,
label: agentName,
imageUrl: agentImageUrl,
})
}

export const createLegacyInvitation = (agentName?: string, agentImageUrl?: string): Promise<AxiosResponse> => {
return apiCall.post('/oob/create-legacy-invitation', {
autoAcceptConnection: true,
label: agentName,
Expand Down
4 changes: 3 additions & 1 deletion client/src/pages/onboarding/steps/SetupConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Loader } from '../../../components/Loader'
import { QRCode } from '../../../components/QRCode'
import { useAppDispatch } from '../../../hooks/hooks'
import { useInterval } from '../../../hooks/useInterval'
import { useConfiguration } from '../../../slices/configuration/configurationSelectors'
import {
createInvitation,
fetchConnectionById,
Expand All @@ -36,9 +37,10 @@ export const SetupConnection: React.FC<Props> = ({
}) => {
const dispatch = useAppDispatch()
const isCompleted = connectionState === 'response-sent' || connectionState === 'completed'
const { useLegacyInvitation } = useConfiguration()

useEffect(() => {
if (!isCompleted) dispatch(createInvitation())
if (!isCompleted) dispatch(createInvitation({ useLegacyInvitation }))
}, [])

useEffect(() => {
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/useCase/steps/StepConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { fade, fadeX } from '../../../FramerAnimations'
import { QRCode } from '../../../components/QRCode'
import { useAppDispatch } from '../../../hooks/hooks'
import { useInterval } from '../../../hooks/useInterval'
import { useConfiguration } from '../../../slices/configuration/configurationSelectors'
import {
createInvitation,
fetchConnectionById,
Expand All @@ -27,9 +28,12 @@ export const StepConnection: React.FC<Props> = ({ step, connection, entity }) =>
const dispatch = useAppDispatch()
const { id, state, invitationUrl, outOfBandId } = connection
const isCompleted = state === 'response-sent' || state === 'completed'
const { useLegacyInvitation } = useConfiguration()

useEffect(() => {
if (!isCompleted) dispatch(createInvitation(entity))
if (!isCompleted) {
dispatch(createInvitation({ entity, useLegacyInvitation }))
}
}, [])

useInterval(
Expand Down
5 changes: 5 additions & 0 deletions client/src/slices/configuration/configurationSelectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { RootState } from '../../store/configureStore'

import { useSelector } from 'react-redux'

export const useConfiguration = () => useSelector((state: RootState) => state.configuration)
23 changes: 23 additions & 0 deletions client/src/slices/configuration/configurationSlice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createSlice } from '@reduxjs/toolkit'

interface ConfigurationState {
useLegacyInvitation: boolean
}

const initialState: ConfigurationState = {
useLegacyInvitation: true,
}

const configurationSlice = createSlice({
name: 'configuration',
initialState,
reducers: {
setLegacyInvitation: (state, action) => {
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
state.useLegacyInvitation = action.payload
},
},
})

export const { setLegacyInvitation } = configurationSlice.actions

export default configurationSlice.reducer
18 changes: 13 additions & 5 deletions client/src/slices/connection/connectionThunks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Entity } from '../../slices/types'
import type { CreateInvitationProps } from '../../slices/types'

import { createAsyncThunk } from '@reduxjs/toolkit'

Expand All @@ -14,7 +14,15 @@ export const fetchConnectionByOutOfBandId = createAsyncThunk('connection/fetchBy
return response.data
})

export const createInvitation = createAsyncThunk('connection/createInvitation', async (entity?: Entity) => {
const response = await Api.createInvitation(entity?.name, entity?.imageUrl)
return response.data
})
export const createInvitation = createAsyncThunk(
'connection/createInvitation',
async (createInvitationOptions?: CreateInvitationProps) => {
const entity = createInvitationOptions?.entity

const response = createInvitationOptions?.useLegacyInvitation
? await Api.createLegacyInvitation(entity?.name, entity?.imageUrl)
: await Api.createOobInvitation(entity?.name, entity?.imageUrl)

return response.data
}
)
2 changes: 2 additions & 0 deletions client/src/slices/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { combineReducers } from 'redux'

import charactersSlice from './characters/charactersSlice'
import configurationSlice from './configuration/configurationSlice'
import connectionSlice from './connection/connectionSlice'
import credentialsSlice from './credentials/credentialsSlice'
import onboardingSlice from './onboarding/onboardingSlice'
Expand All @@ -19,6 +20,7 @@ const rootReducer = combineReducers({
credentials: credentialsSlice,
onboarding: onboardingSlice,
preferences: preferencesSlice,
configuration: configurationSlice,
proof: proofSlice,
section: sectionSlice,
useCases: useCaseSlice,
Expand Down
5 changes: 5 additions & 0 deletions client/src/slices/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ export interface Entity {
imageUrl?: string
}

export interface CreateInvitationProps {
entity?: Entity
useLegacyInvitation?: boolean
}

export interface Colors {
primary: string
secondary: string
Expand Down
2 changes: 1 addition & 1 deletion client/src/store/configureStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import rootReducer from '../slices/index'
export const persistConfig = {
key: 'redux-store-root',
storage,
whitelist: ['preferences', 'characters', 'onboarding', 'credentials', 'connection'],
whitelist: ['preferences', 'configuration', 'characters', 'onboarding', 'credentials', 'connection'],
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
version: 4,
}

Expand Down
107 changes: 107 additions & 0 deletions client/src/utils/KBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Confetti from 'react-confetti'
import { confettiFade } from '../FramerAnimations'
import { useAppDispatch } from '../hooks/hooks'
import { fetchAllCharacters } from '../slices/characters/charactersThunks'
import { setLegacyInvitation } from '../slices/configuration/configurationSlice'
import { usePreferences } from '../slices/preferences/preferencesSelectors'
import { resetDashboard, setDarkMode } from '../slices/preferences/preferencesSlice'
import { fetchWallets } from '../slices/wallets/walletsThunks'
Expand Down Expand Up @@ -63,9 +64,115 @@ export const KBar: React.FunctionComponent<PropsWithChildren> = ({ children }) =
dispatch(fetchAllCharacters())
},
},
{
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
id: 'configuration',
name: 'Choose demo configuration options...',
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
shortcut: ['o'],
keywords: 'configuration',
section: 'Configuration',
},
{
id: 'ledger',
name: 'Select ledger',
keywords: 'ledger',
section: '',
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
parent: 'configuration',
},
{
id: 'BCovrin',
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
name: 'BCovrin',
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
keywords: 'BCovrin',
section: '',
perform: () => {
alert('BCovrin ledger selected!')
},
parent: 'ledger',
},
{
id: 'issue-credential-protocol-version',
name: 'Select credential protocol version',
keywords: 'issue-credential-protocol-version',
section: '',
parent: 'configuration',
},
{
id: 'issue-credential-protocol-version-1',
name: 'v1',
keywords: 'issue-credential-protocol-version-1',
section: '',
perform: () => {
alert('Credential Protocol Version 1 selected')
},
parent: 'issue-credential-protocol-version',
},
{
id: 'issue-credential-protocol-version-2',
name: 'v2',
keywords: 'issue-credential-protocol-version-2',
section: '',
perform: () => {
alert('Credential Protocol Version 2 selected')
},
parent: 'issue-credential-protocol-version',
},
{
id: 'present-proof-protocol-version',
name: 'Select proof protocol version',
keywords: 'present-proof-protocol-version',
section: '',
parent: 'configuration',
},
{
id: 'present-proof-protocol-version-1',
name: 'v1',
keywords: 'present-proof-protocol-version-1',
section: '',
perform: () => {
alert('Proof Protocol Version 1 selected')
jimezesinachi marked this conversation as resolved.
Show resolved Hide resolved
},
parent: 'present-proof-protocol-version',
},
{
id: 'present-proof-protocol-version-2',
name: 'v2',
keywords: 'present-proof-protocol-version-2',
section: '',
perform: () => {
alert('Proof Protocol Version 2 selected')
},
parent: 'present-proof-protocol-version',
},
{
id: 'invitation-method',
name: 'Select invitation method',
keywords: 'invitation-method',
section: '',
parent: 'configuration',
},
{
id: 'invitation-method-oob',
name: 'Out-of-band invitation',
keywords: 'invitation-method-oob',
section: '',
perform: () => {
dispatch(setLegacyInvitation(false))
},
parent: 'invitation-method',
},
{
id: 'invitation-method-legacy',
name: 'Legacy invitation',
keywords: 'invitation-method-legacy',
section: '',
perform: () => {
dispatch(setLegacyInvitation(true))
},
parent: 'invitation-method',
},
{
id: 'theme',
name: 'Change theme…',
shortcut: ['t'],
keywords: 'interface color dark light',
section: 'Preferences',
},
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/usecase_page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('UseCase Page', () => {

cy.get('[data-cy=select-use-case]').first().click()

cy.intercept('POST', `${API_URL}/connections/create-invitation`).as('createInvitation')
// cy.intercept('POST', `${API_URL}/oob/create-invitation`).as('createInvitation')
cy.get('[data-cy=start-container]')
cy.get('[data-cy=small-button]').click()

Expand Down