@equinor/fusion-framework-react-components-bookmark 2.0.2 → 2.0.3
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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/esm/components/edit-bookmark/AppNameField.js +10 -0
- package/dist/esm/components/edit-bookmark/AppNameField.js.map +1 -0
- package/dist/esm/components/edit-bookmark/EditBookmarkModal.js +6 -2
- package/dist/esm/components/edit-bookmark/EditBookmarkModal.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/edit-bookmark/AppNameField.d.ts +11 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +8 -6
- package/src/__tests__/AppNameField.test.tsx +39 -0
- package/src/components/edit-bookmark/AppNameField.tsx +27 -0
- package/src/components/edit-bookmark/EditBookmarkModal.tsx +13 -4
- package/src/version.ts +1 -1
- package/tsconfig.json +1 -1
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders the bookmark's app name while making manifest resolution visible.
|
|
3
|
+
*
|
|
4
|
+
* @param props - The resolved display name and whether the manifest request is pending.
|
|
5
|
+
* @returns A read-only app name field with an accessible loading indicator when needed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AppNameField: ({ id, displayName, isLoading, }: {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly displayName?: string;
|
|
10
|
+
readonly isLoading: boolean;
|
|
11
|
+
}) => import("react").JSX.Element;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.0.
|
|
1
|
+
export declare const version = "2.0.3";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-react-components-bookmark",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"rxjs": "^7.8.1",
|
|
26
|
+
"@equinor/fusion-framework-react": "^8.0.1",
|
|
26
27
|
"@equinor/fusion-framework-react-module-bookmark": "^6.0.1",
|
|
27
|
-
"@equinor/fusion-observable": "^9.1.1"
|
|
28
|
-
"@equinor/fusion-framework-react": "^8.0.1"
|
|
28
|
+
"@equinor/fusion-observable": "^9.1.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@equinor/eds-core-react": "^2.3.7",
|
|
@@ -36,9 +36,10 @@
|
|
|
36
36
|
"react": "^19.2.1",
|
|
37
37
|
"styled-components": "^6.3.11",
|
|
38
38
|
"typescript": "^7.0.2",
|
|
39
|
-
"
|
|
39
|
+
"vitest": "^4.1.0",
|
|
40
|
+
"@equinor/fusion-framework-module-app": "^8.0.3",
|
|
40
41
|
"@equinor/fusion-framework-module-event": "^6.0.1",
|
|
41
|
-
"@equinor/fusion-framework-module-
|
|
42
|
+
"@equinor/fusion-framework-module-bookmark": "^4.0.3"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@equinor/eds-core-react": "^2.0.0",
|
|
@@ -55,6 +56,7 @@
|
|
|
55
56
|
}
|
|
56
57
|
},
|
|
57
58
|
"scripts": {
|
|
58
|
-
"build": "tsc -b"
|
|
59
|
+
"build": "tsc -b",
|
|
60
|
+
"test": "vitest --run"
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isValidElement } from 'react';
|
|
2
|
+
import { Input, Progress } from '@equinor/eds-core-react';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { AppNameField } from '../components/edit-bookmark/AppNameField';
|
|
5
|
+
|
|
6
|
+
describe('AppNameField', () => {
|
|
7
|
+
it('shows an accessible progress indicator while the manifest is loading', () => {
|
|
8
|
+
const field = AppNameField({ id: 'app', isLoading: true });
|
|
9
|
+
const loadingIndicator = field.props.rightAdornments;
|
|
10
|
+
|
|
11
|
+
expect(field.type).toBe(Input);
|
|
12
|
+
expect(field.props.id).toBe('app');
|
|
13
|
+
expect(field.props['aria-busy']).toBe(true);
|
|
14
|
+
expect(isValidElement(loadingIndicator)).toBe(true);
|
|
15
|
+
|
|
16
|
+
// Guard the element shape before inspecting progress-specific props.
|
|
17
|
+
if (!isValidElement(loadingIndicator)) {
|
|
18
|
+
throw new Error('Expected a valid loading indicator');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
expect(loadingIndicator.type).toBe(Progress.Circular);
|
|
22
|
+
expect(loadingIndicator.props).toMatchObject({
|
|
23
|
+
'aria-label': 'Loading app name',
|
|
24
|
+
size: 16,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('shows the resolved display name without a progress indicator', () => {
|
|
29
|
+
const field = AppNameField({
|
|
30
|
+
id: 'app',
|
|
31
|
+
displayName: 'My app',
|
|
32
|
+
isLoading: false,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(field.props.value).toBe('My app');
|
|
36
|
+
expect(field.props['aria-busy']).toBe(false);
|
|
37
|
+
expect(field.props.rightAdornments).toBeUndefined();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Input, Progress } from '@equinor/eds-core-react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Renders the bookmark's app name while making manifest resolution visible.
|
|
5
|
+
*
|
|
6
|
+
* @param props - The resolved display name and whether the manifest request is pending.
|
|
7
|
+
* @returns A read-only app name field with an accessible loading indicator when needed.
|
|
8
|
+
*/
|
|
9
|
+
export const AppNameField = ({
|
|
10
|
+
id,
|
|
11
|
+
displayName,
|
|
12
|
+
isLoading,
|
|
13
|
+
}: {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly displayName?: string;
|
|
16
|
+
readonly isLoading: boolean;
|
|
17
|
+
}) => (
|
|
18
|
+
<Input
|
|
19
|
+
id={id}
|
|
20
|
+
readOnly={true}
|
|
21
|
+
value={displayName ?? ''}
|
|
22
|
+
aria-busy={isLoading}
|
|
23
|
+
rightAdornments={
|
|
24
|
+
isLoading ? <Progress.Circular aria-label="Loading app name" size={16} /> : undefined
|
|
25
|
+
}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
@@ -12,6 +12,7 @@ import { Button, Checkbox, Dialog, Input, Label, Textarea } from '@equinor/eds-c
|
|
|
12
12
|
import styled from 'styled-components';
|
|
13
13
|
|
|
14
14
|
import { useBookmarkComponentContext } from '../BookmarkProvider';
|
|
15
|
+
import { AppNameField } from './AppNameField';
|
|
15
16
|
|
|
16
17
|
const Styled = {
|
|
17
18
|
Dialog: styled(Dialog)`
|
|
@@ -60,6 +61,7 @@ export const EditBookmarkModal = ({
|
|
|
60
61
|
|
|
61
62
|
const nameId = useId();
|
|
62
63
|
const descriptionId = useId();
|
|
64
|
+
const appId = useId();
|
|
63
65
|
|
|
64
66
|
const [updatePayload, setUpdatePayload] = useState(false);
|
|
65
67
|
|
|
@@ -81,12 +83,16 @@ export const EditBookmarkModal = ({
|
|
|
81
83
|
|
|
82
84
|
// TODO(#5091): this should be on the bookmark object
|
|
83
85
|
const appProvider = useFrameworkModule<AppModule>('app');
|
|
84
|
-
const { value: appName } = useObservableState(
|
|
86
|
+
const { value: appName, error: appNameError } = useObservableState(
|
|
85
87
|
useMemo(
|
|
86
88
|
() => (bookmark && appProvider ? appProvider.getAppManifest(bookmark.appKey) : of(undefined)),
|
|
87
89
|
[appProvider, bookmark],
|
|
88
90
|
),
|
|
89
91
|
);
|
|
92
|
+
// Only report a pending manifest request; missing providers and failed requests are not loading.
|
|
93
|
+
const isAppNameLoading = Boolean(
|
|
94
|
+
bookmark && appProvider && appName === undefined && appNameError === null,
|
|
95
|
+
);
|
|
90
96
|
|
|
91
97
|
const updateBookmark = useCallback(
|
|
92
98
|
async (updates: BookmarkUpdate) => {
|
|
@@ -145,9 +151,12 @@ export const EditBookmarkModal = ({
|
|
|
145
151
|
/>
|
|
146
152
|
</div>
|
|
147
153
|
<div>
|
|
148
|
-
<Label htmlFor=
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
<Label htmlFor={appId} label="App" />
|
|
155
|
+
<AppNameField
|
|
156
|
+
id={appId}
|
|
157
|
+
displayName={appName?.displayName}
|
|
158
|
+
isLoading={isAppNameLoading}
|
|
159
|
+
/>
|
|
151
160
|
</div>
|
|
152
161
|
|
|
153
162
|
<Styled.CheckboxWrapper>
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '2.0.
|
|
2
|
+
export const version = '2.0.3';
|
package/tsconfig.json
CHANGED
package/vitest.config.ts
ADDED