Skip to content

Commit

Permalink
Merge branch 'master' into jmfrancois/chore/ds-no-reakit
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois authored Jul 3, 2023
2 parents 2cf2321 + 04167fe commit 1f2260a
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 23 deletions.
6 changes: 0 additions & 6 deletions .changeset/fluffy-horses-poke.md

This file was deleted.

17 changes: 17 additions & 0 deletions .changeset/good-radios-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@talend/http': minor
---

feat(http): add the possibility to add global interceptors for every calls that got through @talend/http calls

Usage:

```typescript
import { addHttpResponseInterceptor, HTTP_STATUS } from '@talend/http';

addHttpResponseInterceptor('logout', (response: Response): void => {
if (response.status === HTTP_STATUS.UNAUTHORIZED) {
logout();
}
});
```
5 changes: 5 additions & 0 deletions .changeset/grumpy-cars-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/react-faceted-search': patch
---

fix(TDC-6575): badge size overlap with "Add Filter" button with some long values
5 changes: 5 additions & 0 deletions .changeset/tidy-suits-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/react-faceted-search': patch
---

fix(faceted-search): data-feature typo
6 changes: 6 additions & 0 deletions packages/design-system/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @talend/design-system

## 7.11.0

### Minor Changes

- d8c9adc34: [DS] InlineEditing : allow to update value from default value prop

## 7.10.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@talend/design-system",
"version": "7.10.0",
"version": "7.11.0",
"description": "Talend Design System",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// stylelint-disable scss/selector-no-redundant-nesting-selector
.tc-badge-faceted {
padding: tokens.$coral-spacing-xxs tokens.$coral-spacing-xs;
max-width: tokens.$coral-sizing-maximal;
max-width: fit-content;

:global(.tc-badge-button) {
max-width: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const SwitchFacetedMode = ({ facetedMode, onChange, t }) => (
onChange={() =>
onChange(facetedMode === FACETED_MODE.BASIC ? FACETED_MODE.ADVANCED : FACETED_MODE.BASIC)
}
dataFeature={
data-feature={
facetedMode === FACETED_MODE.BASIC
? USAGE_TRACKING_TAGS.BASIC
: USAGE_TRACKING_TAGS.ADVANCED
Expand Down
10 changes: 10 additions & 0 deletions packages/faceted-search/stories/facetedSearch.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ const badgesFaceted = {
label: 'Amazon S3',
checked: true,
},
{
id: 'hdfs',
label: 'HDFS',
checked: true,
},
{
id: 'localcon',
label: 'Local connection',
checked: true,
},
],
},
metadata: {
Expand Down
6 changes: 6 additions & 0 deletions packages/flow-designer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 5.5.0

### Minor Changes

- 95670ed73: Lighten grid background

## 5.4.0

### Minor Changes
Expand Down
3 changes: 2 additions & 1 deletion packages/flow-designer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@talend/react-flow-designer",
"description": "Flow designer for react and redux",
"version": "5.4.0",
"version": "5.5.0",
"types": "lib/index.d.ts",
"main": "lib/index.js",
"mainSrc": "src/index.js",
Expand Down Expand Up @@ -54,6 +54,7 @@
"reselect": "^4.1.8"
},
"dependencies": {
"@talend/design-tokens": "^2.7.3",
"classnames": "^2.3.2",
"d3": "^7.8.5",
"invariant": "^2.2.4",
Expand Down
19 changes: 15 additions & 4 deletions packages/flow-designer/src/components/grid/Grid.component.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
import PropTypes from 'prop-types';
import get from 'lodash/get';

import tokens from '@talend/design-tokens';

import { GRID_SIZE } from '../../constants/flowdesigner.constants';
import { Transform } from '../../customTypings/index.d';

const size = (4 * 5) / 3;
const halfSize = size / 2;

function Grid({ transformData }: { transformData?: Transform }) {
const largeGridSize = GRID_SIZE * get(transformData, 'k', 1);
const scale = get(transformData, 'k', 1);
const largeGridSize = GRID_SIZE * scale;
const halfCrossSize = halfSize * scale;
const deltaSize = largeGridSize - halfCrossSize;

return (
<g>
<defs>
<pattern
id="grid"
fill="none"
stroke="#BFBDBD"
stroke={tokens.coralColorNeutralBorder}
strokeWidth="0.5"
x={get(transformData, 'x')}
y={get(transformData, 'y')}
width={largeGridSize}
height={largeGridSize}
patternUnits="userSpaceOnUse"
>
<rect width={largeGridSize} height={largeGridSize} />
<path d={`M ${largeGridSize} 0 L 0 0 0 ${largeGridSize}`} />
<path d={`M 0 0 V ${halfCrossSize}`} />
<path d={`M 0 0 H ${halfCrossSize}`} />
<line x1="0" y1={largeGridSize} x2="0" y2={deltaSize} />
<line x1={largeGridSize} y1="0" x2={deltaSize} y2="0" />
</pattern>
</defs>
<rect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ exports[`Grid.component should render a grid by default 1`] = `
height={40}
id="grid"
patternUnits="userSpaceOnUse"
stroke="#BFBDBD"
stroke="var(--coral-color-neutral-border, hsla(0, 0%, 55%, 1))"
strokeWidth="0.5"
width={40}
x={0}
y={0}
>
<rect
height={40}
width={40}
<path
d="M 0 0 V 3.3333333333333335"
/>
<path
d="M 40 0 L 0 0 0 40"
d="M 0 0 H 3.3333333333333335"
/>
<line
x1="0"
x2="0"
y1={40}
y2={36.666666666666664}
/>
<line
x1={40}
x2={36.666666666666664}
y1="0"
y2="0"
/>
</pattern>
</defs>
Expand Down
57 changes: 56 additions & 1 deletion packages/http/src/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { HTTP, getDefaultConfig, setDefaultConfig, setDefaultLanguage } from './config';
import {
HTTP,
HTTP_RESPONSE_INTERCEPTORS,
addHttpResponseInterceptor,
getDefaultConfig,
removeHttpResponseInterceptor,
setDefaultConfig,
setDefaultLanguage,
} from './config';

describe('Configuration service', () => {
describe('setDefaultLanguage', () => {
Expand Down Expand Up @@ -39,4 +47,51 @@ describe('Configuration service', () => {
);
});
});

describe('Http interceptors', () => {
beforeEach(() => {
for (const key in HTTP_RESPONSE_INTERCEPTORS) {
if (HTTP_RESPONSE_INTERCEPTORS.hasOwnProperty(key)) {
delete HTTP_RESPONSE_INTERCEPTORS[key];
}
}
});

it('should add a new interceptor when the name is not already used', () => {
const interceptor = jest.fn();
addHttpResponseInterceptor('myInterceptor', interceptor);
expect(HTTP_RESPONSE_INTERCEPTORS).toEqual({
myInterceptor: interceptor,
});
});

it('should throw an error when the name is already used', () => {
const interceptor1 = jest.fn();
const interceptor2 = jest.fn();
addHttpResponseInterceptor('myInterceptor', interceptor1);
expect(() => addHttpResponseInterceptor('myInterceptor', interceptor2)).toThrowError(
'Interceptor myInterceptor already exists',
);
expect(HTTP_RESPONSE_INTERCEPTORS).toEqual({
myInterceptor: interceptor1,
});
});

it('should remove an existing interceptor', () => {
const interceptor1 = jest.fn();
addHttpResponseInterceptor('myInterceptor', interceptor1);

removeHttpResponseInterceptor('myInterceptor');
expect(HTTP_RESPONSE_INTERCEPTORS).toEqual({});
});

it('should throw an error when the interceptor does not exist', () => {
const interceptor2 = jest.fn();
addHttpResponseInterceptor('myInterceptor2', interceptor2);
expect(() => removeHttpResponseInterceptor('myInterceptor')).toThrowError(
'Interceptor myInterceptor does not exist',
);
expect(HTTP_RESPONSE_INTERCEPTORS).toEqual({ myInterceptor2: interceptor2 });
});
});
});
19 changes: 19 additions & 0 deletions packages/http/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ export const HTTP: { defaultConfig?: TalendRequestInit | null } = {
defaultConfig: null,
};

export const HTTP_RESPONSE_INTERCEPTORS: Record<string, (response: Response) => void> = {};

export function addHttpResponseInterceptor(
name: string,
interceptor: (response: Response) => void,
) {
if (HTTP_RESPONSE_INTERCEPTORS[name]) {
throw new Error(`Interceptor ${name} already exists`);
}
HTTP_RESPONSE_INTERCEPTORS[name] = interceptor;
}

export function removeHttpResponseInterceptor(name: string) {
if (!HTTP_RESPONSE_INTERCEPTORS[name]) {
throw new Error(`Interceptor ${name} does not exist`);
}
delete HTTP_RESPONSE_INTERCEPTORS[name];
}

/**
* setDefaultHeader - define a default config to use with the saga http
* this default config is stored in this module for the whole application
Expand Down
7 changes: 6 additions & 1 deletion packages/http/src/http.common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HTTP } from './config';
import { HTTP, HTTP_RESPONSE_INTERCEPTORS } from './config';
import { mergeCSRFToken } from './csrfHandling';
import { HTTP_STATUS, testHTTPCode } from './http.constants';
import { TalendHttpResponse, TalendRequestInit } from './http.types';
Expand Down Expand Up @@ -125,5 +125,10 @@ export async function httpFetch<T>(
body: encodePayload(params.headers || {}, payload),
}),
);

Object.values(HTTP_RESPONSE_INTERCEPTORS).forEach(interceptor => {
interceptor(response);
});

return handleHttpResponse(response);
}
8 changes: 8 additions & 0 deletions packages/http/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ export { http } from './async';

export * from './http.types';
export * from './http.constants';

export {
addHttpResponseInterceptor,
removeHttpResponseInterceptor,
getDefaultConfig,
setDefaultConfig,
setDefaultLanguage,
} from './config';
11 changes: 11 additions & 0 deletions packages/storybook/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @talend/ui-storybook

## 1.2.0

### Minor Changes

- d8c9adc34: [DS] InlineEditing : allow to update value from default value prop

### Patch Changes

- Updated dependencies [d8c9adc34]
- @talend/design-system@7.11.0

## 1.1.3

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@talend/ui-storybook",
"version": "1.1.3",
"version": "1.2.0",
"description": "Package containing all stories from talend/ui repository",
"homepage": "https://github.com/Talend/ui#readme",
"main": "src/index.ts",
Expand All @@ -20,7 +20,7 @@
"url": "https://github.com/Talend/ui/issues"
},
"dependencies": {
"@talend/design-system": "^7.10.0",
"@talend/design-system": "^7.11.0",
"@talend/design-tokens": "^2.7.3",
"react-hook-form": "^6.15.8"
},
Expand Down

0 comments on commit 1f2260a

Please sign in to comment.