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

fix(react-grid): clear expanded groups after ungrouping #202

Merged

Conversation

SergeyAlexeev
Copy link
Contributor

No description provided.

kvet
kvet previously requested changes Jul 13, 2017
Copy link
Contributor

@kvet kvet left a comment

Choose a reason for hiding this comment

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

Too many questions about implementation. Please, rewrite ambiguous things with simplicity in mind.

@@ -65,6 +80,27 @@ export class GroupingState extends React.PureComponent {
grouping,
]}
/>
<Watcher
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you use Watcher to track changes in local Plugin context? It seems like overkill.

describe('GroupingState', () => {
let resetConsole;
beforeAll(() => {
resetConsole = setupConsole({ ignore: ['validateDOMNesting'] });
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure that ignoring 'validateDOMNesting' is needed here?

@@ -72,3 +74,37 @@ export const nextExpandedGroups = (prevExpandedGroups, groupKey) => {

return expandedGroups;
};

const ungroupedColumnIndex = (prevGrouping, nextGrouping) => {
if (prevGrouping.length > nextGrouping.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you not use "guard if" here? It makes function much easier to read.


export const expandedGroupsWithChangedGrouping = (prevGrouping, nextGrouping, expandedGroups) => {
const index = ungroupedColumnIndex(prevGrouping, nextGrouping);
if (index !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The same about "guard if".

.join(SEPARATOR),
);

result = new Set(result);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a bad practice to reassign a variable with a differed value type.


const ungroupedColumnIndex = (prevGrouping, nextGrouping) => {
if (prevGrouping.length > nextGrouping.length) {
for (let i = 0; i < prevGrouping.length; i += 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A complexity of this algorithm is too big. Feels like this function can be written with O(n) complexity.

return null;
};

export const expandedGroupsWithChangedGrouping = (prevGrouping, nextGrouping, expandedGroups) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of the function does not describe the result.


export const expandedGroupsDependOnGrouping = (prevGrouping, nextGrouping, expandedGroups) => {
const index = ungroupedColumnIndex(prevGrouping, nextGrouping);
if (index === null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

-1 is commonly used if an index is not found.

return result;
};

const uniqueArrayWithoutEmptyStrings = (array) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

array.filter(s => s) seems to be simplier and can be inlined

return Array.from(tmpSet);
};

export const expandedGroupsDependOnGrouping = (prevGrouping, nextGrouping, expandedGroups) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider renaming this.

@kvet kvet dismissed their stale review July 17, 2017 08:15

I committed to this PR

@kvet kvet merged commit d97809e into DevExpress:master Jul 17, 2017
@kvet kvet deleted the clear-expanded-groups-after-ungrouping branch July 17, 2017 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants