Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
resolve review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
superhawk610 committed Sep 2, 2018
1 parent dcdf510 commit 6afbcc3
Show file tree
Hide file tree
Showing 12 changed files with 642 additions and 619 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ import CustomHighlight from '../CustomHighlight';

import type { DependencyStatus } from '../../types';

const DEPENDENCY_ACTIONS_COPY = {
idle: 'Installed',
installing: 'Installing…',
updating: 'Updating…',
deleting: 'Deleting…',
'queued-install': 'Queued for Install',
'queued-update': 'Queued for Update',
'queued-delete': 'Queued for Delete',
};

type Props = {
projectId: string,
currentStatus: ?DependencyStatus,
Expand Down Expand Up @@ -76,8 +86,9 @@ const getColorForDownloadNumber = (num: number) => {
class AddDependencySearchResult extends PureComponent<Props> {
renderActionArea() {
const { hit, projectId, currentStatus, addDependency } = this.props;
const isAlreadyInstalled = currentStatus === 'idle';

if (currentStatus === 'idle') {
if (isAlreadyInstalled) {
return (
<NoActionAvailable>
<IconBase
Expand All @@ -96,16 +107,7 @@ class AddDependencySearchResult extends PureComponent<Props> {
<NoActionAvailable>
<Spinner size={24} />
<Spacer size={6} />
{
{
installing: 'Installing..',
updating: 'Updating..',
deleting: 'Deleting..',
'queued-install': 'Queued for Install',
'queued-update': 'Queued for Update',
'queued-delete': 'Queued for Delete',
}[currentStatus]
}
{DEPENDENCY_ACTIONS_COPY[currentStatus]}
</NoActionAvailable>
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/DeleteDependencyButton/DeleteDependencyButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import PixelShifter from '../PixelShifter';

const { dialog } = remote;

const DEPENDENCY_DELETE_COPY = {
idle: 'Delete',
'queued-delete': 'Queued for Delete…',
};

type Props = {
projectId: string,
dependencyName: string,
Expand Down Expand Up @@ -75,10 +80,7 @@ class DeleteDependencyButton extends PureComponent<Props> {
<Spinner size={18} color={COLORS.white} />
</PixelShifter>
) : (
{
idle: 'Delete',
'queued-delete': 'Queued for Delete..',
}[dependencyStatus]
DEPENDENCY_DELETE_COPY[dependencyStatus]
)}
</Button>
);
Expand Down
82 changes: 43 additions & 39 deletions src/components/DependencyManagementPane/DependencyManagementPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import styled from 'styled-components';
import IconBase from 'react-icons-kit';
import { moreHorizontal, plus } from 'react-icons-kit/feather';
import { plus } from 'react-icons-kit/feather/plus';

import { runTask, abortTask } from '../../actions';
import { getSelectedProject } from '../../reducers/projects.reducer';
Expand Down Expand Up @@ -102,6 +102,44 @@ class DependencyManagementPane extends PureComponent<Props, State> {
this.setState({ addingNewDependency: false });
};

renderListAddon = (dependency, isSelected) => {
if (
dependency.status === 'installing' ||
dependency.status.match(/^queued-/)
) {
return (
<Spinner size={20} color={isSelected ? COLORS.white : undefined} />
);
}

return (
<DependencyVersion isSelected={isSelected}>
{dependency.version}
</DependencyVersion>
);
};

renderMainContents = (selectedDependency, projectId) => {
if (
selectedDependency.status === 'installing' ||
selectedDependency.status === 'queued-install'
) {
return (
<DependencyInstalling
name={selectedDependency.name}
queued={selectedDependency.status === 'queued-install'}
/>
);
}

return (
<DependencyDetails
projectId={projectId}
dependency={selectedDependency}
/>
);
};

render() {
const { id, dependencies } = this.props.project;
const { selectedDependencyIndex, addingNewDependency } = this.state;
Expand All @@ -123,32 +161,9 @@ class DependencyManagementPane extends PureComponent<Props, State> {
onClick={() => this.selectDependency(dependency.name)}
>
<DependencyName>{dependency.name}</DependencyName>
{dependency.status === 'installing' ? (
<Spinner
size={20}
color={
selectedDependencyIndex === index
? COLORS.white
: undefined
}
/>
) : dependency.status.match(/^queued-/) ? (
<span
style={{
color:
selectedDependencyIndex === index
? COLORS.white
: undefined,
}}
>
<IconBase size={20} icon={moreHorizontal} />
</span>
) : (
<DependencyVersion
isSelected={selectedDependencyIndex === index}
>
{dependency.version}
</DependencyVersion>
{this.renderListAddon(
dependency,
selectedDependencyIndex === index
)}
</DependencyButton>
))}
Expand Down Expand Up @@ -182,18 +197,7 @@ class DependencyManagementPane extends PureComponent<Props, State> {
</MountAfter>
</DependencyList>
<MainContent>
{selectedDependency.status === 'installing' ||
selectedDependency.status === 'queued-install' ? (
<DependencyInstalling
name={selectedDependency.name}
queued={selectedDependency.status === 'queued-install'}
/>
) : (
<DependencyDetails
projectId={id}
dependency={selectedDependency}
/>
)}
{this.renderMainContents(selectedDependency, id)}
</MainContent>
</Wrapper>

Expand Down
Loading

0 comments on commit 6afbcc3

Please sign in to comment.