Skip to content

Commit

Permalink
Merge branch 'main' of github.com:island-is/island.is into j-s/civil-…
Browse files Browse the repository at this point in the history
…demands
  • Loading branch information
gudjong committed Sep 13, 2024
2 parents 2205d91 + e09340c commit 7ad5f8d
Show file tree
Hide file tree
Showing 156 changed files with 708 additions and 353 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ jobs:
# See this for more information:
# https://github.blog/changelog/2020-10-08-github-actions-ability-to-change-retention-days-for-artifacts-and-logs/
- name: Keep PR run event
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@b18b1d32f3f31abcdc29dee3f2484801fe7822f4
with:
name: pr-event
path: event.json
retention-days: 90
include-hidden-files: true
if-no-files-found: error

- name: Get cache
id: get-cache
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,14 @@ jobs:
# See this for more information:
# https://github.blog/changelog/2020-10-08-github-actions-ability-to-change-retention-days-for-artifacts-and-logs/
- name: Keep PR run event
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@b18b1d32f3f31abcdc29dee3f2484801fe7822f4
if: needs.pre-checks.outputs.PRE_CHECK && needs.pre-checks.outputs.PRE_CHECK == 'feature-deploy'
with:
name: pr-event
path: event.json
retention-days: 90
include-hidden-files: true
if-no-files-found: error

- name: Generate nodejs image tag
id: nodejs_image
Expand Down
5 changes: 5 additions & 0 deletions apps/api/infra/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ export const serviceSetup = (services: {
FISKISTOFA_ZENTER_CLIENT_ID: '1114',
HSN_WEB_FORM_ID: '1dimJFHLFYtnhoYEA3JxRK',
SESSIONS_API_URL: ref((h) => `http://${h.svc(services.sessionsApi)}`),
AUTH_ADMIN_API_PATH: {
dev: 'https://identity-server.dev01.devland.is/backend',
staging: 'https://identity-server.staging01.devland.is/backend',
prod: 'https://innskra.island.is/backend',
},
AUTH_ADMIN_API_PATHS: {
dev: json({
development: 'https://identity-server.dev01.devland.is/backend',
Expand Down
3 changes: 3 additions & 0 deletions apps/services/auth/admin-api/infra/auth-admin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
service,
ServiceBuilder,
} from '../../../../../infra/src/dsl/dsl'
import { Base, Client, RskProcuring } from '../../../../../infra/src/dsl/xroad'

const REDIS_NODE_CONFIG = {
dev: json([
Expand All @@ -25,6 +26,7 @@ export const serviceSetup = (): ServiceBuilder<'services-auth-admin-api'> => {
name: 'servicesauth',
})
.env({
IDENTITY_SERVER_CLIENT_ID: '@island.is/clients/auth-api',
IDENTITY_SERVER_ISSUER_URL: {
dev: 'https://identity-server.dev01.devland.is',
staging: 'https://identity-server.staging01.devland.is',
Expand Down Expand Up @@ -66,6 +68,7 @@ export const serviceSetup = (): ServiceBuilder<'services-auth-admin-api'> => {
NATIONAL_REGISTRY_IDS_CLIENT_SECRET:
'/k8s/xroad/client/NATIONAL-REGISTRY/IDENTITYSERVER_SECRET',
})
.xroad(Base, Client, RskProcuring)
.ingress({
primary: {
host: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,21 +816,23 @@ describe('User profile API', () => {
)
})

it('POST /userProfile/{nationalId}/device-tokens duplicate token should return 400 bad request', async () => {
it('POST /userProfile/{nationalId}/device-tokens duplicate token should return the existing token', async () => {
// create it
await request(app.getHttpServer())
const res1 = await request(app.getHttpServer())
.post(`/userProfile/${mockProfile.nationalId}/device-tokens`)
.send({
deviceToken: mockDeviceToken.deviceToken,
})
.expect(201)
// try to create same again
await request(app.getHttpServer())
const res2 = await request(app.getHttpServer())
.post(`/userProfile/${mockProfile.nationalId}/device-tokens`)
.send({
deviceToken: mockDeviceToken.deviceToken,
})
.expect(400)
.expect(201)

expect(res1.body).toEqual(res2.body)
})

it('POST /userProfile/{nationalId}/device-tokens with missing payload should 400 bad request', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@ export class UserProfileController {
} else {
// findOrCreateUserProfile for edge cases - fragmented onboarding
await this.findOrCreateUserProfile(nationalId, user)
return await this.userProfileService.addDeviceToken(body, user)
// The behaviour of returning the token if it already exists is not following API Design Guide
// It should respond with 303 See Other and a Location header to the existing resource
// But as the v1 of the user profile is not following this, we will keep the same behaviour.
return this.userProfileService.addDeviceToken(body, user)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ export class UserProfileService {

async addDeviceToken(body: DeviceTokenDto, user: User) {
try {
const token = await this.userDeviceTokensModel.findOne({
where: { nationalId: user.nationalId, deviceToken: body.deviceToken },
})

if (token) {
return token
}

return await this.userDeviceTokensModel.create({
...body,
nationalId: user.nationalId,
Expand Down
4 changes: 4 additions & 0 deletions apps/web/components/GenericList/GenericList.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import { style } from '@vanilla-extract/css'
export const clickableItemTopRowContainer = style({
minHeight: '30px',
})

export const filterTagsContainer = style({
minHeight: '32px',
})
83 changes: 44 additions & 39 deletions apps/web/components/GenericList/GenericList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ export const GenericList = ({
variant={isMobile ? 'dialog' : 'popover'}
onFilterClear={() => {
setParameters(null)
setPage(null)
}}
filterInput={filterInputComponent}
>
Expand All @@ -342,6 +343,7 @@ export const GenericList = ({
: 'Clear selection'
}
onChange={({ categoryId, selected }) => {
setPage(null)
setParameters((prevParameters) => {
// Make sure we clear out the query params from the url when there is nothing selected
if (
Expand All @@ -361,6 +363,7 @@ export const GenericList = ({
})
}}
onClear={(categoryId) => {
setPage(null)
setParameters((prevParameters) => {
const updatedParameters = {
...prevParameters,
Expand All @@ -384,43 +387,45 @@ export const GenericList = ({
</Filter>
</Stack>

<Inline space={1} alignY="top">
{selectedFilters.length > 0 && (
<Text>
{activeLocale === 'is' ? 'Síað eftir:' : 'Filtered by:'}
</Text>
)}
<Inline space={1}>
{selectedFilters.map(({ value, label, category }) => (
<FilterTag
key={value}
onClick={() => {
setParameters((prevParameters) => {
const updatedParameters = {
...prevParameters,
[category]: (
prevParameters?.[category] ?? []
).filter((prevValue) => prevValue !== value),
}

// Make sure we clear out the query params from the url when there is nothing selected
if (
Object.values(updatedParameters).every(
(s) => !s || s.length === 0,
)
) {
return null
}

return updatedParameters
})
}}
>
{label}
</FilterTag>
))}
<Box className={styles.filterTagsContainer}>
<Inline space={1} alignY="top">
{selectedFilters.length > 0 && (
<Text>
{activeLocale === 'is' ? 'Síað eftir:' : 'Filtered by:'}
</Text>
)}
<Inline space={1}>
{selectedFilters.map(({ value, label, category }) => (
<FilterTag
key={value}
onClick={() => {
setParameters((prevParameters) => {
const updatedParameters = {
...prevParameters,
[category]: (
prevParameters?.[category] ?? []
).filter((prevValue) => prevValue !== value),
}

// Make sure we clear out the query params from the url when there is nothing selected
if (
Object.values(updatedParameters).every(
(s) => !s || s.length === 0,
)
) {
return null
}

return updatedParameters
})
}}
>
{label}
</FilterTag>
))}
</Inline>
</Inline>
</Inline>
</Box>
</Stack>
)}
{filterCategories.length === 0 && filterInputComponent}
Expand All @@ -436,7 +441,7 @@ export const GenericList = ({
}
/>
)}
{totalItems === 0 && !displayError && (
{totalItems === 0 && !displayError && !loading && (
<Text>{noResultsFoundText}</Text>
)}
{totalItems > 0 && (
Expand Down Expand Up @@ -511,7 +516,7 @@ export const GenericListWrapper = ({
useState<GenericListItemResponse | null>(null)
const [errorOccurred, setErrorOccurred] = useState(false)

const [fetchListItems, { loading }] = useLazyQuery<
const [fetchListItems, { loading, called }] = useLazyQuery<
Query,
GetGenericListItemsQueryVariables
>(GET_GENERIC_LIST_ITEMS_QUERY, {
Expand Down Expand Up @@ -567,7 +572,7 @@ export const GenericListWrapper = ({
})
}}
totalItems={totalItems}
loading={loading}
loading={loading || !called}
pageQueryId={pageQueryId}
searchQueryId={searchQueryId}
tagQueryId={tagQueryId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const TeamMemberListWrapper = ({
)
const [errorOccurred, setErrorOccurred] = useState(false)

const [fetchListItems, { loading }] = useLazyQuery<Query>(
const [fetchListItems, { loading, called }] = useLazyQuery<Query>(
GET_TEAM_MEMBERS_QUERY,
{
onCompleted(data) {
Expand Down Expand Up @@ -89,7 +89,7 @@ export const TeamMemberListWrapper = ({
})
}}
totalItems={totalItems}
loading={loading}
loading={loading || !called}
pageQueryId={pageQueryId}
searchQueryId={searchQueryId}
tagQueryId={tagQueryId}
Expand Down
Loading

0 comments on commit 7ad5f8d

Please sign in to comment.