Skip to content

Commit

Permalink
Merge pull request #573 from maryvilledev/revert-571-DownloadButton209
Browse files Browse the repository at this point in the history
Revert "Add download button"
  • Loading branch information
thebho authored May 31, 2017
2 parents 921449f + f435b3b commit b40ec4c
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 197 deletions.
7 changes: 1 addition & 6 deletions __tests__/components/AppMenu.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const defaultProps = {
orgSnippets: {},
username: 'username',
userSnippets: {},
onDownloadClick: jest.fn(),
};

describe('<AppMenu />', () => {
Expand Down Expand Up @@ -47,11 +46,7 @@ describe('<AppMenu />', () => {
onSignOut={onSignOut}
/>,
);
expect(
wrapper.find('MenuItem')
.find('[primaryText="Sign out"]')
.prop('onClick'),
).toEqual(onSignOut);
expect(wrapper.find('MenuItem').prop('onClick')).toEqual(onSignOut);
});
});
});
28 changes: 0 additions & 28 deletions __tests__/components/__snapshots__/AppMenu.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@ exports[`<AppMenu /> snapshot tests matches snapshot of when user is logged in 1
<GistMenu
gists={Array []}
onClick={[Function]} />
<MenuItem
anchorOrigin={
Object {
"horizontal": "right",
"vertical": "top",
}
}
checked={false}
desktop={false}
disabled={false}
focusState="none"
insetChildren={false}
onClick={[Function]}
primaryText="Download" />
<MenuItem
anchorOrigin={
Object {
Expand Down Expand Up @@ -134,20 +120,6 @@ exports[`<AppMenu /> snapshot tests matches snapshot of when user is not logged
<GistMenu
gists={Array []}
onClick={[Function]} />
<MenuItem
anchorOrigin={
Object {
"horizontal": "right",
"vertical": "top",
}
}
checked={false}
desktop={false}
disabled={false}
focusState="none"
insetChildren={false}
onClick={[Function]}
primaryText="Download" />
<MenuItem
anchorOrigin={
Object {
Expand Down
12 changes: 0 additions & 12 deletions __tests__/containers/__snapshots__/CodesplainAppBar.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ exports[`<CodesplainAppBar /> snapshot tests user is logged in 1`] = `
onRequestClose={[Function]}
open={false}
orderedSnippets={Array []} />
<DownloadDialog
onCanceled={[Function]}
onDownloadClick={[Function]}
open={false}
orgs={Array []}
username="FooBar" />
</div>
`;

Expand Down Expand Up @@ -256,11 +250,5 @@ exports[`<CodesplainAppBar /> snapshot tests user is not logged in 1`] = `
onRequestClose={[Function]}
open={false}
orderedSnippets={Array []} />
<DownloadDialog
onCanceled={[Function]}
onDownloadClick={[Function]}
open={false}
orgs={Array []}
username="FooBar" />
</div>
`;
21 changes: 1 addition & 20 deletions src/actions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import { addNotification, closeNotification } from './notifications';
import { setAuthor, setPermissions } from './permissions';
import { fetchSnippetLists } from './user';
import { removeDeprecatedFiltersFromState } from '../util/codemirror-utils';
import {
makeDumpEndpointUrl,
makeSaveEndpointUrl,
normalizeState,
} from '../util/requests';
import { makeSaveEndpointUrl, normalizeState } from '../util/requests';
import { setDefaults } from '../util/state-management';

export const RESET_STATE = 'RESET_STATE';
Expand Down Expand Up @@ -227,21 +223,6 @@ export const deleteSnippet = snippetKey => (dispatch, getState) => {
});
};

export const downloadZip = selectedOrg => (dispatch) => {
dispatch(addNotification('Downloading snippets zip file.'));
return axios.post(makeDumpEndpointUrl(selectedOrg))
.then(({ data: url }) => {
dispatch(closeNotification());
dispatch(addNotification('Successfully downloaded zip file!'));
window.location = url;
})
.catch((err) => {
dispatch(closeNotification());
dispatch(addNotification('Failed to download snippets zip.'));
throw err;
});
};

export const loadSnippet = (snippetOwner, snippetKey) => (dispatch, getState) => {
const { token } = getState().user;
const reqHeaders = {
Expand Down
78 changes: 0 additions & 78 deletions src/components/DownloadDialog.jsx

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/menus/AppMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class AppMenu extends Component {
const {
avatarUrl,
onSignOut,
onDownloadClick,
style,
gists,
onImportGist,
Expand All @@ -87,10 +86,6 @@ class AppMenu extends Component {
onClick={onImportGist}
gists={gists}
/>
<MenuItem
onClick={onDownloadClick}
primaryText="Download"
/>
<MenuItem
onClick={onSignOut}
primaryText="Sign out"
Expand All @@ -104,7 +99,6 @@ class AppMenu extends Component {
AppMenu.propTypes = {
avatarUrl: PropTypes.string,
onSignOut: PropTypes.func.isRequired,
onDownloadClick: PropTypes.func.isRequired,
gists: CustomPropTypes.gists,
onImportGist: PropTypes.func.isRequired,
};
Expand Down
41 changes: 1 addition & 40 deletions src/containers/CodesplainAppBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { closeAnnotationPanel } from '../actions/annotation';
import {
resetState,
setSnippetTitle,
downloadZip,
} from '../actions/app';
import {
fetchGist,
Expand All @@ -35,7 +34,6 @@ import AppMenu from '../components/menus/AppMenu';
import CustomPropTypes from '../util/custom-prop-types';
import SnippetMenu from '../components/menus/SnippetMenu';
import SearchMenu from '../components/menus/SearchMenu';
import DownloadDialog from '../components/DownloadDialog';

const CLIENT_ID = process.env.REACT_APP_CLIENT_ID;
const GITHUB_URL = `https://github.com/login/oauth/authorize?client_id=${CLIENT_ID}&scope=read:org`;
Expand Down Expand Up @@ -110,7 +108,6 @@ export class CodesplainAppBar extends Component {
isLoggedIn: false,
isDialogOpen: false,
isSearchMenuOpen: false,
isDownloadDialogOpen: false,
};
this.fetchUserAccountInfo = this.fetchUserAccountInfo.bind(this);
this.handleConfirmNavigation = this.handleConfirmNavigation.bind(this);
Expand All @@ -124,9 +121,6 @@ export class CodesplainAppBar extends Component {
this.onLoginClick = this.onLoginClick.bind(this);
this.redirectToHomePage = this.redirectToHomePage.bind(this);
this.resetApplication = this.resetApplication.bind(this);
this.showDownloadDialog = this.showDownloadDialog.bind(this);
this.hideDownloadDialog = this.hideDownloadDialog.bind(this);
this.handleDownload = this.handleDownload.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -261,20 +255,6 @@ export class CodesplainAppBar extends Component {
}
}

showDownloadDialog() {
this.setState({ isDownloadDialogOpen: true });
}

hideDownloadDialog() {
this.setState({ isDownloadDialogOpen: false });
}

handleDownload(selectedOrg) {
const { dispatch } = this.props;
dispatch(downloadZip(selectedOrg));
this.hideDownloadDialog();
}

render() {
const actions = [
<FlatButton
Expand All @@ -296,22 +276,14 @@ export class CodesplainAppBar extends Component {
userSnippets,
gists,
orderedSnippets,
orgs,
} = this.props;
const {
isDialogOpen,
isLoggedIn,
isSearchMenuOpen,
isDownloadDialogOpen,
} = this.state;

const { isDialogOpen, isLoggedIn, isSearchMenuOpen } = this.state;
const appMenu = isLoggedIn ?
(<AppMenu
avatarUrl={avatarUrl}
gists={gists}
onImportGist={this.handleImportGist}
onSignOut={this.handleSignOut}
onDownloadClick={this.showDownloadDialog}
onSnippetSelected={this.handleSnippetSelected}
orgSnippets={orgSnippets}
username={username}
Expand Down Expand Up @@ -373,13 +345,6 @@ export class CodesplainAppBar extends Component {
orderedSnippets={orderedSnippets}
onClick={this.handleSnippetSelected}
/>
<DownloadDialog
open={isDownloadDialogOpen}
onDownloadClick={this.handleDownload}
onCanceled={this.hideDownloadDialog}
orgs={orgs}
username={username}
/>
</div>
);
}
Expand All @@ -395,7 +360,6 @@ CodesplainAppBar.propTypes = {
userSnippets: CustomPropTypes.snippets,
orderedSnippets: CustomPropTypes.orderedSnippets,
snippetKey: PropTypes.string,
orgs: CustomPropTypes.orgs,
};

CodesplainAppBar.defaultProps = {
Expand All @@ -407,7 +371,6 @@ CodesplainAppBar.defaultProps = {
userSnippets: {},
orderedSnippets: [],
snippetKey: '',
orgs: [],
};

const mapStateToProps = (state) => {
Expand All @@ -423,7 +386,6 @@ const mapStateToProps = (state) => {
token,
username,
userSnippets,
orgs,
},
gists,
} = state;
Expand All @@ -439,7 +401,6 @@ const mapStateToProps = (state) => {
userSnippets,
orderedSnippets,
snippetKey,
orgs,
};
};

Expand Down
7 changes: 0 additions & 7 deletions src/util/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export const makeSaveEndpointUrl = (username, snippetId = '') => {
return `${API_URL}/users/${username}/snippets`;
};

/*
Construct the REST endpoint for generating a zip file of the selectedOrg.
*/
export const makeDumpEndpointUrl = selectedOrg => (
`${API_URL}/users/${selectedOrg}/dump`
);

/*
Construct the REST endpoint for obtaining the parser for the specified
language.
Expand Down

0 comments on commit b40ec4c

Please sign in to comment.