diff --git a/app/javascript/src/components/Navigation/components/GlobalActivitiesModal.jsx b/app/javascript/src/components/Navigation/components/GlobalActivitiesModal.jsx index 57bcf78da..fe70d3224 100644 --- a/app/javascript/src/components/Navigation/components/GlobalActivitiesModal.jsx +++ b/app/javascript/src/components/Navigation/components/GlobalActivitiesModal.jsx @@ -1,6 +1,7 @@ // @flow import React, { Component } from "react"; +import type { Element } from "react"; import { FormattedMessage } from "react-intl"; import { Button, Modal } from "react-bootstrap"; import _ from "lodash"; @@ -70,27 +71,19 @@ class GlobalActivitiesModal extends Component { constructor(props: Props) { super(props); this.state = { activities: [], more: false }; - (this: Class< - GlobalActivitiesModal - >).displayActivities = this.displayActivities.bind(this); - (this: Class< - GlobalActivitiesModal - >).addMoreActivities = this.addMoreActivities.bind(this); - (this: Class< - GlobalActivitiesModal - >).onCloseModalActions = this.onCloseModalActions.bind(this); - (this: Class).loadData = this.loadData.bind(this); - (this: Class< - GlobalActivitiesModal - >).mapActivities = this.mapActivities.bind(this); + (this: any).displayActivities = this.displayActivities.bind(this); + (this: any).addMoreActivities = this.addMoreActivities.bind(this); + (this: any).onCloseModalActions = this.onCloseModalActions.bind(this); + (this: any).loadData = this.loadData.bind(this); + (this: any).mapActivities = this.mapActivities.bind(this); } - onCloseModalActions() { + onCloseModalActions(): void { this.setState({ activities: [], more: false }); this.props.onCloseModal(); } - loadData() { + loadData(): void { getActivities().then(response => { this.setState({ activities: response.activities, @@ -99,7 +92,7 @@ class GlobalActivitiesModal extends Component { }); } - mapActivities() { + mapActivities(): Array<*> { return this.state.activities.map((activity, i, arr) => { // @todo replace key={i} with key={activity.id} !!!!!!!!!!!!!! // when the backend bug will be fixed @@ -142,7 +135,7 @@ class GlobalActivitiesModal extends Component { return this.mapActivities(); } - addMoreActivities() { + addMoreActivities(): void { const lastId = _.last(this.state.activities).id; getActivities( lastId @@ -154,7 +147,7 @@ class GlobalActivitiesModal extends Component { }); } - addMoreButton() { + addMoreButton(): Element<*> { if (this.state.more) { return (
  • @@ -164,7 +157,7 @@ class GlobalActivitiesModal extends Component {
  • ); } - return ""; + return ; } render() { diff --git a/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx b/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx index 61d5e1c02..764e90c32 100644 --- a/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx +++ b/app/javascript/src/scenes/SettingsPage/scenes/team/index.jsx @@ -5,7 +5,7 @@ import { Breadcrumb, Row, Col, Glyphicon, Well } from "react-bootstrap"; import { LinkContainer } from "react-router-bootstrap"; import { FormattedHTMLMessage, FormattedMessage } from "react-intl"; import moment from "moment"; -import prettysize from "prettysize"; +import { formatBytes } from "../../../../services/helpers/units_converter_helper"; import axios from "../../../../config/axios"; import { SETTINGS_TEAMS_ROUTE } from "../../../../config/routes"; @@ -25,7 +25,9 @@ const Wrapper = styled.div` padding: 16px 15px 50px 15px; `; -const TabTitle = styled.div`padding: 15px;`; +const TabTitle = styled.div` + padding: 15px; +`; const BadgeWrapper = styled.div` font-size: 1.4em; @@ -39,7 +41,8 @@ const StyledWell = styled(Well)` padding: 9px; & > span { padding-left: 5px; - }`; + } +`; const StyledDescriptionWell = styled(Well)` padding: 9px; @@ -59,8 +62,6 @@ const StyledH3 = styled.h3` } `; -const StyledOl = styled.ol`padding: 15px;`; - class SettingsTeam extends Component { constructor(props) { super(props); @@ -132,7 +133,7 @@ class SettingsTeam extends Component { renderEditNameModel() { if (this.state.showNameModal) { - return( + return ( @@ -208,9 +209,7 @@ class SettingsTeam extends Component { - - {this.renderDescription()} - + {this.renderDescription()} diff --git a/app/javascript/src/services/helpers/units_converter_helper.js b/app/javascript/src/services/helpers/units_converter_helper.js new file mode 100644 index 000000000..c52757fb8 --- /dev/null +++ b/app/javascript/src/services/helpers/units_converter_helper.js @@ -0,0 +1,9 @@ +// @flow + +export function formatBytes(bytes: number): string { + if (bytes === 0) return "0 Bytes"; + const k = 1024; + const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return `${parseFloat((bytes / (k ** i)).toFixed(2))} ${sizes[i]}`; +} diff --git a/package.json b/package.json index c2399f7b3..75a074613 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "postcss-loader": "^2.0.6", "postcss-smart-import": "^0.7.5", "precss": "^2.0.0", - "prettysize": "^1.1.0", "prop-types": "^15.5.10", "rails-erb-loader": "^5.0.2", "react": "15.6.1", diff --git a/yarn.lock b/yarn.lock index 3ba25c624..3a3030b74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4823,10 +4823,6 @@ prettier@^1.7.0: version "1.7.4" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.4.tgz#5e8624ae9363c80f95ec644584ecdf55d74f93fa" -prettysize@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/prettysize/-/prettysize-1.1.0.tgz#c6c52f87161ff172ea435f375f99831dd9a97bb0" - private@^0.1.6, private@^0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1"