Skip to content

Commit 306e4cc

Browse files
committed
toggle class schedule to new server
1 parent e46f221 commit 306e4cc

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

classes/ClassSchedule.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,26 @@ function adminAssets()
4141

4242
function theHTML($attributes)
4343
{
44+
// Retrieve the 'useNewServer' attribute
45+
$useNewServer = isset($attributes['useNewServer']) && $attributes['useNewServer'];
46+
47+
// Determine the base URL based on the 'useNewServer' attribute
48+
$baseURL = $useNewServer ? 'https://webapps.stg.web.aws.ucsc.edu/wcsi' : 'https://webapps.ucsc.edu/wcsi';
49+
4450
$deptOrSubAttribute = '';
4551
if ($attributes['subjectOrDept'] == 'dept') {
4652
$deptOrSubAttribute = 'department="' . $attributes['department'] . '"';
4753
} else {
4854
$deptOrSubAttribute = 'subject="' . $attributes['subject'] . '" department=""';
4955
}
5056
$markup = '
51-
<link rel="stylesheet" href="https://webapps.ucsc.edu/wcsi/css/app.css">
52-
<div id="wcsi" ' . $deptOrSubAttribute . ' >
53-
54-
</div>
57+
<link rel="stylesheet" href="' . $baseURL . '/css/app.css">
58+
<div id="wcsi" ' . $deptOrSubAttribute . '></div>
5559
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=default,Promise,Object.assign,Object.values,Array.prototype.find,Array.prototype.findIndex,Array.prototype.includes,String.prototype.includes,String.prototype.startsWith,String.prototype.endsWith"></script>
56-
<script src="https://webapps.ucsc.edu/wcsi/js/manifest.js"></script>
57-
<script src="https://webapps.ucsc.edu/wcsi/js/vendor.js"></script>
58-
<script src="https://webapps.ucsc.edu/wcsi/js/app.js"></script>';
60+
<script src="' . $baseURL . '/js/manifest.js"></script>
61+
<script src="' . $baseURL . '/js/vendor.js"></script>
62+
<script src="' . $baseURL . '/js/app.js"></script>';
63+
5964
return $markup;
6065
}
6166
}

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Plugin Name: UCSC Gutenberg Blocks
55
Description: Custom UCSC Gutenberg Blocks.
6-
Version: 1.1.23
6+
Version: 1.1.24
77
Author: UCSC
88
Author URI: https://www.ucsc.edu/
99
*/

src/blocks/ClassSchedule.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Panel, PanelBody, RadioControl } from '@wordpress/components';
1+
import { Panel, PanelBody, RadioControl, CheckboxControl } from '@wordpress/components';
22

33
import DepartmentDropdown from '../components/DepartmentDropdown';
44
import SubjectDropdown from '../components/SubjectDropdown';
@@ -23,12 +23,17 @@ const ClassSchedule = () => {
2323
subject: {
2424
type: "string"
2525
},
26+
useNewServer: {
27+
type: "boolean",
28+
default: false
29+
},
2630
},
2731
edit: ({ setAttributes, attributes }) => {
2832
const {
2933
department,
3034
subject,
31-
subjectOrDept
35+
subjectOrDept,
36+
useNewServer
3237
} = attributes;
3338

3439
let localSubjectOrDept;
@@ -42,6 +47,12 @@ const ClassSchedule = () => {
4247
[localSubjectOrDept, setLocalSubjectOrDept] = useState(subjectOrDept);
4348
}
4449

50+
const isDevEnvironment = () => {
51+
const isDevEnv = window.location.href.includes('https://wordpress-dev.ucsc.edu/')
52+
|| window.location.href.includes('wp-dev.ucsc');
53+
return isDevEnv;
54+
}
55+
4556
const options = [
4657
{ label: 'Department', value: 'dept' },
4758
{ label: 'Subject', value: 'subject' },
@@ -76,6 +87,16 @@ const ClassSchedule = () => {
7687
setAttributes={setAttributes}
7788
disabled={subjectOrDept !== "subject"}
7889
/>
90+
{isDevEnvironment() && (
91+
<>
92+
<hr />
93+
<CheckboxControl
94+
label="Use New Server for Testing"
95+
checked={useNewServer}
96+
onChange={(newUseNewServer) => setAttributes({ useNewServer: newUseNewServer })}
97+
/>
98+
</>
99+
)}
79100
</PanelBody>
80101
</Panel>
81102
</>

0 commit comments

Comments
 (0)