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: only show pats that you created #1319

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Changes from all commits
Commits
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
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