Skip to content

Commit 7b579c7

Browse files
authored
Merge pull request #1389 from outoftime/no-anonymous-gist-export
Remove anonymous gist export
2 parents 6c11ec4 + edb023c commit 7b579c7

2 files changed

Lines changed: 18 additions & 30 deletions

File tree

src/clients/github.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import trim from 'lodash/trim';
55
import performWithRetries from '../util/performWithRetries';
66
import compileProject from '../util/compileProject';
77

8-
const anonymousGithub = new GitHub({});
98
const COMMIT_MESSAGE = 'Created using Popcode: https://popcode.org';
109
const MASTER = 'master';
1110
const GH_PAGES = 'gh-pages';
@@ -70,11 +69,7 @@ export async function createGistFromProject(project, user) {
7069
const response =
7170
await performWithRetryNetworkErrors(() => github.getGist().create(gist));
7271

73-
const gistData = response.data;
74-
if (canUpdateGist(user)) {
75-
return updateGistWithImportUrl(github, gistData);
76-
}
77-
return gistData;
72+
return updateGistWithImportUrl(github, response.data);
7873
}
7974

8075
export async function loadGistFromId(gistId, user) {
@@ -253,19 +248,7 @@ function githubWithAccessToken(token) {
253248
return new GitHub({auth: 'oauth', token});
254249
}
255250

256-
function getGithubToken(user) {
257-
return get(user, ['accessTokens', 'github.com']);
258-
}
259-
260251
function clientForUser(user) {
261-
const githubToken = getGithubToken(user);
262-
if (githubToken) {
263-
return githubWithAccessToken(githubToken);
264-
}
265-
266-
return anonymousGithub;
267-
}
268-
269-
function canUpdateGist(user) {
270-
return Boolean(getGithubToken(user));
252+
const githubToken = get(user, ['accessTokens', 'github.com']);
253+
return githubWithAccessToken(githubToken);
271254
}

src/components/TopBar/HamburgerMenu.jsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ const HamburgerMenu = createMenu({
2323
}) {
2424
return tap([], (items) => {
2525
items.push(
26-
<MenuItem
27-
key="exportGist"
28-
onClick={isGistExportInProgress ? noop : onExportGist}
29-
>
30-
{t('top-bar.export-gist')}
31-
</MenuItem>,
3226
<MenuItem
3327
key="exportToClassroom"
3428
onClick={isClassroomExportInProgress ? noop : onExportToClassroom}
@@ -37,15 +31,26 @@ const HamburgerMenu = createMenu({
3731
</MenuItem>,
3832
);
3933

40-
if (isUserAuthenticated && isExperimental) {
34+
if (isUserAuthenticated) {
4135
items.push(
4236
<MenuItem
43-
key="exportRepo"
44-
onClick={isRepoExportInProgress ? noop : onExportRepo}
37+
key="exportGist"
38+
onClick={isGistExportInProgress ? noop : onExportGist}
4539
>
46-
{t('top-bar.export-repo')}
40+
{t('top-bar.export-gist')}
4741
</MenuItem>,
4842
);
43+
44+
if (isExperimental) {
45+
items.push(
46+
<MenuItem
47+
key="exportRepo"
48+
onClick={isRepoExportInProgress ? noop : onExportRepo}
49+
>
50+
{t('top-bar.export-repo')}
51+
</MenuItem>,
52+
);
53+
}
4954
}
5055

5156
items.push(

0 commit comments

Comments
 (0)