From 14f79711ef97d960b3bdf74ca577c8371c5f18b3 Mon Sep 17 00:00:00 2001 From: manisha Date: May 24 2021 08:39:10 +0000 Subject: removed lodash and added uniqueID fn removed existing lodash usage --- diff --git a/package.json b/package.json index 20d0779..9af4daa 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "dependencies": { "bootstrap": "^4.4.1", "dateformat": "^3.0.3", + "nanoid": "^3.1.22", + "ramda": "^0.27.1", "react": "^16.5.2", "react-dom": "^16.5.2", "react-redux": "^7.2.1", diff --git a/src/helpers/uniqueID.js b/src/helpers/uniqueID.js new file mode 100644 index 0000000..d168497 --- /dev/null +++ b/src/helpers/uniqueID.js @@ -0,0 +1,7 @@ +import { nanoid } from 'nanoid'; + +const uniqueID = (string) => { + return string + nanoid(); +} + +export default uniqueID; \ No newline at end of file diff --git a/src/landingpage/Hideable.js b/src/landingpage/Hideable.js index aac075a..9295373 100644 --- a/src/landingpage/Hideable.js +++ b/src/landingpage/Hideable.js @@ -1,10 +1,10 @@ import React, { Component } from "react" -import _ from "lodash" +import uniqueID from "../helpers/uniqueID" class Hideable extends Component { constructor(props) { super(props) - this.id = _.uniqueId("hideable-id-") + this.id = uniqueID("hideable-id-") } render() { diff --git a/src/landingpage/LandingPage.js b/src/landingpage/LandingPage.js index b1bee82..5ae38fe 100644 --- a/src/landingpage/LandingPage.js +++ b/src/landingpage/LandingPage.js @@ -7,9 +7,7 @@ import Events from "./Events" import Blockers from "./Blockers" import Minutes from "./Minutes" import Hideable from "./Hideable" - -import _ from "lodash" - +import * as R from 'ramda' import { connect } from "react-redux" import { loadData } from "../actions/reduxActions" @@ -70,9 +68,9 @@ class LandingPage extends Component { blockers: , minutes: , } - let components = _.chunk( - this.state.config_mode ? this.available_components : this.state.enabled_components, - 2 + let components = R.splitEvery( + 2, + this.state.config_mode ? this.available_components : this.state.enabled_components ) components = components.map((row) => ( @@ -86,6 +84,7 @@ class LandingPage extends Component { {available_components[item]} + ))} )) diff --git a/src/wizard/Actions.js b/src/wizard/Actions.js index e951154..fe9864b 100644 --- a/src/wizard/Actions.js +++ b/src/wizard/Actions.js @@ -3,39 +3,33 @@ import React, { Component } from "react" import Easyfix from "./Easyfix" import FedoraManualTesting from "./FedoraManualTesting" import FedoraEasyKarma from "./FedoraEasyKarma" - -import _ from "lodash" +import * as R from 'ramda' export class Actions extends Component { render() { var outdata = [] - const grouped = _(this.props.data) - .groupBy((action) => action.provider) - .value() + const grouped = R.groupBy((action) => action.provider, this.props.data) + + const processData = (data, firstLevelGroupKey, secondLevelGroupKey) => { + const getProcessedData = R.pipe( + R.groupBy((a) => a.extra_data[firstLevelGroupKey]), + R.map((v) => R.groupBy((a) => a.extra_data[secondLevelGroupKey], v)) + ); + return getProcessedData(data) + } + + const manualTestingData = processData(grouped["fedora_manual_testing"] || [], 'testtype', 'section') + const easyfixTestingData = processData(grouped["easyfix"] || [], 'repo_org', 'repo_name') outdata.push( a.extra_data.testtype) - .mapValues((v) => - _(v) - .groupBy((a) => a.extra_data.section) - .value() - ) - .value()} + data={manualTestingData} key="fmtl" /> ) outdata.push( a.extra_data.repo_org) - .mapValues((v) => - _(v) - .groupBy((a) => a.extra_data.repo_name) - .value() - ) - .value()} + data={easyfixTestingData} key="easyfix" /> ) diff --git a/src/wizard/WizardForm.js b/src/wizard/WizardForm.js index 795d166..b705fea 100644 --- a/src/wizard/WizardForm.js +++ b/src/wizard/WizardForm.js @@ -1,6 +1,6 @@ import React, { Component } from "react" import { Row, Button } from "reactstrap" -import _ from "lodash" +import * as R from 'ramda' const durationString = { 3: "Few hours", @@ -17,10 +17,14 @@ class WizardForm extends Component { } provider_selected(provider) { - const tags = _(this.props.actions[provider.provider]) - .flatMap((action) => action.tags) - .uniq() - .value() + const getUniqueTags = R.pipe( + R.map((action) => action.tags), + R.flatten, + R.uniq + ); + + const tags = getUniqueTags(this.props.actions[provider.provider]) + this.props.show_actions([]) this.setState( { @@ -34,9 +38,7 @@ class WizardForm extends Component { } tag_selected(tag) { - const actions = _(this.props.actions[this.state.selected_provider.provider]) - .filter((a) => a.tags.includes(tag)) - .value() + const actions = R.filter((a) => a.tags.includes(tag), this.props.actions[this.state.selected_provider.provider]) this.props.show_actions(actions) } diff --git a/src/wizard/components.js b/src/wizard/components.js index d17540b..4b2c8f3 100644 --- a/src/wizard/components.js +++ b/src/wizard/components.js @@ -1,11 +1,11 @@ import React, { Component } from "react" import { Card, CardHeader, CardBody, UncontrolledCollapse, Row } from "reactstrap" -import _ from "lodash" +import uniqueID from "../helpers/uniqueID" class CollapsableCard extends Component { render() { const { title, expand_text, expand_class, children } = this.props - const id = _.uniqueId("collapsable-card-id-") + const id = uniqueID("collapsable-card-id-") return ( @@ -27,7 +27,7 @@ class CollapsableCard extends Component { class CollapsableBadge extends Component { render() { const { expand_text, expand_class, children, type } = this.props - const id = _.uniqueId("collapsable-badge-id-") + const id = uniqueID("collapsable-badge-id-") return ( diff --git a/yarn.lock b/yarn.lock index 85bfaa4..4e47ea6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6907,6 +6907,11 @@ nan@^2.12.1: resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01" integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw== +nanoid@^3.1.22: + version "3.1.22" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.22.tgz#b35f8fb7d151990a8aebd5aa5015c03cf726f844" + integrity sha512-/2ZUaJX2ANuLtTvqTlgqBQNJoQO398KyJgZloL0PZkC0dpysjncRUPsFe3DUPzz/y3h+u7C46np8RMuvF3jsSQ== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -8505,6 +8510,11 @@ raf@^3.4.1: dependencies: performance-now "^2.1.0" +ramda@^0.27.1: + version "0.27.1" + resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9" + integrity sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw== + randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"