Skip to content

Commit

Permalink
Remove global imports of lodash (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor committed Jun 19, 2019
1 parent 9b3e728 commit 15ed9e0
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 30 deletions.
6 changes: 3 additions & 3 deletions dashboard/src/actions/helpers/object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from "lodash";
import { isEmpty } from "lodash";

// Check if all the keys of an object are empty. If any value of the
// object is a nested object it recursively checks if the inner object
Expand All @@ -9,14 +9,14 @@ export function isEmptyDeep(obj: any): boolean {
// but we should not consider it empty
return false;
}
if (typeof obj === "object" && !_.isEmpty(obj)) {
if (typeof obj === "object" && !isEmpty(obj)) {
// Check if nested objects are empty
// If some of the keys are not empty the result is not empty
return !Object.keys(obj).some(k => {
return !isEmptyDeep(obj[k]);
});
}
return _.isEmpty(obj);
return isEmpty(obj);
}

// Remove empty keys from an object (recursively)
Expand Down
6 changes: 3 additions & 3 deletions dashboard/src/components/AppView/AppView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RouterAction } from "connected-react-router";
import * as yaml from "js-yaml";
import * as _ from "lodash";
import { assignWith, isEqual } from "lodash";
import * as React from "react";

import AccessURLTable from "../../containers/AccessURLTableContainer";
Expand Down Expand Up @@ -108,7 +108,7 @@ class AppView extends React.Component<IAppViewProps, IAppViewState> {
// Filter out elements in the manifest that does not comply
// with { kind: foo }
manifest = manifest.filter(r => r && r.kind);
if (!_.isEqual(manifest, this.state.manifest)) {
if (!isEqual(manifest, this.state.manifest)) {
this.setState({ manifest });
} else {
return;
Expand Down Expand Up @@ -236,7 +236,7 @@ class AppView extends React.Component<IAppViewProps, IAppViewState> {
// A List can contain an arbitrary set of resources so we treat them as an
// additional manifest. We merge the current result with the resources of
// the List, concatenating items from both.
_.assignWith(
assignWith(
result,
this.parseResources((i as IK8sList<IResource, {}>).items, releaseNamespace),
// Merge the list with the current result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash";
import * as React from "react";

import ResourceRef from "shared/ResourceRef";
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/components/AppView/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as _ from "lodash";
import { some } from "lodash";

import { IKubeItem } from "./../../../shared/types";

export default function isSomeResourceLoading(resources: Array<IKubeItem<any>>): boolean {
return _.some(resources, i => i.isFetching);
return some(resources, i => i.isFetching);
}
10 changes: 5 additions & 5 deletions dashboard/src/components/Catalog/CatalogItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallow } from "enzyme";
import context from "jest-plugin-context";
import * as _ from "lodash";
import { cloneDeep } from "lodash";
import * as React from "react";

import { IChart, IRepo } from "../../shared/types";
Expand Down Expand Up @@ -36,7 +36,7 @@ it("should render an item", () => {
});

it("should use the default placeholder for the icon if it doesn't exist", () => {
const chartWithoutIcon = _.cloneDeep(defaultChart);
const chartWithoutIcon = cloneDeep(defaultChart);
chartWithoutIcon.attributes.icon = undefined;
const wrapper = shallow(<CatalogItem chart={chartWithoutIcon} />);
// Importing an image returns "undefined"
Expand All @@ -50,7 +50,7 @@ it("should use the default placeholder for the icon if it doesn't exist", () =>
});

it("should place a dash if the version is not avaliable", () => {
const chartWithoutVersion = _.cloneDeep(defaultChart);
const chartWithoutVersion = cloneDeep(defaultChart);
chartWithoutVersion.relationships.latestChartVersion.data.app_version = "";
const wrapper = shallow(<CatalogItem chart={chartWithoutVersion} />);
expect(
Expand All @@ -63,7 +63,7 @@ it("should place a dash if the version is not avaliable", () => {
});

it("show the chart description", () => {
const chartWithDescription = _.cloneDeep(defaultChart);
const chartWithDescription = cloneDeep(defaultChart);
chartWithDescription.attributes.description = "This is a description";
const wrapper = shallow(<CatalogItem chart={chartWithDescription} />);
expect(
Expand All @@ -77,7 +77,7 @@ it("show the chart description", () => {

context("when the description is too long", () => {
it("trims the description", () => {
const chartWithDescription = _.cloneDeep(defaultChart);
const chartWithDescription = cloneDeep(defaultChart);
chartWithDescription.attributes.description =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ultrices velit leo, quis pharetra mi vestibulum quis.";
const wrapper = shallow(<CatalogItem chart={chartWithDescription} />);
Expand Down
11 changes: 5 additions & 6 deletions dashboard/src/components/ChartView/ChartVersionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ class ChartVersionsList extends React.Component<IChartVersionsListProps, IChartV
return (
<div className="ChartVersionsList">
<ul className="remove-style padding-l-reset margin-b-reset">{items}</ul>
{!this.state.showAll &&
this.props.versions.length > 5 && (
<a className="type-small" onClick={this.handleShowAll}>
Show all...
</a>
)}
{!this.state.showAll && this.props.versions.length > 5 && (
<a className="type-small" onClick={this.handleShowAll}>
Show all...
</a>
)}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as _ from "lodash";
import { lowerFirst } from "lodash";
import * as React from "react";

import { IClusterServiceClass } from "shared/ClusterServiceClass";
Expand Down Expand Up @@ -48,7 +48,7 @@ const ServiceInstanceCardList: React.SFC<IServiceInstanceCardListProps> = props
icon={icon}
serviceClassName={(svcClass && svcClass.spec.externalName) || "-"}
servicePlanName={instance.spec.clusterServicePlanExternalName}
statusReason={status && _.lowerFirst(status.reason)}
statusReason={status && lowerFirst(status.reason)}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash";
import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash";
import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash";
import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash";
import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as _ from "lodash";
import { connect } from "react-redux";
import { Action } from "redux";
import { ThunkDispatch } from "redux-thunk";
Expand Down
2 changes: 0 additions & 2 deletions dashboard/src/containers/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as _ from "lodash";

import ResourceRef from "../../shared/ResourceRef";
import { IKubeState } from "../../shared/types";

Expand Down
1 change: 0 additions & 1 deletion dashboard/src/reducers/kube.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LOCATION_CHANGE, LocationChangeAction } from "connected-react-router";
import * as _ from "lodash";

import { getType } from "typesafe-actions";
import actions from "../actions";
Expand Down

0 comments on commit 15ed9e0

Please sign in to comment.