Skip to content

Commit

Permalink
Merge main into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 14, 2023
2 parents d389e74 + ffbd960 commit 4912811
Show file tree
Hide file tree
Showing 38 changed files with 351 additions and 42 deletions.
9 changes: 9 additions & 0 deletions packages/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 7.1.13

### Patch Changes

- Updated dependencies [[`0af3540`](https://github.com/equinor/fusion-framework/commit/0af3540340bac85a19ca3a8ec4e0ccd42b3090ee)]:
- @equinor/fusion-framework-module-http@5.1.3
- @equinor/fusion-framework@7.0.26
- @equinor/fusion-framework-module-app@5.2.12

## 7.1.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-app",
"version": "7.1.12",
"version": "7.1.13",
"description": "",
"main": "dist/esm/index.js",
"exports": {
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 9.5.4

### Patch Changes

- Updated dependencies []:
- @equinor/fusion-framework-app@7.1.13
- @equinor/fusion-framework-react-components-people-provider@1.1.7

## 9.5.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-cli",
"version": "9.5.3",
"version": "9.5.4",
"keywords": [
"Fusion",
"Fusion Framework",
Expand Down
9 changes: 9 additions & 0 deletions packages/framework/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 7.0.26

### Patch Changes

- Updated dependencies [[`0af3540`](https://github.com/equinor/fusion-framework/commit/0af3540340bac85a19ca3a8ec4e0ccd42b3090ee)]:
- @equinor/fusion-framework-module-http@5.1.3
- @equinor/fusion-framework-module-service-discovery@7.0.16
- @equinor/fusion-framework-module-services@3.2.3

## 7.0.25

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework",
"version": "7.0.25",
"version": "7.0.26",
"description": "",
"main": "dist/esm/index.js",
"exports": {
Expand Down
24 changes: 24 additions & 0 deletions packages/modules/http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Change Log

## 5.1.3

### Patch Changes

- [#1621](https://github.com/equinor/fusion-framework/pull/1621) [`0af3540`](https://github.com/equinor/fusion-framework/commit/0af3540340bac85a19ca3a8ec4e0ccd42b3090ee) Thanks [@odinr](https://github.com/odinr)! - **Improves error handling when processing json http response**

In packages/modules/http/src/errors.ts:

- The class HttpResponseError now has a generic parameter TResponse.
- Added a static property Name to the class.
- Added a new class HttpJsonResponseError which extends HttpResponseError and also has generic parameters TType and TResponse.
- Added a static property Name to the class.
- Added a public property data of type TType.
- Modified the constructor to accept an optional data parameter.

In packages/modules/http/src/lib/selectors/json-selector.ts:

- Added an import statement for HttpJsonResponseError.
- Modified the jsonSelector function to handle errors when parsing the response.
- Added a try-catch block.
- Changed the JSON parsing logic to store the parsed data in a variable data.
- If the response is not OK, a HttpJsonResponseError is thrown with the appropriate error message, response object, and data property.
- If there is an error parsing the response, a HttpJsonResponseError is thrown with the appropriate error message, response object, and cause property.

## 5.1.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-module-http",
"version": "5.1.2",
"version": "5.1.3",
"description": "",
"main": "dist/esm/index.js",
"types": "index.d.ts",
Expand Down
29 changes: 26 additions & 3 deletions packages/modules/http/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
export class HttpResponseError extends Error {
/**
* Represents an error that occurs when handling an HTTP response.
* @template TResponse The type of the HTTP response.
*/
export class HttpResponseError<TResponse = Response> extends Error {
static Name = 'HttpResponseError';
constructor(
public message: string,
public response: Response,
message: string,
public readonly response: TResponse,
options?: ErrorOptions,
) {
super(message, options);
}
}

/**
* Represents an error that occurs when handling a JSON response in an HTTP request.
* @template TType - The type of the data contained in the response.
* @template TResponse - The type of the HTTP response.
*/
export class HttpJsonResponseError<
TType = unknown,
TResponse = Response,
> extends HttpResponseError<TResponse> {
static Name = 'HttpJsonResponseError';
public readonly data?: TType;
constructor(message: string, response: TResponse, options?: ErrorOptions & { data?: TType }) {
super(message, response, options);
this.name = HttpJsonResponseError.Name;
this.data = options?.data;
}
}
29 changes: 21 additions & 8 deletions packages/modules/http/src/lib/selectors/json-selector.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
export const jsonSelector = <TType = unknown, TResponse extends Response = Response>(
import { HttpJsonResponseError } from '../../errors';

/**
* Converts the JSON response from an HTTP request into the specified type.
* If the response is not OK or if there is an error parsing the response, an error is thrown.
* If the response has a status code of 204 (No Content), a resolved Promise is returned.
*
* @param response The HTTP response object.
* @returns A Promise that resolves to the parsed JSON data.
* @throws {Error} If the network response is not OK.
* @throws {HttpJsonResponseError} If there is an error parsing the response.
*/
export const jsonSelector = async <TType = unknown, TResponse extends Response = Response>(
response: TResponse,
): Promise<TType> => {
if (!response.ok) {
throw new Error('network response was not OK');
}
//Status code 204 is no content
/** Status code 204 is no content */
if (response.status === 204) {
return Promise.resolve() as Promise<TType>;
}

try {
return response.json();
} catch (err) {
throw Error('failed to parse response');
const data = await response.json();
if (!response.ok) {
throw new HttpJsonResponseError('network response was not OK', response, { data });
}
return data;
} catch (cause) {
throw new HttpJsonResponseError('failed to parse response', response, { cause });
}
};

Expand Down
7 changes: 7 additions & 0 deletions packages/modules/service-discovery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 7.0.16

### Patch Changes

- Updated dependencies [[`0af3540`](https://github.com/equinor/fusion-framework/commit/0af3540340bac85a19ca3a8ec4e0ccd42b3090ee)]:
- @equinor/fusion-framework-module-http@5.1.3

## 7.0.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/service-discovery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-module-service-discovery",
"version": "7.0.15",
"version": "7.0.16",
"description": "",
"main": "dist/esm/index.js",
"exports": {
Expand Down
7 changes: 7 additions & 0 deletions packages/modules/signalr/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 2.0.15

### Patch Changes

- Updated dependencies []:
- @equinor/fusion-framework-module-service-discovery@7.0.16

## 2.0.14

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/signalr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-module-signalr",
"version": "2.0.14",
"version": "2.0.15",
"description": "",
"sideEffects": false,
"main": "dist/esm/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/modules/widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 2.0.6

### Patch Changes

- Updated dependencies [[`0af3540`](https://github.com/equinor/fusion-framework/commit/0af3540340bac85a19ca3a8ec4e0ccd42b3090ee)]:
- @equinor/fusion-framework-module-http@5.1.3
- @equinor/fusion-framework-module-service-discovery@7.0.16

## 2.0.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-module-widget",
"version": "2.0.5",
"version": "2.0.6",
"description": "",
"main": "dist/esm/index.js",
"exports": {
Expand Down
10 changes: 10 additions & 0 deletions packages/react/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## 4.1.18

### Patch Changes

- Updated dependencies [[`cce198d`](https://github.com/equinor/fusion-framework/commit/cce198d6a91fb7912265d4383246dc405cf17a17), [`f85316f`](https://github.com/equinor/fusion-framework/commit/f85316f2344258896a77ef602bd4047dfa553788)]:
- @equinor/fusion-framework-react-module-http@4.0.3
- @equinor/fusion-framework-app@7.1.13
- @equinor/fusion-framework-module-app@5.2.12
- @equinor/fusion-framework-react@5.3.6

## 4.1.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-react-app",
"version": "4.1.17",
"version": "4.1.18",
"description": "",
"main": "dist/esm/index.js",
"exports": {
Expand Down
12 changes: 12 additions & 0 deletions packages/react/components/bookmark/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change Log

## 0.3.0

### Minor Changes

- [#1615](https://github.com/equinor/fusion-framework/pull/1615) [`750a7f5`](https://github.com/equinor/fusion-framework/commit/750a7f5f96104e33d4a436ff858044516e269c68) Thanks [@Noggling](https://github.com/Noggling)! - Implement a "No Content" message and relocate the "Loading" indicator to the bookmarks component. Additionally, incorporate an effect to handle cases where the "onBookmarksChanged" event is not triggered.

### Patch Changes

- Updated dependencies []:
- @equinor/fusion-framework-react@5.3.6
- @equinor/fusion-framework-react-module-bookmark@2.0.25

## 0.2.14

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/components/bookmark/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/fusion-framework-react-components-bookmark",
"version": "0.2.14",
"version": "0.3.0",
"description": "",
"main": "dist/esm/index.js",
"exports": {
Expand Down
39 changes: 37 additions & 2 deletions packages/react/components/bookmark/src/components/Bookmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { useBookmark } from '@equinor/fusion-framework-react-module-bookmark';
import { useBookmarkGrouping } from '../hooks';
import { BookmarkFilter } from './filter/Filter';
import { SectionList } from './sectionList/SectionList';
import { useEffect } from 'react';
import { useEffect, useState } from 'react';

import { Icon } from '@equinor/eds-core-react';
import { chevron_down, chevron_right, share, more_vertical, add } from '@equinor/eds-icons';

import styled from 'styled-components';
import { Message } from './messages/Message';
import { Loading } from './loading/Loading';
import { useFramework } from '@equinor/fusion-framework-react';

Icon.add({
chevron_down,
Expand All @@ -29,10 +32,32 @@ const Styled = {
overflow-x: hidden;
height: calc((100vh - 85px) - 3rem);
`,
NoContentWrapper: styled.div`
position: absolute;
top: 150px;
bottom: 200px;
left: 0px;
right: 0px;
`,
};

export const Bookmark = () => {
const { bookmarks, getAllBookmarks } = useBookmark();
const [loading, setLoading] = useState(true);

const { event } = useFramework().modules;

useEffect(() => {
return event.addEventListener('onBookmarksChanged', () => {
setLoading(false);
});
}, [event]);

useEffect(() => {
if (bookmarks.length > 0) {
setLoading(false);
}
}, [bookmarks]);

useEffect(() => {
getAllBookmarks();
Expand All @@ -51,7 +76,17 @@ export const Bookmark = () => {
setSearchText={setSearchText}
/>
<Styled.List>
<SectionList bookmarkGroups={bookmarkGroups} />
{bookmarkGroups.length > 0 ? (
<SectionList bookmarkGroups={bookmarkGroups} />
) : loading ? (
<Loading />
) : (
<Styled.NoContentWrapper>
<Message title="No Bookmarks" type="NoContent">
You have not created any bookmarks yet.
</Message>
</Styled.NoContentWrapper>
)}
</Styled.List>
</Styled.Wrapper>
);
Expand Down
Loading

0 comments on commit 4912811

Please sign in to comment.