File tree 13 files changed +71
-33
lines changed
13 files changed +71
-33
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ rm -rf .env
29
29
echo "
30
30
PORT=$WEB_PORT
31
31
REACT_APP_GRAPHQL_URL=http://localhost:$BACKEND_PORT /graphql
32
- REACT_APP_NOTIFICATIONS_URL=https://notifications.automatisch.io
33
32
" >> .env
34
33
cd $CURRENT_DIR
35
34
Original file line number Diff line number Diff line change 1
1
{
2
2
"editor.formatOnSave" : true ,
3
- "editor.defaultFormatter" : " esbenp.prettier-vscode"
3
+ "editor.defaultFormatter" : " esbenp.prettier-vscode" ,
4
+ "[javascript]" : {
5
+ "editor.defaultFormatter" : " esbenp.prettier-vscode"
6
+ }
4
7
}
Original file line number Diff line number Diff line change
1
+ import axios from '../../helpers/axios-with-proxy' ;
2
+
3
+ const NOTIFICATIONS_URL = 'https://notifications.automatisch.io/notifications.json' ;
4
+
5
+ const getNotifications = async ( ) => {
6
+ try {
7
+ const { data : notifications = [ ] } = await axios . get ( NOTIFICATIONS_URL ) ;
8
+
9
+ return notifications ;
10
+ } catch ( err ) {
11
+ return [ ] ;
12
+ }
13
+ } ;
14
+
15
+ export default getNotifications ;
Original file line number Diff line number Diff line change @@ -16,13 +16,14 @@ import getExecutions from './queries/get-executions';
16
16
import getFlow from './queries/get-flow' ;
17
17
import getFlows from './queries/get-flows' ;
18
18
import getInvoices from './queries/get-invoices.ee' ;
19
+ import getNotifications from './queries/get-notifications' ;
19
20
import getPaddleInfo from './queries/get-paddle-info.ee' ;
20
21
import getPaymentPlans from './queries/get-payment-plans.ee' ;
21
22
import getPermissionCatalog from './queries/get-permission-catalog.ee' ;
22
23
import getRole from './queries/get-role.ee' ;
23
24
import getRoles from './queries/get-roles.ee' ;
24
- import getSamlAuthProvider from './queries/get-saml-auth-provider.ee' ;
25
25
import getSamlAuthProviderRoleMappings from './queries/get-saml-auth-provider-role-mappings.ee' ;
26
+ import getSamlAuthProvider from './queries/get-saml-auth-provider.ee' ;
26
27
import getStepWithTestExecutions from './queries/get-step-with-test-executions' ;
27
28
import getSubscriptionStatus from './queries/get-subscription-status.ee' ;
28
29
import getTrialStatus from './queries/get-trial-status.ee' ;
@@ -51,6 +52,7 @@ const queryResolvers = {
51
52
getFlow,
52
53
getFlows,
53
54
getInvoices,
55
+ getNotifications,
54
56
getPaddleInfo,
55
57
getPaymentPlans,
56
58
getPermissionCatalog,
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ type Query {
46
46
getPermissionCatalog : PermissionCatalog
47
47
getRole (id : String ! ): Role
48
48
getRoles : [Role ]
49
+ getNotifications : [Notification ]
49
50
getSamlAuthProvider : SamlAuthProvider
50
51
getSamlAuthProviderRoleMappings (id : String ! ): [SamlAuthProvidersRoleMapping ]
51
52
getSubscriptionStatus : GetSubscriptionStatus
@@ -787,6 +788,13 @@ input UpdateAppAuthClientInput {
787
788
active : Boolean
788
789
}
789
790
791
+ type Notification {
792
+ name : String
793
+ createdAt : String
794
+ documentationUrl : String
795
+ description : String
796
+ }
797
+
790
798
schema {
791
799
query : Query
792
800
mutation : Mutation
Original file line number Diff line number Diff line change 1
- import { rule , shield , allow } from 'graphql-shield' ;
1
+ import { allow , rule , shield } from 'graphql-shield' ;
2
2
import jwt from 'jsonwebtoken' ;
3
- import User from '../models/user' ;
4
3
import appConfig from '../config/app' ;
4
+ import User from '../models/user' ;
5
5
6
6
const isAuthenticated = rule ( ) ( async ( _parent , _args , req ) => {
7
7
const token = req . headers [ 'authorization' ] ;
@@ -34,15 +34,16 @@ const authentication = shield(
34
34
Query : {
35
35
'*' : isAuthenticated ,
36
36
getAutomatischInfo : allow ,
37
- listSamlAuthProviders : allow ,
38
- healthcheck : allow ,
39
37
getConfig : allow ,
38
+ getNotifications : allow ,
39
+ healthcheck : allow ,
40
+ listSamlAuthProviders : allow ,
40
41
} ,
41
42
Mutation : {
42
43
'*' : isAuthenticated ,
43
- registerUser : allow ,
44
44
forgotPassword : allow ,
45
45
login : allow ,
46
+ registerUser : allow ,
46
47
resetPassword : allow ,
47
48
} ,
48
49
} ,
Original file line number Diff line number Diff line change @@ -448,6 +448,13 @@ type AppAuthClient = {
448
448
formattedAuthDefaults : IJSONObject ;
449
449
} ;
450
450
451
+ type Notification = {
452
+ name : string ;
453
+ createdAt : string ;
454
+ documentationUrl : string ;
455
+ description : string ;
456
+ }
457
+
451
458
declare module 'axios' {
452
459
interface AxiosResponse {
453
460
httpError ?: IJSONObject ;
Original file line number Diff line number Diff line change @@ -2,4 +2,3 @@ PORT=3001
2
2
REACT_APP_GRAPHQL_URL=http://localhost:3000/graphql
3
3
# HTTPS=true
4
4
REACT_APP_BASE_URL=http://localhost:3001
5
- REACT_APP_NOTIFICATIONS_URL=https://notifications.automatisch.io
Original file line number Diff line number Diff line change @@ -2,15 +2,13 @@ type Config = {
2
2
[ key : string ] : string ;
3
3
baseUrl : string ;
4
4
graphqlUrl : string ;
5
- notificationsUrl : string ;
6
5
chatwootBaseUrl : string ;
7
6
supportEmailAddress : string ;
8
7
} ;
9
8
10
9
const config : Config = {
11
10
baseUrl : process . env . REACT_APP_BASE_URL as string ,
12
11
graphqlUrl : process . env . REACT_APP_GRAPHQL_URL as string ,
13
- notificationsUrl : process . env . REACT_APP_NOTIFICATIONS_URL as string ,
14
12
chatwootBaseUrl : 'https://app.chatwoot.com' ,
15
13
supportEmailAddress :
'[email protected] ' ,
16
14
} ;
Original file line number Diff line number Diff line change
1
+ import { gql } from '@apollo/client' ;
2
+
3
+ export const GET_NOTIFICATIONS = gql `
4
+ query GetNotifications {
5
+ getNotifications {
6
+ name
7
+ createdAt
8
+ documentationUrl
9
+ description
10
+ }
11
+ }
12
+ ` ;
Original file line number Diff line number Diff line change 1
- import * as React from 'react ' ;
2
- import appConfig from 'config/app ' ;
1
+ import { useQuery } from '@apollo/client ' ;
2
+ import type { Notification } from '@automatisch/types ' ;
3
3
4
- interface INotification {
5
- name : string ;
6
- createdAt : string ;
7
- documentationUrl : string ;
8
- description : string ;
4
+ import { GET_NOTIFICATIONS } from 'graphql/queries/get-notifications' ;
5
+
6
+ type UseNotificationsReturn = {
7
+ notifications : Notification [ ] ;
8
+ loading : boolean ;
9
9
}
10
10
11
- export default function useNotifications ( ) : INotification [ ] {
12
- const [ notifications , setNotifications ] = React . useState < INotification [ ] > ( [ ] ) ;
11
+ export default function useNotifications ( ) : UseNotificationsReturn {
12
+ const { data , loading } = useQuery ( GET_NOTIFICATIONS ) ;
13
13
14
- React . useEffect ( ( ) => {
15
- fetch ( `${ appConfig . notificationsUrl } /notifications.json` )
16
- . then ( ( response ) => response . json ( ) )
17
- . then ( ( notifications ) => {
18
- if ( Array . isArray ( notifications ) && notifications . length ) {
19
- setNotifications ( notifications ) ;
20
- }
21
- } )
22
- . catch ( console . error ) ;
23
- } , [ ] ) ;
14
+ const notifications = data ?. getNotifications || [ ] ;
24
15
25
- return notifications ;
16
+ return {
17
+ loading,
18
+ notifications,
19
+ } ;
26
20
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ type TVersionInfo = {
10
10
} ;
11
11
12
12
export default function useVersion ( ) : TVersionInfo {
13
- const notifications = useNotifications ( ) ;
13
+ const { notifications } = useNotifications ( ) ;
14
14
const { data } = useQuery ( HEALTHCHECK , { fetchPolicy : 'cache-and-network' } ) ;
15
15
const version = data ?. healthcheck . version ;
16
16
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ interface INotification {
17
17
18
18
export default function Updates ( ) : React . ReactElement {
19
19
const formatMessage = useFormatMessage ( ) ;
20
- const notifications = useNotifications ( ) ;
20
+ const { notifications } = useNotifications ( ) ;
21
21
22
22
return (
23
23
< Box sx = { { py : 3 } } >
You can’t perform that action at this time.
0 commit comments