Skip to content

Commit

Permalink
Revert "Dropdowns for context selection"
Browse files Browse the repository at this point in the history
  • Loading branch information
jpolitz authored Aug 10, 2023
1 parent f676875 commit 09bc488
Show file tree
Hide file tree
Showing 13 changed files with 4,156 additions and 7,297 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ PORT=4999
NODE_ENV=development
POSTMESSAGE_ORIGIN="http://localhost:3000"

WHITELISTED_CTXS="essentials2019, essentials2020, essentials2021"
DEFAULT_CTX="essentials2021"
6 changes: 0 additions & 6 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@
},
"USE_STANDALONE_PYRET": {
"required": true
},
"WHITELISTED_CTXS": {
"required": true
},
"DEFAULT_CTX": {
"required": true
}
},
"formation": {
Expand Down
11,025 changes: 4,140 additions & 6,885 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"pyret-codemirror-mode": "git://github.com/brownplt/pyret-codemirror-mode.git#master",
"pyret-lang": "git+https://github.com/brownplt/pyret-lang.git#horizon",
"q": "~1.4.1",
"react": "^16.8.0",
"react-dom": "^16",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"redis": "^0.10.3",
"request": "^2.87.0",
"requirejs": "2.1.14",
Expand Down
61 changes: 0 additions & 61 deletions src/web/css/dropdowns.css

This file was deleted.

60 changes: 1 addition & 59 deletions src/web/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>code.pyret.org</title>

<link rel="preload" href="{{&PYRET}}" as="script">
<link rel="stylesheet" href="/css/reset.css" />
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
Expand All @@ -26,9 +25,6 @@
<style id="highlight-styles"></style>
<script>var APP_LOG_URL = "{{{ LOG_URL }}}";</script>
<script src="/js/localSettings.js"></script>

<link href="/css/dropdowns.css" rel="stylesheet" />

</head>
<body class="default">
<script>
Expand Down Expand Up @@ -463,7 +459,6 @@ <h2>Announcements</h2>
console.log(window.performance.now());
</script>
<script src="js/events.js"></script>
<script src="js/dropdowns.js"></script>
<script src="js/beforePyret.js"></script>
<script>
var APP_BASE_URL = "{{{ BASE_URL }}}";
Expand All @@ -477,59 +472,6 @@ <h2>Announcements</h2>
});
</script>


<template id="ctx-modal-template">
<div>
<p>Enter the context to use for the program, or choose “Cancel” to keep the current context of <tt>essentials2021</tt>.</p>
<p><ul>
<li>The default is <tt>essentials2021</tt>.</li>
<li>You might use something like <tt>shared-gdrive(...)</tt> if one was provided as part of a course.</li>
</ul></p>
<div id="modal-dropdown-placeholder"></div>
</div>
</template>


<!--
<div style="display: flex; flex-direction: row; justify-content: flex-start; align-items: baseline;">
<tt style="flex-grow: 0; padding-right: 1em;">use context</tt>
<div style="flex-grow: 1;"><input id="modal-prompt-text" type="text">
</div>
</div> -->


<template id="dropdown-template"><form>

<div>
<input type="radio" id="whitelisted-radio" name="ctx-choice-type" value="whitelisted" checked>
<label for="whitelisted-radio">Choose from frequently-used contexts</label>
</div>

<div class="dropdown">
<button class="dropdown-toggle" data-dd-target="first" aria-label="Dropdown Menu">
<code id="current-whitelist-ctx"></code>
</button>
<ul class="dropdown-menu" data-dd-path="first"></ul>
</div>

<hr>

<div>
<input type="radio" id="manual-radio" name="ctx-choice-type" value="manual">
<label for="manual-radio">Input context manually</label>
</div>
<div id="manual-ctx-text-input" style="display:none">
<label for="ctx-input"><code>use context </code></label>
<input id="ctx-input" type="text">
</div>

</form></template>

<template id="dropdown-menu-item-template">
<li><a class="dropdown-menu__link" href="#1"><code></code></a></li>
</template>


</main>
</main>
</body>
</html>
12 changes: 2 additions & 10 deletions src/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,11 @@
<!-- GAPI Client -->
<script type="text/javascript" src="https://apis.google.com/js/client.js"></script>



<script src="js/dropdowns.js"></script>
<link href="/css/dropdowns.css" rel="stylesheet" />

</head>
<body>


<main>
<div id="root"></div>
<script src="{{{ASSET_BASE_URL}}}/js/dashboard/index.js"></script>
<div id="root"></div>
<script src="{{{ASSET_BASE_URL}}}/js/dashboard/index.js"></script>
</main>

</body>
</html>
22 changes: 2 additions & 20 deletions src/web/js/beforePyret.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,7 @@ window.CPO = {
documents : new Documents()
};
$(function() {

let CONTEXT_FOR_NEW_FILES = "use context " + process.env.DEFAULT_CTX + "\n";
let pop_ctx_modal = false;
let whitelist = process.env.WHITELISTED_CTXS.split(", ");
let cur_url = new URL(document.location.href);
let parms = cur_url.searchParams;

if (whitelist.includes(parms.get("ctx"))) {
CONTEXT_FOR_NEW_FILES = "use context " + parms.get("ctx") + "\n";
} else if (parms.get("ctx") === "_") {
pop_ctx_modal = true;
}

const CONTEXT_FOR_NEW_FILES = "use context essentials2021\n";
function merge(obj, extension) {
var newobj = {};
Object.keys(obj).forEach(function(k) {
Expand Down Expand Up @@ -484,10 +472,9 @@ $(function() {
element.append(entry);
return element;
}

const namespaceResult = new modalPrompt({
title: "Choose a Context",
style: "ctxDropdown",
style: "text",
options: [
{
drawElement: drawElement,
Expand Down Expand Up @@ -1423,9 +1410,4 @@ $(function() {
if(window.parent !== window) {
makeEvents({ CPO: CPO, sendPort: window.parent, receivePort: window });
}


if (pop_ctx_modal) {
$('#choose-context').trigger('click');
}
});
52 changes: 5 additions & 47 deletions src/web/js/dashboard/StudentDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class StudentDashboard extends Component {
});
}

// handleStartCodingClick = (event) => {
// window.open("/editor", "_blank");
// }
handleStartCodingClick = (event) => {
window.open("/editor", "_blank");
}

handleSignInClick = (event) => {
this.setState({signedIn: WAITING_FOR_SIGNIN});
Expand Down Expand Up @@ -146,42 +146,6 @@ class StudentDashboard extends Component {
}

render = () => {

let ctx_options = process.env.WHITELISTED_CTXS.split(", ");

let items = ctx_options.map((ctx, i) =>
<li key={i}>
<a
className="dropdown-menu__link"
href={"/editor?ctx=" + ctx}>
in context <code>{ctx}</code>
</a>
</li>
);

items.push(
<li key={100}>
<a
className="dropdown-menu__link"
href="/editor?ctx=_">
in custom context
</a>
</li>
)

let start_coding_contents = <React.Fragment>
<div className="dropdown">
<a href="/editor"><button>
Open editor
</button></a>
<button className="dropdown-toggle" data-dd-target="first" aria-label="Dropdown Menu">
</button>
<ul className="dropdown-menu" data-dd-path="first">
{items}
</ul>
</div>
</React.Fragment>;

return (
<div className='wrap'>
<div id='header' className=''>
Expand All @@ -197,15 +161,10 @@ class StudentDashboard extends Component {
<button className={'auth-button ' + (this.state.signedIn !== NOT_SIGNED_IN ? '' : 'hidden')} onClick={this.handleSignOutClick} id='signout-button' >Sign out</button>
</div>
<div className='button-wrapper right start'>

<div id='start-button' className={'start-button ' + (this.state.signedIn === SIGNED_IN ? '' : 'hidden')} >
{start_coding_contents}
</div>

<button className={'start-button ' + (this.state.signedIn === SIGNED_IN ? '' : 'hidden')} onClick={this.handleStartCodingClick} id='start-button' >Open Editor</button>
</div>
</div>
</div>

<div className={'main middle container ' + (this.state.signedIn === NOT_SIGNED_IN ? '' : 'hidden')}>

<div className={'middle large-logo-container'} aria-label='Pyret'>
Expand All @@ -216,8 +175,7 @@ class StudentDashboard extends Component {


<div className={'left'}>
{start_coding_contents}
<p><em>to start coding immediately</em></p>
<p><button onClick={this.handleStartCodingClick} id='start-button' >Open Editor</button></p><p><em>to start coding immediately</em></p>
</div>

<div className={'right'}>
Expand Down
10 changes: 2 additions & 8 deletions src/web/js/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@ import '../../css/dashboard/index.css';

ReactDOM.render(
<StudentDashboard />,
document.getElementById('root'),
() =>

// Make the "start coding" dropdowns interactible. This is probably the sort of thing that should be bundled into the React component, but I'm more familiar with this style.
$(".dropdown").each(
(i, container) => bindDropdown(container)
)
);
document.getElementById('root')
);
Loading

0 comments on commit 09bc488

Please sign in to comment.