-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable custom configuration settings for the data table manager (#2851)
* feat(data table manager): enable custom configuration settings for data table manager * feat(data table manager): remove unused files * feat(data table manager): include test for custom component * feat(data table manager): fix type issue * feat(data table manager): update changeset * feat(data table manager): update story * feat(data table manager): update data table with custom props * feat(data table manager): define data table payload data shape * feat(data table manager): option to change default settings dropdown label * feat(data table manager): expose column settings manager component * feat(data table manager): remove unused console logs * feat(data table manager): refactor columns update * feat(data table manager): restructure payload schema * feat(data table manager): update test * feat(data table manager): remove comments * feat(data table manager): fix searchable bug * feat(data table manager): add description to property definitions * feat(data table manager): add description to property definitions * feat(data table manager): prop description * feat(data table manager): update title type * feat(data table manager): change check for custom column manager * feat(data table manager): visual storybook changes for the custom settings * feat(data table manager): visual storybook changes for the custom settings * feat(data table manager): update reame docs with new prop changes * feat(data table manager): update reame docs to include column manager label override * feat(data table manager): update reame docs * feat(data table manager): update docs * feat(data table manager): update types * feat(data table manager): initiate simple poc for the nested table onclick * feat(data table manager): initiate simple poc for the nested table onclick --------- Co-authored-by: Ddouglasz <[email protected]>
- Loading branch information
Showing
25 changed files
with
1,321 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@commercetools-uikit/data-table-manager': minor | ||
'@commercetools-uikit/data-table': minor | ||
--- | ||
|
||
This extends the data table manager settings to make provision for additional settings that can allow users add more configurations to the already existing settings of the data table manager. | ||
With the new approach, a user can now add any desired configuration option to the settings dropdown, and also create their own settings interface (a custom settings component) to configure the data table to their desired settings. |
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
packages/components/data-table-manager/column-settings-manager/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"main": "dist/commercetools-uikit-data-table-manager-column-settings-manager.cjs.js", | ||
"module": "dist/commercetools-uikit-data-table-manager-column-settings-manager.esm.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/components/data-table-manager/src/column-settings-manager/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default } from './column-settings-manager'; | ||
export { ColumnSettingsManager } from './column-settings-manager'; | ||
export * from './export-types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...components/data-table-manager/src/custom-settings-manager/custom-settings-manager.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { screen, render, fireEvent } from '../../../../../test/test-utils'; | ||
import CustomSettingsManager from './custom-settings-manager'; | ||
|
||
const mockCustomComponentClick = jest.fn(); | ||
|
||
const CustomComponent = (prop) => ( | ||
<button onClick={prop.onClick}>Custom Component</button> | ||
); | ||
|
||
const createTestProps = (customProps) => ({ | ||
managerTheme: 'light', | ||
children: <CustomComponent onClick={mockCustomComponentClick} />, | ||
customPanelTitle: 'Test Title', | ||
onClose: jest.fn(), | ||
...customProps, | ||
}); | ||
|
||
describe('CustomSettingsManager', () => { | ||
it('renders with the correct title', () => { | ||
const props = createTestProps(); | ||
render(<CustomSettingsManager {...props} />); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); | ||
}); | ||
it('renders with the correct children', () => { | ||
const props = createTestProps(); | ||
render(<CustomSettingsManager {...props} />); | ||
|
||
const customButton = screen.getByText('Custom Component'); | ||
expect(customButton).toBeInTheDocument(); | ||
|
||
fireEvent.click(customButton); | ||
expect(mockCustomComponentClick).toHaveBeenCalled(); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
...ges/components/data-table-manager/src/custom-settings-manager/custom-settings-manager.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { MouseEvent, KeyboardEvent, ReactNode } from 'react'; | ||
import SettingsContainer, { type TIntlMessage } from '../settings-container'; | ||
import messages from './messages'; | ||
|
||
export type TCustomSettingsManagerProps = { | ||
onClose: ( | ||
event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement> | ||
) => void; | ||
managerTheme?: 'light' | 'dark'; | ||
children: ReactNode; | ||
customPanelTitle: string | TIntlMessage; | ||
}; | ||
|
||
const CustomSettingsManager = (props: TCustomSettingsManagerProps) => { | ||
return ( | ||
<> | ||
<SettingsContainer | ||
customSettingsTitle={props.customPanelTitle} | ||
closeButtonLabel={messages.closeButtonLabel} | ||
onClose={props.onClose} | ||
containerTheme={props.managerTheme} | ||
> | ||
{props.children} | ||
</SettingsContainer> | ||
</> | ||
); | ||
}; | ||
|
||
CustomSettingsManager.displayName = 'CustomSettingsManager'; | ||
|
||
export default CustomSettingsManager; |
3 changes: 3 additions & 0 deletions
3
packages/components/data-table-manager/src/custom-settings-manager/export-types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { TCustomSettingsManagerProps as CustomSettingsManagerProps } from './custom-settings-manager'; | ||
|
||
export type TCustomSettingsManagerProps = CustomSettingsManagerProps; |
2 changes: 2 additions & 0 deletions
2
packages/components/data-table-manager/src/custom-settings-manager/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './custom-settings-manager'; | ||
export * from './export-types'; |
9 changes: 9 additions & 0 deletions
9
packages/components/data-table-manager/src/custom-settings-manager/messages.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineMessages } from 'react-intl'; | ||
|
||
export default defineMessages({ | ||
closeButtonLabel: { | ||
id: 'UIKit.DataTableManager.CustomSettingsManager.closeButtonLabel', | ||
description: 'Label for custom settings manager close button.', | ||
defaultMessage: 'Close', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.