Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SSHOC
sshoc-marketplace-frontend
Commits
70108a88
Commit
70108a88
authored
Jul 05, 2021
by
Stefan Probst
Browse files
fix: clear cache on sign in
parent
8096624e
Pipeline
#209450
failed with stages
in 4 minutes and 42 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib/sshoc/validateCommonFormFields.ts
View file @
70108a88
...
@@ -15,7 +15,7 @@ export function validateCommonFormFields<
...
@@ -15,7 +15,7 @@ export function validateCommonFormFields<
|
PublicationCore
|
PublicationCore
|
ToolCore
|
ToolCore
|
TrainingMaterialCore
|
TrainingMaterialCore
|
WorkflowCore
|
WorkflowCore
,
>
(
>
(
values
:
Partial
<
T
>
,
values
:
Partial
<
T
>
,
errors
:
Partial
<
Record
<
keyof
typeof
values
,
any
>>
,
errors
:
Partial
<
Record
<
keyof
typeof
values
,
any
>>
,
...
@@ -40,7 +40,6 @@ export function validateCommonFormFields<
...
@@ -40,7 +40,6 @@ export function validateCommonFormFields<
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if
(
url
!=
null
&&
!
isUrl
(
url
))
{
if
(
url
!=
null
&&
!
isUrl
(
url
))
{
if
(
errors
.
accessibleAt
===
undefined
)
{
if
(
errors
.
accessibleAt
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
accessibleAt
=
[]
errors
.
accessibleAt
=
[]
}
}
errors
.
accessibleAt
[
index
]
=
'
Must be a valid URL.
'
errors
.
accessibleAt
[
index
]
=
'
Must be a valid URL.
'
...
@@ -58,7 +57,6 @@ export function validateCommonFormFields<
...
@@ -58,7 +57,6 @@ export function validateCommonFormFields<
contributor
.
actor
===
undefined
contributor
.
actor
===
undefined
)
{
)
{
if
(
errors
.
contributors
===
undefined
)
{
if
(
errors
.
contributors
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
contributors
=
[]
errors
.
contributors
=
[]
}
}
errors
.
contributors
[
index
]
=
{
errors
.
contributors
[
index
]
=
{
...
@@ -78,7 +76,6 @@ export function validateCommonFormFields<
...
@@ -78,7 +76,6 @@ export function validateCommonFormFields<
contributor
.
role
===
undefined
contributor
.
role
===
undefined
)
{
)
{
if
(
errors
.
contributors
===
undefined
)
{
if
(
errors
.
contributors
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
contributors
=
[]
errors
.
contributors
=
[]
}
}
errors
.
contributors
[
index
]
=
{
errors
.
contributors
[
index
]
=
{
...
@@ -98,7 +95,6 @@ export function validateCommonFormFields<
...
@@ -98,7 +95,6 @@ export function validateCommonFormFields<
(
property
.
value
!==
undefined
||
property
.
concept
!==
undefined
)
(
property
.
value
!==
undefined
||
property
.
concept
!==
undefined
)
)
{
)
{
if
(
errors
.
properties
===
undefined
)
{
if
(
errors
.
properties
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
properties
=
[]
errors
.
properties
=
[]
}
}
errors
.
properties
[
index
]
=
{
errors
.
properties
[
index
]
=
{
...
@@ -129,7 +125,6 @@ export function validateCommonFormFields<
...
@@ -129,7 +125,6 @@ export function validateCommonFormFields<
(
type
===
'
float
'
&&
!
Number
.
isFinite
(
Number
(
property
.
value
)))
(
type
===
'
float
'
&&
!
Number
.
isFinite
(
Number
(
property
.
value
)))
)
{
)
{
if
(
errors
.
properties
===
undefined
)
{
if
(
errors
.
properties
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
properties
=
[]
errors
.
properties
=
[]
}
}
errors
.
properties
[
index
]
=
{
errors
.
properties
[
index
]
=
{
...
@@ -152,7 +147,6 @@ export function validateCommonFormFields<
...
@@ -152,7 +147,6 @@ export function validateCommonFormFields<
property
.
concept
===
undefined
property
.
concept
===
undefined
)
{
)
{
if
(
errors
.
properties
===
undefined
)
{
if
(
errors
.
properties
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
properties
=
[]
errors
.
properties
=
[]
}
}
errors
.
properties
[
index
]
=
{
errors
.
properties
[
index
]
=
{
...
@@ -173,7 +167,6 @@ export function validateCommonFormFields<
...
@@ -173,7 +167,6 @@ export function validateCommonFormFields<
item
.
persistentId
===
undefined
item
.
persistentId
===
undefined
)
{
)
{
if
(
errors
.
relatedItems
===
undefined
)
{
if
(
errors
.
relatedItems
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
relatedItems
=
[]
errors
.
relatedItems
=
[]
}
}
errors
.
relatedItems
[
index
]
=
{
persistentId
:
'
Please select an item.
'
}
errors
.
relatedItems
[
index
]
=
{
persistentId
:
'
Please select an item.
'
}
...
@@ -191,7 +184,6 @@ export function validateCommonFormFields<
...
@@ -191,7 +184,6 @@ export function validateCommonFormFields<
item
.
relation
===
undefined
item
.
relation
===
undefined
)
{
)
{
if
(
errors
.
relatedItems
===
undefined
)
{
if
(
errors
.
relatedItems
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
relatedItems
=
[]
errors
.
relatedItems
=
[]
}
}
errors
.
relatedItems
[
index
]
=
{
errors
.
relatedItems
[
index
]
=
{
...
@@ -212,7 +204,6 @@ export function validateCommonFormFields<
...
@@ -212,7 +204,6 @@ export function validateCommonFormFields<
id
.
identifier
==
null
id
.
identifier
==
null
)
{
)
{
if
(
errors
.
externalIds
===
undefined
)
{
if
(
errors
.
externalIds
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
externalIds
=
[]
errors
.
externalIds
=
[]
}
}
errors
.
externalIds
[
index
]
=
{
errors
.
externalIds
[
index
]
=
{
...
@@ -233,7 +224,6 @@ export function validateCommonFormFields<
...
@@ -233,7 +224,6 @@ export function validateCommonFormFields<
id
.
identifierService
?.
code
==
null
id
.
identifierService
?.
code
==
null
)
{
)
{
if
(
errors
.
externalIds
===
undefined
)
{
if
(
errors
.
externalIds
===
undefined
)
{
/* @ts-expect-error Untyped empty array. */
errors
.
externalIds
=
[]
errors
.
externalIds
=
[]
}
}
errors
.
externalIds
[
index
]
=
{
errors
.
externalIds
[
index
]
=
{
...
...
src/modules/auth/AuthContext.tsx
View file @
70108a88
...
@@ -43,7 +43,12 @@ export function useAuth(): Auth {
...
@@ -43,7 +43,12 @@ export function useAuth(): Auth {
*/
*/
export
default
function
AuthProvider
({
export
default
function
AuthProvider
({
children
,
children
,
}:
PropsWithChildren
<
unknown
>
):
JSX
.
Element
{
onSignIn
,
onSignOut
,
}:
PropsWithChildren
<
{
onSignIn
?:
()
=>
void
onSignOut
?:
()
=>
void
}
>
):
JSX
.
Element
{
const
[
session
,
setSession
]
=
useLocalStorage
<
Session
|
null
>
(
'
session
'
,
null
)
const
[
session
,
setSession
]
=
useLocalStorage
<
Session
|
null
>
(
'
session
'
,
null
)
const
auth
=
useMemo
(()
=>
{
const
auth
=
useMemo
(()
=>
{
...
@@ -57,11 +62,13 @@ export default function AuthProvider({
...
@@ -57,11 +62,13 @@ export default function AuthProvider({
accessToken
:
token
,
accessToken
:
token
,
expiresAt
:
decoded
.
exp
,
expiresAt
:
decoded
.
exp
,
})
})
onSignIn
?.()
}
}
}
}
function
signOut
()
{
function
signOut
()
{
setSession
(
null
)
setSession
(
null
)
onSignOut
?.()
}
}
function
validateToken
(
token
:
string
)
{
function
validateToken
(
token
:
string
)
{
...
...
src/modules/page/PageHeader.tsx
View file @
70108a88
...
@@ -5,7 +5,6 @@ import type { NextRouter } from 'next/router'
...
@@ -5,7 +5,6 @@ import type { NextRouter } from 'next/router'
import
{
useRouter
}
from
'
next/router
'
import
{
useRouter
}
from
'
next/router
'
import
type
{
PropsWithChildren
,
Ref
}
from
'
react
'
import
type
{
PropsWithChildren
,
Ref
}
from
'
react
'
import
{
Fragment
,
useEffect
,
useState
}
from
'
react
'
import
{
Fragment
,
useEffect
,
useState
}
from
'
react
'
import
{
useQueryClient
}
from
'
react-query
'
import
{
useGetItemCategories
,
useGetLoggedInUser
}
from
'
@/api/sshoc
'
import
{
useGetItemCategories
,
useGetLoggedInUser
}
from
'
@/api/sshoc
'
import
type
{
ItemCategory
,
ItemSearchQuery
}
from
'
@/api/sshoc/types
'
import
type
{
ItemCategory
,
ItemSearchQuery
}
from
'
@/api/sshoc/types
'
...
@@ -243,7 +242,6 @@ function ReportAnIssueButton({
...
@@ -243,7 +242,6 @@ function ReportAnIssueButton({
function
AuthButton
()
{
function
AuthButton
()
{
const
router
=
useRouter
()
const
router
=
useRouter
()
const
auth
=
useAuth
()
const
auth
=
useAuth
()
const
queryClient
=
useQueryClient
()
const
{
data
:
user
}
=
useGetLoggedInUser
(
const
{
data
:
user
}
=
useGetLoggedInUser
(
{
{
...
@@ -278,8 +276,6 @@ function AuthButton() {
...
@@ -278,8 +276,6 @@ function AuthButton() {
function
onSignOut
()
{
function
onSignOut
()
{
auth
.
signOut
()
auth
.
signOut
()
/** clear the whole query cache to be on the safe side */
queryClient
.
clear
()
router
.
replace
(
router
.
replace
(
getRedirectPath
(
getScalarQueryParameter
(
router
.
query
.
from
))
??
'
/
'
,
getRedirectPath
(
getScalarQueryParameter
(
router
.
query
.
from
))
??
'
/
'
,
)
)
...
...
src/pages/_app.tsx
View file @
70108a88
...
@@ -94,7 +94,12 @@ function Providers({ children }: PropsWithChildren<unknown>) {
...
@@ -94,7 +94,12 @@ function Providers({ children }: PropsWithChildren<unknown>) {
<
SSRProvider
>
<
SSRProvider
>
<
I18nProvider
locale
=
"en"
>
<
I18nProvider
locale
=
"en"
>
<
QueryClientProvider
client
=
{
queryClient
}
>
<
QueryClientProvider
client
=
{
queryClient
}
>
<
AuthProvider
>
{
children
}
</
AuthProvider
>
<
AuthProvider
onSignIn
=
{
queryClient
.
clear
}
onSignOut
=
{
queryClient
.
clear
}
>
{
children
}
</
AuthProvider
>
</
QueryClientProvider
>
</
QueryClientProvider
>
</
I18nProvider
>
</
I18nProvider
>
</
SSRProvider
>
</
SSRProvider
>
...
...
src/screens/browse/BrowseActivitiesScreen.tsx
View file @
70108a88
import
BrowseLayout
from
'
@/screens/browse/BrowseLayout
.tsx
'
import
BrowseLayout
from
'
@/screens/browse/BrowseLayout
'
export
default
function
BrowseActivitiesScreen
():
JSX
.
Element
{
export
default
function
BrowseActivitiesScreen
():
JSX
.
Element
{
return
(
return
(
...
...
src/screens/browse/BrowseKeywordsScreen.tsx
View file @
70108a88
import
BrowseLayout
from
'
@/screens/browse/BrowseLayout
.tsx
'
import
BrowseLayout
from
'
@/screens/browse/BrowseLayout
'
export
default
function
BrowseKeywordsScreen
():
JSX
.
Element
{
export
default
function
BrowseKeywordsScreen
():
JSX
.
Element
{
return
(
return
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment