@etsoo/react 1.5.2 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app/ReactApp.d.ts +9 -0
- package/lib/app/ReactApp.js +6 -1
- package/lib/app/ServiceApp.js +9 -11
- package/package.json +2 -2
- package/src/app/ReactApp.ts +16 -1
- package/src/app/ServiceApp.ts +11 -10
package/lib/app/ReactApp.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CoreApp, IActionResult, IAppSettings, ICoreApp, IUser, IUserData } from '@etsoo/appscript';
|
|
2
2
|
import { NotificationRenderProps, NotificationReturn } from '@etsoo/notificationbase';
|
|
3
3
|
import { DataTypes } from '@etsoo/shared';
|
|
4
|
+
import { History } from '@reach/router';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { NotificationReactCallProps } from '../notifier/Notifier';
|
|
6
7
|
import { CultureAction, CultureState } from '../states/CultureState';
|
|
@@ -30,6 +31,10 @@ export interface IReactApp<S extends IAppSettings, D extends IUser, P extends IP
|
|
|
30
31
|
* User state
|
|
31
32
|
*/
|
|
32
33
|
readonly userState: UserState<D>;
|
|
34
|
+
/**
|
|
35
|
+
* Router history
|
|
36
|
+
*/
|
|
37
|
+
readonly history?: History;
|
|
33
38
|
/**
|
|
34
39
|
* Is screen size down 'sm'
|
|
35
40
|
*/
|
|
@@ -69,6 +74,10 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
|
|
|
69
74
|
* Culture state
|
|
70
75
|
*/
|
|
71
76
|
readonly cultureState: CultureState;
|
|
77
|
+
/**
|
|
78
|
+
* Router history
|
|
79
|
+
*/
|
|
80
|
+
readonly history?: History;
|
|
72
81
|
/**
|
|
73
82
|
* Page state
|
|
74
83
|
*/
|
package/lib/app/ReactApp.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ActionResultError, BridgeUtils, CoreApp, createClient } from '@etsoo/appscript';
|
|
2
2
|
import { WindowStorage } from '@etsoo/shared';
|
|
3
|
+
import { navigate } from '@reach/router';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { NotifierMU } from '../mu/NotifierMU';
|
|
5
6
|
import { ProgressCount } from '../mu/ProgressCount';
|
|
@@ -64,6 +65,10 @@ export class ReactApp extends CoreApp {
|
|
|
64
65
|
* User state
|
|
65
66
|
*/
|
|
66
67
|
this.userState = new UserState();
|
|
68
|
+
this.history =
|
|
69
|
+
window.location.hostname === ''
|
|
70
|
+
? Utils.getMemoryHistory()
|
|
71
|
+
: undefined;
|
|
67
72
|
this.cultureState = new CultureState(settings.currentCulture);
|
|
68
73
|
this.pageState = new PageState();
|
|
69
74
|
globalApp = this;
|
|
@@ -194,7 +199,7 @@ export class ReactApp extends CoreApp {
|
|
|
194
199
|
* @param url Url
|
|
195
200
|
*/
|
|
196
201
|
redirectTo(url) {
|
|
197
|
-
|
|
202
|
+
(this.history == null ? navigate : this.history.navigate)(url);
|
|
198
203
|
}
|
|
199
204
|
/**
|
|
200
205
|
* Set page data
|
package/lib/app/ServiceApp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createClient } from '@etsoo/appscript';
|
|
1
|
+
import { BridgeUtils, createClient } from '@etsoo/appscript';
|
|
2
2
|
import { DomUtils } from '@etsoo/shared';
|
|
3
3
|
import { CoreConstants } from './CoreConstants';
|
|
4
4
|
import { ReactApp } from './ReactApp';
|
|
@@ -44,16 +44,14 @@ export class ServiceApp extends ReactApp {
|
|
|
44
44
|
* @param tryLogin Try to login again
|
|
45
45
|
*/
|
|
46
46
|
toLoginPage(tryLogin) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
coreUrl
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.culture +
|
|
56
|
-
(tryLogin ? '' : '&tryLogin=false');
|
|
47
|
+
const parameters = `?serviceId=${this.settings.serviceId}&${DomUtils.CultureField}=${this.culture}${tryLogin ? '' : '&tryLogin=false'}`;
|
|
48
|
+
if (BridgeUtils.host == null) {
|
|
49
|
+
const coreUrl = this.settings.webUrl;
|
|
50
|
+
window.location.href = coreUrl + parameters;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
BridgeUtils.host.loadApp('core', parameters);
|
|
54
|
+
}
|
|
57
55
|
}
|
|
58
56
|
/**
|
|
59
57
|
* Refresh token
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.6",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@emotion/react": "^11.7.1",
|
|
51
51
|
"@emotion/style": "^0.8.0",
|
|
52
52
|
"@emotion/styled": "^11.6.0",
|
|
53
|
-
"@etsoo/appscript": "^1.2.
|
|
53
|
+
"@etsoo/appscript": "^1.2.45",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.1",
|
|
55
55
|
"@etsoo/shared": "^1.1.11",
|
|
56
56
|
"@mui/icons-material": "^5.4.1",
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
NotificationReturn
|
|
15
15
|
} from '@etsoo/notificationbase';
|
|
16
16
|
import { DataTypes, WindowStorage } from '@etsoo/shared';
|
|
17
|
+
import { History, navigate } from '@reach/router';
|
|
17
18
|
import React from 'react';
|
|
18
19
|
import { NotifierMU } from '../mu/NotifierMU';
|
|
19
20
|
import { ProgressCount } from '../mu/ProgressCount';
|
|
@@ -98,6 +99,11 @@ export interface IReactApp<
|
|
|
98
99
|
*/
|
|
99
100
|
readonly userState: UserState<D>;
|
|
100
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Router history
|
|
104
|
+
*/
|
|
105
|
+
readonly history?: History;
|
|
106
|
+
|
|
101
107
|
/**
|
|
102
108
|
* Is screen size down 'sm'
|
|
103
109
|
*/
|
|
@@ -167,6 +173,11 @@ export class ReactApp<
|
|
|
167
173
|
*/
|
|
168
174
|
readonly cultureState: CultureState;
|
|
169
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Router history
|
|
178
|
+
*/
|
|
179
|
+
readonly history?: History;
|
|
180
|
+
|
|
170
181
|
/**
|
|
171
182
|
* Page state
|
|
172
183
|
*/
|
|
@@ -210,6 +221,10 @@ export class ReactApp<
|
|
|
210
221
|
new WindowStorage(),
|
|
211
222
|
name
|
|
212
223
|
);
|
|
224
|
+
this.history =
|
|
225
|
+
window.location.hostname === ''
|
|
226
|
+
? Utils.getMemoryHistory()
|
|
227
|
+
: undefined;
|
|
213
228
|
this.cultureState = new CultureState(settings.currentCulture);
|
|
214
229
|
this.pageState = new PageState<P>();
|
|
215
230
|
|
|
@@ -355,7 +370,7 @@ export class ReactApp<
|
|
|
355
370
|
* @param url Url
|
|
356
371
|
*/
|
|
357
372
|
override redirectTo(url: string) {
|
|
358
|
-
|
|
373
|
+
(this.history == null ? navigate : this.history.navigate)(url);
|
|
359
374
|
}
|
|
360
375
|
|
|
361
376
|
/**
|
package/src/app/ServiceApp.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BridgeUtils,
|
|
2
3
|
createClient,
|
|
3
4
|
IApi,
|
|
4
5
|
IApiPayload,
|
|
@@ -72,16 +73,16 @@ export class ServiceApp<
|
|
|
72
73
|
* @param tryLogin Try to login again
|
|
73
74
|
*/
|
|
74
75
|
override toLoginPage(tryLogin?: boolean) {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
const parameters = `?serviceId=${this.settings.serviceId}&${
|
|
77
|
+
DomUtils.CultureField
|
|
78
|
+
}=${this.culture}${tryLogin ? '' : '&tryLogin=false'}`;
|
|
79
|
+
|
|
80
|
+
if (BridgeUtils.host == null) {
|
|
81
|
+
const coreUrl = this.settings.webUrl;
|
|
82
|
+
window.location.href = coreUrl + parameters;
|
|
83
|
+
} else {
|
|
84
|
+
BridgeUtils.host.loadApp('core', parameters);
|
|
85
|
+
}
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
/**
|