Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CardView: Implement Toolbar #28693

Open
wants to merge 4 commits into
base: grids/cardview/main
Choose a base branch
from

Conversation

Alyar666
Copy link
Contributor

@Alyar666 Alyar666 commented Jan 9, 2025

No description provided.

@Alyar666 Alyar666 self-assigned this Jan 9, 2025
@Alyar666 Alyar666 requested a review from a team as a code owner January 9, 2025 16:31
Comment on lines +32 to +33
const propsToUpdate = { ...props };
delete propsToUpdate.items;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use more modern syntax with destructing

Suggested change
const propsToUpdate = { ...props };
delete propsToUpdate.items;
const {items, ...propsToUpdate} = props;

public addDefaultItem(
item: MaybeSubscribable<PredefinedToolbarItem>,
): void {
toSubscribable(item).subscribe((item) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unsubscribing for this subscription to removeDefaultItem method

'revertButton',
'editButton',
'columnsChooserButton',
'searchPanel',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor
Let's make this array empty for now. We'll add buttons later one-by-one when we'll implement corresponding module


describe('when visibleConfig = undefined and there are no items', () => {
it('should be equal to true', () => {
expect(isVisible(undefined, [{ name: 'toolbarItem1' }, { name: 'toolbarItem2' }])).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor
Let's format this line into multiline


export type PredefinedToolbarItem = ToolbarItem & { name: DefaultToolbarItem };
export type ToolbarItems = (ToolbarItem | DefaultToolbarItem)[];
export type ToolbarVisible = boolean | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's inline this type
It's hard to understand what it means until you open its definition

name?: string;
}

function normalizeToolbarItem(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This utilities work with toolbar, so they should be in toolbar folder

};

describe('render', () => {
it('empty toolbar', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's follow the pattern describe('some entity in code') -> describe('some case') -> it('should ...')
there's no entity "render" in code, so let's rewrite it as
describe("Toolbar") -> describe("when it is empty") -> describe("it should be rendered correctly")`
And if it possible, instead of "should be rendered correctly" let's use something more specific, like "should be rendered to empty div" or "should not be rendered"


describe('normalizeToolbarItems', () => {
describe('when only default items are specified', () => {
it('should return correct items', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's too much unspecific test names. It is not quite understandable what you mean by "should return correct items". It is okay to use it sometimes, but looks like here we can write something more specific

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants