Skip to content

Commit

Permalink
Merge branch 'next' into 963-addon-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsperrine committed Jun 28, 2021
2 parents 34a648a + 31ebeb9 commit 0778f98
Show file tree
Hide file tree
Showing 23 changed files with 642 additions and 201 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.146.0-next.37](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.146.0-next.36...v2.146.0-next.37) (2021-06-25)


### Bug Fixes

* **table:** bring toggleAggregations into alignment with other actions ([3870e0b](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/3870e0ba2c56b12367ea622b718cdf1af80a513e))
* **table:** move onToggleAggregations into toolbar and fix proptypes ([b14007a](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/b14007a0a96e06888a57f6f27792214522566369))
* **table:** revert onToggleAggregations change ([6a2f986](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/6a2f98679fbf33624810ff86e304a3ca1ea95300))
* **table:** try not passing event to toggle action ([38a5ce1](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/38a5ce1b0f8bc5ef10c542b0f60e88498fa86eaf))
* **table:** try not passing event to toggle action ([aefabda](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/aefabda022ecb3e141daf69ffca6e052c517e333))
* **table:** useEffect to keep backwards compatibility in aggregations ([444bf66](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/444bf661078519f69cdf63b762bbbdcfccc66cb9))





# [2.146.0-next.36](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.146.0-next.35...v2.146.0-next.36) (2021-06-23)


### Bug Fixes

* **dashboard-grid:** grid should generate layouts for all supported breakpoints for each card ([49d392b](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/49d392b51bb1a201702ed0724a45f68562b77664))





# [2.146.0-next.35](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.146.0-next.33...v2.146.0-next.35) (2021-06-23)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"packages/*"
],
"useWorkspaces": true,
"version": "2.146.0-next.35",
"version": "2.146.0-next.37",
"npmClient": "yarn"
}
27 changes: 27 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.146.0-next.37](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.146.0-next.36...v2.146.0-next.37) (2021-06-25)


### Bug Fixes

* **table:** bring toggleAggregations into alignment with other actions ([3870e0b](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/3870e0ba2c56b12367ea622b718cdf1af80a513e))
* **table:** move onToggleAggregations into toolbar and fix proptypes ([b14007a](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/b14007a0a96e06888a57f6f27792214522566369))
* **table:** revert onToggleAggregations change ([6a2f986](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/6a2f98679fbf33624810ff86e304a3ca1ea95300))
* **table:** try not passing event to toggle action ([38a5ce1](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/38a5ce1b0f8bc5ef10c542b0f60e88498fa86eaf))
* **table:** try not passing event to toggle action ([aefabda](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/aefabda022ecb3e141daf69ffca6e052c517e333))
* **table:** useEffect to keep backwards compatibility in aggregations ([444bf66](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/444bf661078519f69cdf63b762bbbdcfccc66cb9))





# [2.146.0-next.36](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.146.0-next.35...v2.146.0-next.36) (2021-06-23)


### Bug Fixes

* **dashboard-grid:** grid should generate layouts for all supported breakpoints for each card ([49d392b](https://github.com/carbon-design-system/carbon-addons-iot-react/commit/49d392b51bb1a201702ed0724a45f68562b77664))





# [2.146.0-next.35](https://github.com/carbon-design-system/carbon-addons-iot-react/compare/v2.146.0-next.33...v2.146.0-next.35) (2021-06-23)


Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
"whatwg-fetch": "^3.0.0"
},
"sideEffects": false,
"version": "2.146.0-next.35",
"version": "2.146.0-next.37",
"resolutions": {
"chokidar": "3.3.1",
"react-grid-layout": "1.2.2"
Expand Down
30 changes: 15 additions & 15 deletions packages/react/src/components/Dashboard/DashboardGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,35 +127,35 @@ export const getBreakPointSizes = (breakpoint, cardDimensions, cardSizes) => {

/**
* This function finds an existing layout for each dashboard breakpoint, validates it, and or generates a new one to return
* @param {Object} layouts an keyed object of each layout for each breakpoint
* @param {Object} layouts a keyed object of each layout for each breakpoint
* @param {Array<Object>} cards an array of the card props for each card
* @param {Array<string>} supportedLayouts
*/
export const findLayoutOrGenerate = (layouts, cards, supportedLayouts) => {
// iterate through each breakpoint
return supportedLayouts.reduce((acc, layoutName) => {
let layout = layouts && layouts[layoutName];
if (layout) {
// if we're using an existing layout, we need to add CARD_DIMENSIONS because they are not stored in our JSON document
layout = layout.reduce((updatedLayout, cardFromLayout) => {
const matchingCard = find(cards, { id: cardFromLayout.i });
if (matchingCard)
updatedLayout.push({
...cardFromLayout,
...CARD_DIMENSIONS[matchingCard.size][layoutName],
});
return updatedLayout;
}, []);
// If layouts exists and there is one for each card
if (layout && layout.length === cards.length) {
// We need to set the width and height based on the card.size using CARD_DIMENSIONS
layout = layout.map((cardLayout) => {
const matchingCard = find(cards, { id: cardLayout.i });
return {
...cardLayout,
...(matchingCard ? { ...CARD_DIMENSIONS[matchingCard.size][layoutName] } : {}),
};
});
} else {
// generate the layout if we're not passed from the parent
layout = getLayout(layoutName, cards, DASHBOARD_COLUMNS, CARD_DIMENSIONS);
// generate the layout if we're not passed one from the parent or if the layouts are missing for any breakpoints
layout = getLayout(layoutName, cards, DASHBOARD_COLUMNS, CARD_DIMENSIONS, layout);
}

// Add the resizable flag
const layoutWithResizableItems = layout.map((cardFromLayout) => {
const matchingCard = find(cards, { id: cardFromLayout.i });
return {
...cardFromLayout,
isResizable: matchingCard.isResizable,
isResizable: matchingCard?.isResizable,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ describe('DashboardGrid', () => {
[{ id: 'mycard', size: CARD_SIZES.MEDIUM }],
['xl', 'lg', 'md']
);
// will be generated automatically with coordinates after first render
// should generate layouts for each existing card for each supported layout
expect(regenerated).toEqual({
xl: [],
lg: [],
md: [],
xl: [{ h: 2, i: 'mycard', isResizable: undefined, w: 8, x: 0, y: 0 }],
lg: [{ h: 2, i: 'mycard', isResizable: undefined, w: 8, x: 0, y: 0 }],
md: [{ h: 2, i: 'mycard', isResizable: undefined, w: 8, x: 0, y: 0 }],
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,10 @@ const DashboardEditor = ({
if (onLayoutChange) {
onLayoutChange(newLayout, newLayouts);
}
setDashboardJson({
...dashboardJson,
setDashboardJson((oldDashboard) => ({
...oldDashboard,
layouts: newLayouts,
});
}));
}}
onResizeStop={handleCardResize}
supportedLayouts={['lg', 'md', 'sm']}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const WithInitialValue = () => (
{
id: 'Timeseries',
title: 'Timeseries',
size: 'MEDIUMWIDE',
size: 'MEDIUM',
type: 'TIMESERIES',
content: {
series: [
Expand Down Expand Up @@ -324,58 +324,61 @@ export const WithInitialValue = () => (
],
layouts: {
lg: [
{ h: 4, i: 'Table', w: 8, x: 0, y: 0 },
{ h: 2, i: 'Custom', w: 4, x: 8, y: 0 },
{ i: 'Table', x: 0, y: 0 },
{ i: 'Custom', x: 8, y: 0 },
{
h: 2,
i: 'Standard',
w: 4,
x: 12,
y: 0,
},
{
h: 2,
i: 'Timeseries',
w: 8,
x: 1,
y: 4,
},
{
i: 'Bar',
x: 1,
y: 8,
},
],
md: [
{ h: 4, i: 'Table', w: 8, x: 0, y: 0 },
{ h: 2, i: 'Custom', w: 4, x: 8, y: 0 },
{ i: 'Table', x: 0, y: 0 },
{ i: 'Custom', x: 0, y: 4 },
{
h: 2,
i: 'Standard',
w: 4,
x: 12,
y: 0,
x: 0,
y: 6,
},
{
h: 2,
i: 'Timeseries',
w: 8,
x: 1,
y: 4,
x: 0,
y: 8,
},
{
i: 'Bar',
x: 0,
y: 10,
},
],
xl: [
{ h: 4, i: 'Table', w: 8, x: 0, y: 0 },
{ h: 2, i: 'Custom', w: 4, x: 8, y: 0 },
sm: [
{ i: 'Table', x: 0, y: 0 },
{ i: 'Custom', x: 4, y: 0 },
{
h: 2,
i: 'Standard',
w: 4,
x: 12,
y: 0,
x: 4,
y: 2,
},
{
h: 2,
i: 'Timeseries',
w: 8,
x: 1,
y: 4,
},
{
i: 'Bar',
x: 1,
y: 6,
},
],
},
}}
Expand Down Expand Up @@ -477,7 +480,7 @@ export const SummaryDashboardWithInitialValue = () => (
{
id: 'Timeseries',
title: 'Timeseries',
size: 'MEDIUMWIDE',
size: 'MEDIUM',
type: 'TIMESERIES',
content: {
series: [
Expand Down Expand Up @@ -530,56 +533,59 @@ export const SummaryDashboardWithInitialValue = () => (
],
layouts: {
lg: [
{ h: 4, i: 'Table', w: 8, x: 0, y: 0 },
{ h: 2, i: 'Custom', w: 4, x: 8, y: 0 },
{ i: 'Table', x: 0, y: 0 },
{ i: 'Custom', x: 8, y: 0 },
{
h: 2,
i: 'Standard',
w: 4,
x: 12,
y: 0,
x: 8,
y: 2,
},
{
h: 2,
i: 'Timeseries',
w: 8,
x: 1,
x: 0,
y: 4,
},
{
i: 'Bar',
x: 0,
y: 6,
},
],
md: [
{ h: 4, i: 'Table', w: 8, x: 0, y: 0 },
{ h: 2, i: 'Custom', w: 4, x: 8, y: 0 },
{ i: 'Table', x: 0, y: 0 },
{ i: 'Custom', x: 0, y: 4 },
{
h: 2,
i: 'Standard',
w: 4,
x: 12,
y: 0,
x: 0,
y: 6,
},
{
h: 2,
i: 'Timeseries',
w: 8,
x: 1,
y: 4,
x: 0,
y: 8,
},
{
i: 'Bar',
x: 0,
y: 10,
},
],
xl: [
{ h: 4, i: 'Table', w: 8, x: 0, y: 0 },
{ h: 2, i: 'Custom', w: 4, x: 8, y: 0 },
sm: [
{ i: 'Table', x: 0, y: 0 },
{ i: 'Custom', x: 4, y: 0 },
{
h: 2,
i: 'Standard',
w: 4,
x: 12,
y: 0,
x: 4,
y: 2,
},
{
h: 2,
i: 'Timeseries',
w: 8,
x: 1,
x: 0,
y: 4,
},
{
i: 'Bar',
x: 4,
y: 4,
},
],
Expand Down
Loading

0 comments on commit 0778f98

Please sign in to comment.