Skip to content

Commit

Permalink
feat: only show pats that you created (#1319)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroms authored Jun 27, 2023
1 parent 2a4a544 commit 37b723a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/personalAccessTokens/PersonalAccessTokens.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useDataQuery } from '@dhis2/app-runtime'
import { Card, Button } from '@dhis2/ui'
import React, { useState } from 'react'
import i18n from '../locales/index.js'
import userProfileStore from '../profile/profile.store.js'
import GenerateTokenModal from './generateTokenModal/GenerateTokenModal.component.js'
import styles from './PersonalAccessTokens.module.css'
import TokensList from './TokensList.component.js'
Expand All @@ -10,16 +11,20 @@ import { useModal } from './use-modal.js'
const query = {
tokens: {
resource: 'apiToken',
params: {
params: ({ userId }) => ({
fields: ['id', 'created', 'expire', 'attributes'],
paging: false,
},
filter: `createdBy.id:eq:${userId}`,
}),
},
}

const PersonalAccessTokens = () => {
const userId = userProfileStore.state.id
const [tokenKeys, setTokenKeys] = useState(new Map())
const { loading, error, data, refetch } = useDataQuery(query)
const { loading, error, data, refetch } = useDataQuery(query, {
variables: { userId },
})
const generateTokenModal = useModal()

const tokens = data?.tokens.apiToken
Expand Down

0 comments on commit 37b723a

Please sign in to comment.