Skip to content

Commit b40ec4c

Browse files
authored
Merge pull request #573 from maryvilledev/revert-571-DownloadButton209
Revert "Add download button"
2 parents 921449f + f435b3b commit b40ec4c

File tree

8 files changed

+3
-197
lines changed

8 files changed

+3
-197
lines changed

__tests__/components/AppMenu.test.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const defaultProps = {
1313
orgSnippets: {},
1414
username: 'username',
1515
userSnippets: {},
16-
onDownloadClick: jest.fn(),
1716
};
1817

1918
describe('<AppMenu />', () => {
@@ -47,11 +46,7 @@ describe('<AppMenu />', () => {
4746
onSignOut={onSignOut}
4847
/>,
4948
);
50-
expect(
51-
wrapper.find('MenuItem')
52-
.find('[primaryText="Sign out"]')
53-
.prop('onClick'),
54-
).toEqual(onSignOut);
49+
expect(wrapper.find('MenuItem').prop('onClick')).toEqual(onSignOut);
5550
});
5651
});
5752
});

__tests__/components/__snapshots__/AppMenu.test.jsx.snap

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,6 @@ exports[`<AppMenu /> snapshot tests matches snapshot of when user is logged in 1
5050
<GistMenu
5151
gists={Array []}
5252
onClick={[Function]} />
53-
<MenuItem
54-
anchorOrigin={
55-
Object {
56-
"horizontal": "right",
57-
"vertical": "top",
58-
}
59-
}
60-
checked={false}
61-
desktop={false}
62-
disabled={false}
63-
focusState="none"
64-
insetChildren={false}
65-
onClick={[Function]}
66-
primaryText="Download" />
6753
<MenuItem
6854
anchorOrigin={
6955
Object {
@@ -134,20 +120,6 @@ exports[`<AppMenu /> snapshot tests matches snapshot of when user is not logged
134120
<GistMenu
135121
gists={Array []}
136122
onClick={[Function]} />
137-
<MenuItem
138-
anchorOrigin={
139-
Object {
140-
"horizontal": "right",
141-
"vertical": "top",
142-
}
143-
}
144-
checked={false}
145-
desktop={false}
146-
disabled={false}
147-
focusState="none"
148-
insetChildren={false}
149-
onClick={[Function]}
150-
primaryText="Download" />
151123
<MenuItem
152124
anchorOrigin={
153125
Object {

__tests__/containers/__snapshots__/CodesplainAppBar.test.jsx.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,6 @@ exports[`<CodesplainAppBar /> snapshot tests user is logged in 1`] = `
132132
onRequestClose={[Function]}
133133
open={false}
134134
orderedSnippets={Array []} />
135-
<DownloadDialog
136-
onCanceled={[Function]}
137-
onDownloadClick={[Function]}
138-
open={false}
139-
orgs={Array []}
140-
username="FooBar" />
141135
</div>
142136
`;
143137

@@ -256,11 +250,5 @@ exports[`<CodesplainAppBar /> snapshot tests user is not logged in 1`] = `
256250
onRequestClose={[Function]}
257251
open={false}
258252
orderedSnippets={Array []} />
259-
<DownloadDialog
260-
onCanceled={[Function]}
261-
onDownloadClick={[Function]}
262-
open={false}
263-
orgs={Array []}
264-
username="FooBar" />
265253
</div>
266254
`;

src/actions/app.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { addNotification, closeNotification } from './notifications';
55
import { setAuthor, setPermissions } from './permissions';
66
import { fetchSnippetLists } from './user';
77
import { removeDeprecatedFiltersFromState } from '../util/codemirror-utils';
8-
import {
9-
makeDumpEndpointUrl,
10-
makeSaveEndpointUrl,
11-
normalizeState,
12-
} from '../util/requests';
8+
import { makeSaveEndpointUrl, normalizeState } from '../util/requests';
139
import { setDefaults } from '../util/state-management';
1410

1511
export const RESET_STATE = 'RESET_STATE';
@@ -227,21 +223,6 @@ export const deleteSnippet = snippetKey => (dispatch, getState) => {
227223
});
228224
};
229225

230-
export const downloadZip = selectedOrg => (dispatch) => {
231-
dispatch(addNotification('Downloading snippets zip file.'));
232-
return axios.post(makeDumpEndpointUrl(selectedOrg))
233-
.then(({ data: url }) => {
234-
dispatch(closeNotification());
235-
dispatch(addNotification('Successfully downloaded zip file!'));
236-
window.location = url;
237-
})
238-
.catch((err) => {
239-
dispatch(closeNotification());
240-
dispatch(addNotification('Failed to download snippets zip.'));
241-
throw err;
242-
});
243-
};
244-
245226
export const loadSnippet = (snippetOwner, snippetKey) => (dispatch, getState) => {
246227
const { token } = getState().user;
247228
const reqHeaders = {

src/components/DownloadDialog.jsx

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/components/menus/AppMenu.jsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class AppMenu extends Component {
6262
const {
6363
avatarUrl,
6464
onSignOut,
65-
onDownloadClick,
6665
style,
6766
gists,
6867
onImportGist,
@@ -87,10 +86,6 @@ class AppMenu extends Component {
8786
onClick={onImportGist}
8887
gists={gists}
8988
/>
90-
<MenuItem
91-
onClick={onDownloadClick}
92-
primaryText="Download"
93-
/>
9489
<MenuItem
9590
onClick={onSignOut}
9691
primaryText="Sign out"
@@ -104,7 +99,6 @@ class AppMenu extends Component {
10499
AppMenu.propTypes = {
105100
avatarUrl: PropTypes.string,
106101
onSignOut: PropTypes.func.isRequired,
107-
onDownloadClick: PropTypes.func.isRequired,
108102
gists: CustomPropTypes.gists,
109103
onImportGist: PropTypes.func.isRequired,
110104
};

src/containers/CodesplainAppBar.jsx

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { closeAnnotationPanel } from '../actions/annotation';
1515
import {
1616
resetState,
1717
setSnippetTitle,
18-
downloadZip,
1918
} from '../actions/app';
2019
import {
2120
fetchGist,
@@ -35,7 +34,6 @@ import AppMenu from '../components/menus/AppMenu';
3534
import CustomPropTypes from '../util/custom-prop-types';
3635
import SnippetMenu from '../components/menus/SnippetMenu';
3736
import SearchMenu from '../components/menus/SearchMenu';
38-
import DownloadDialog from '../components/DownloadDialog';
3937

4038
const CLIENT_ID = process.env.REACT_APP_CLIENT_ID;
4139
const GITHUB_URL = `https://github.com/login/oauth/authorize?client_id=${CLIENT_ID}&scope=read:org`;
@@ -110,7 +108,6 @@ export class CodesplainAppBar extends Component {
110108
isLoggedIn: false,
111109
isDialogOpen: false,
112110
isSearchMenuOpen: false,
113-
isDownloadDialogOpen: false,
114111
};
115112
this.fetchUserAccountInfo = this.fetchUserAccountInfo.bind(this);
116113
this.handleConfirmNavigation = this.handleConfirmNavigation.bind(this);
@@ -124,9 +121,6 @@ export class CodesplainAppBar extends Component {
124121
this.onLoginClick = this.onLoginClick.bind(this);
125122
this.redirectToHomePage = this.redirectToHomePage.bind(this);
126123
this.resetApplication = this.resetApplication.bind(this);
127-
this.showDownloadDialog = this.showDownloadDialog.bind(this);
128-
this.hideDownloadDialog = this.hideDownloadDialog.bind(this);
129-
this.handleDownload = this.handleDownload.bind(this);
130124
}
131125

132126
componentDidMount() {
@@ -261,20 +255,6 @@ export class CodesplainAppBar extends Component {
261255
}
262256
}
263257

264-
showDownloadDialog() {
265-
this.setState({ isDownloadDialogOpen: true });
266-
}
267-
268-
hideDownloadDialog() {
269-
this.setState({ isDownloadDialogOpen: false });
270-
}
271-
272-
handleDownload(selectedOrg) {
273-
const { dispatch } = this.props;
274-
dispatch(downloadZip(selectedOrg));
275-
this.hideDownloadDialog();
276-
}
277-
278258
render() {
279259
const actions = [
280260
<FlatButton
@@ -296,22 +276,14 @@ export class CodesplainAppBar extends Component {
296276
userSnippets,
297277
gists,
298278
orderedSnippets,
299-
orgs,
300279
} = this.props;
301-
const {
302-
isDialogOpen,
303-
isLoggedIn,
304-
isSearchMenuOpen,
305-
isDownloadDialogOpen,
306-
} = this.state;
307-
280+
const { isDialogOpen, isLoggedIn, isSearchMenuOpen } = this.state;
308281
const appMenu = isLoggedIn ?
309282
(<AppMenu
310283
avatarUrl={avatarUrl}
311284
gists={gists}
312285
onImportGist={this.handleImportGist}
313286
onSignOut={this.handleSignOut}
314-
onDownloadClick={this.showDownloadDialog}
315287
onSnippetSelected={this.handleSnippetSelected}
316288
orgSnippets={orgSnippets}
317289
username={username}
@@ -373,13 +345,6 @@ export class CodesplainAppBar extends Component {
373345
orderedSnippets={orderedSnippets}
374346
onClick={this.handleSnippetSelected}
375347
/>
376-
<DownloadDialog
377-
open={isDownloadDialogOpen}
378-
onDownloadClick={this.handleDownload}
379-
onCanceled={this.hideDownloadDialog}
380-
orgs={orgs}
381-
username={username}
382-
/>
383348
</div>
384349
);
385350
}
@@ -395,7 +360,6 @@ CodesplainAppBar.propTypes = {
395360
userSnippets: CustomPropTypes.snippets,
396361
orderedSnippets: CustomPropTypes.orderedSnippets,
397362
snippetKey: PropTypes.string,
398-
orgs: CustomPropTypes.orgs,
399363
};
400364

401365
CodesplainAppBar.defaultProps = {
@@ -407,7 +371,6 @@ CodesplainAppBar.defaultProps = {
407371
userSnippets: {},
408372
orderedSnippets: [],
409373
snippetKey: '',
410-
orgs: [],
411374
};
412375

413376
const mapStateToProps = (state) => {
@@ -423,7 +386,6 @@ const mapStateToProps = (state) => {
423386
token,
424387
username,
425388
userSnippets,
426-
orgs,
427389
},
428390
gists,
429391
} = state;
@@ -439,7 +401,6 @@ const mapStateToProps = (state) => {
439401
userSnippets,
440402
orderedSnippets,
441403
snippetKey,
442-
orgs,
443404
};
444405
};
445406

src/util/requests.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ export const makeSaveEndpointUrl = (username, snippetId = '') => {
3333
return `${API_URL}/users/${username}/snippets`;
3434
};
3535

36-
/*
37-
Construct the REST endpoint for generating a zip file of the selectedOrg.
38-
*/
39-
export const makeDumpEndpointUrl = selectedOrg => (
40-
`${API_URL}/users/${selectedOrg}/dump`
41-
);
42-
4336
/*
4437
Construct the REST endpoint for obtaining the parser for the specified
4538
language.

0 commit comments

Comments
 (0)