Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksiAhtiainen committed Dec 31, 2024
1 parent a69329c commit 96124fe
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 38 deletions.
3 changes: 1 addition & 2 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ module.exports = {
],
moduleFileExtensions: ['js', 'jsx', 'json'],
moduleNameMapper: {
'\\.(svg)$': '<rootDir>/src/__mocks__/filemock.js',
'Resources/mapping/usagePermissionDescriptions': '<rootDir>/resources/mapping/usagePermissionDescriptions.json'
'\\.(svg)$': '<rootDir>/src/__mocks__/filemock.js'
},
snapshotSerializers: ['enzyme-to-json/serializer'],
coverageThreshold: {
Expand Down
4 changes: 0 additions & 4 deletions frontend/mock/mapping/usagePermissionDescriptions.json

This file was deleted.

15 changes: 8 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions frontend/resources/mapping/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,10 @@
"fi": "Tarkasteltava henkilö:",
"sv": "Person vars uppgifter granskas",
"en": "Person who’s data is being viewed"
},
"Suoritusjakolinkkien katselut": {
"fi": "Suoritusjakolinkkien katselut",
"sv": "Visningar av delningslänken",
"en": "Accesses of study information sharing links"
}
}
5 changes: 0 additions & 5 deletions frontend/resources/mapping/usagePermissionDescriptions.json

This file was deleted.

12 changes: 7 additions & 5 deletions frontend/src/component/organization/Organization.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ import { lensPath, view } from 'ramda'
import Expander from 'component/generic/widget/Expander'
import OrganizationDetails from 'component/organization/OrganizationDetails'
import LogEntries from 'component/log-entries/LogEntries'
import t from 'util/translate'

/*
TODO: Currently we just take the first organization alternative (its name and oid). This must be changed.
*/
const nameLens = lensPath(['0', 'name'])
const oidLens = lensPath(['0', 'oid'])

const title = organizations => view(nameLens, organizations)

const Organization = ({ organizationAlternatives, timestamps, serviceName }) => (
<Expander title={title(organizationAlternatives)} serviceName={serviceName}>
<OrganizationDetails organizationOid={view(oidLens, organizationAlternatives)} />
const Organization = ({ organizationAlternatives, timestamps, serviceName, isMyDataUse, isJakolinkkiUse }) => (
<Expander title={isJakolinkkiUse ? t('Suoritusjakolinkkien katselut') : title(organizationAlternatives)} serviceName={serviceName}>
<OrganizationDetails isMyDataUse={isMyDataUse} />
<LogEntries timestamps={timestamps}/>
</Expander>
)

Organization.propTypes = {
organizationAlternatives: PropTypes.array.isRequired,
timestamps: PropTypes.array.isRequired,
serviceName: PropTypes.string.isRequired
serviceName: PropTypes.string.isRequired,
isMyDataUse: PropTypes.bool,
isJakolinkkiUse: PropTypes.bool
}

export default Organization
12 changes: 6 additions & 6 deletions frontend/src/component/organization/OrganizationDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import t from 'util/translate'
import { getTranslatedUsagePermissionDescription, isMydataPartner } from 'util/usagePermissionDescriptions'
import { getTranslatedUsagePermissionDescription } from 'util/usagePermissionDescriptions'
import { Bold } from 'ui/typography'
import constants from 'ui/constants'
import media from 'ui/media'
Expand Down Expand Up @@ -31,27 +31,27 @@ const Description = styled.div`
font-size: ${constants.font.size.s};
`

const weblink = oid => (isMydataPartner(oid)
const weblink = isMyDataUse => (isMyDataUse
? t('omadata-link')
: t('tietosuojaseloste-link')
)

const OrganizationDetails = ({ organizationOid }) => (
const OrganizationDetails = ({ isMyDataUse }) => (
<Details>
<Description>
<Bold>{t`Tietojen käyttölupa`}:</Bold> {getTranslatedUsagePermissionDescription(organizationOid)}
<Bold>{t`Tietojen käyttölupa`}:</Bold> {getTranslatedUsagePermissionDescription(isMyDataUse)}
</Description>

<ExternalLink
text={t`Tarkempi kuvaus lähetetyistä tiedoista`}
url={weblink(organizationOid)}
url={weblink(isMyDataUse)}
openInNewTab={true}
/>
</Details>
)

OrganizationDetails.propTypes = {
organizationOid: PropTypes.string.isRequired
isMyDataUse: PropTypes.bool
}

export default OrganizationDetails
4 changes: 3 additions & 1 deletion frontend/src/component/organization/Organizations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Organizations = ({ translatedOrganizations }) => (
<OrganizationsHeader/>

{
translatedOrganizations.map(({ organizations, timestamps, serviceName }) => {
translatedOrganizations.map(({ organizations, timestamps, serviceName, isMyDataUse, isJakolinkkiUse }) => {
const key = map(view(oidLens), organizations).join(',')

return (
Expand All @@ -20,6 +20,8 @@ const Organizations = ({ translatedOrganizations }) => (
organizationAlternatives={organizations}
timestamps={timestamps}
serviceName={serviceName}
isMyDataUse={isMyDataUse}
isJakolinkkiUse={isJakolinkkiUse}
/>
)
})
Expand Down
10 changes: 2 additions & 8 deletions frontend/src/util/usagePermissionDescriptions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import t from 'util/translate'

import permissionsMap from 'Resources/mapping/usagePermissionDescriptions'

export const getTranslatedUsagePermissionDescription = organizationOid => {
const permission = permissionsMap[organizationOid] || permissionsMap.default
export const getTranslatedUsagePermissionDescription = isMyDataUse => {
const permission = isMyDataUse ? 'Olet antanut tälle palvelutarjoajalle luvan käyttää tietojasi.' : 'Lakiin perustuva tiedonkäyttölupa.'
return t(permission)
}

export const isMydataPartner = organizationOid => {
return Boolean(permissionsMap[organizationOid])
}

0 comments on commit 96124fe

Please sign in to comment.