forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuggestedChartRevisionApproverPage.tsx
1430 lines (1376 loc) · 62.3 KB
/
SuggestedChartRevisionApproverPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import * as React from "react"
import { observer } from "mobx-react"
import { observable, computed, action, runInAction } from "mobx"
import { Link } from "react-router-dom"
import { Base64 } from "js-base64"
import { format } from "timeago.js"
import Select from "react-select"
import classNames from "classnames"
import { Bounds } from "../clientUtils/Bounds"
import { getStylesForTargetHeight } from "../clientUtils/react-select"
import { SortOrder } from "../clientUtils/owidTypes"
import { Grapher } from "../grapher/core/Grapher"
import { TextAreaField, NumberField, RadioGroup, Toggle } from "./Forms"
import { PostReference } from "./ChartEditor"
import { AdminLayout } from "./AdminLayout"
import { SuggestedChartRevisionStatusIcon } from "./SuggestedChartRevisionList"
import { AdminAppContext, AdminAppContextType } from "./AdminAppContext"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faMobile } from "@fortawesome/free-solid-svg-icons/faMobile"
import { faDesktop } from "@fortawesome/free-solid-svg-icons/faDesktop"
import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons/faExternalLinkAlt"
import { faAngleLeft } from "@fortawesome/free-solid-svg-icons/faAngleLeft"
import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight"
import { faAngleDoubleLeft } from "@fortawesome/free-solid-svg-icons/faAngleDoubleLeft"
import { faAngleDoubleRight } from "@fortawesome/free-solid-svg-icons/faAngleDoubleRight"
import { faSortAlphaDown } from "@fortawesome/free-solid-svg-icons/faSortAlphaDown"
import { faSortAlphaUpAlt } from "@fortawesome/free-solid-svg-icons/faSortAlphaUpAlt"
import { faRandom } from "@fortawesome/free-solid-svg-icons/faRandom"
import {
VisionDeficiency,
VisionDeficiencySvgFilters,
VisionDeficiencyDropdown,
VisionDeficiencyEntity,
} from "./VisionDeficiencies"
import {
SuggestedChartRevisionSerialized,
SuggestedChartRevisionStatus,
} from "./SuggestedChartRevision"
@observer
export class SuggestedChartRevisionApproverPage extends React.Component<{
suggestedChartRevisionId?: number
}> {
@observable.ref suggestedChartRevision?: SuggestedChartRevisionSerialized
@observable.ref originalGrapherElement?: JSX.Element
@observable.ref suggestedGrapherElement?: JSX.Element
@observable.ref existingGrapherElement?: JSX.Element
@observable.ref chartReferences: PostReference[] = []
@observable rowNum: number = 1
@observable numTotalRows: number = 0
@observable decisionReasonInput?: string = ""
@observable showReadme: boolean = false
@observable showSettings: boolean = false
@observable showPendingOnly: boolean = true
@observable showExistingChart: boolean = false
@observable previewMode: string = "desktop"
@observable desktopPreviewSize: string = "normal"
@observable sortBy: string = "updatedAt"
@observable sortOrder: SortOrder = SortOrder.desc
@observable previewSvgOrJson: string = "svg"
@observable simulateVisionDeficiency?: VisionDeficiency
@observable private _isGraphersSet = false
static contextType = AdminAppContext
context!: AdminAppContextType
@computed get admin() {
return this.context.admin
}
@computed get offset() {
return this.rowNumValid - 1
}
@computed get prevBtnIsDisabled() {
return !this._isGraphersSet || this.rowNumValid <= 1
}
@computed get nextBtnIsDisabled() {
return !this._isGraphersSet || this.rowNumValid >= this.numTotalRows
}
@computed get randomBtnIsDisabled() {
return !this._isGraphersSet || this.numTotalRows <= 1
}
@computed get grapherBounds() {
let bounds
if (this.previewMode === "mobile") {
bounds = new Bounds(0, 0, 360, 500)
} else {
if (this.desktopPreviewSize === "small") {
bounds = new Bounds(0, 0, 600, 450)
} else {
bounds = new Bounds(0, 0, 800, 600)
}
}
return bounds
}
@computed get rowNumValid() {
return Math.max(Math.min(this.rowNum, this.numTotalRows), 1)
}
@computed get updateButtonsIsDisabled() {
return !this._isGraphersSet
}
@computed get approveButtonIsDisabled() {
return (
this.updateButtonsIsDisabled ||
(this.suggestedChartRevision &&
!this.suggestedChartRevision.canApprove)
)
}
@computed get rejectButtonIsDisabled() {
return (
this.updateButtonsIsDisabled ||
(this.suggestedChartRevision &&
!this.suggestedChartRevision.canReject)
)
}
@computed get flagButtonIsDisabled() {
return (
this.updateButtonsIsDisabled ||
(this.suggestedChartRevision &&
!this.suggestedChartRevision.canFlag)
)
}
@computed get listMode() {
const { suggestedChartRevisionId } = this.props
return !suggestedChartRevisionId
}
@action.bound async refresh() {
this.clearDecisionReasonInput()
await this.fetchGraphers()
await this.fetchRefs()
}
@action.bound async fetchGraphers() {
const { admin } = this.context
const { suggestedChartRevisionId } = this.props
if (suggestedChartRevisionId === undefined) {
const json = await admin.getJSON("/api/suggested-chart-revisions", {
limit: 1,
offset: this.offset,
status:
this.listMode && this.showPendingOnly
? SuggestedChartRevisionStatus.pending
: null,
sortBy: this.sortBy,
sortOrder: this.sortOrder,
})
runInAction(() => {
this.numTotalRows = json.numTotalRows as number
this.suggestedChartRevision = json
.suggestedChartRevisions[0] as SuggestedChartRevisionSerialized
})
} else {
const json = await admin.getJSON(
`/api/suggested-chart-revisions/${suggestedChartRevisionId}`
)
this.suggestedChartRevision = json.suggestedChartRevision
}
this.decisionReasonInput = this.suggestedChartRevision
? this.suggestedChartRevision.decisionReason ?? ""
: ""
this.rerenderGraphers()
}
@action.bound async rerenderGraphers() {
this._isGraphersSet = false
setTimeout(() => {
if (this.suggestedChartRevision) {
this._isGraphersSet = true
}
}, 0)
}
@action.bound async fetchRefs() {
const chartId = this.suggestedChartRevision?.chartId
const { admin } = this.context
const json =
chartId === undefined
? []
: await admin.getJSON(`/api/charts/${chartId}.references.json`)
this.chartReferences = json.references || []
}
@action.bound onApproveSuggestedChartRevision() {
this.updateSuggestedChartRevision(
SuggestedChartRevisionStatus.approved,
this.decisionReasonInput
)
}
@action.bound onRejectSuggestedChartRevision() {
this.updateSuggestedChartRevision(
SuggestedChartRevisionStatus.rejected,
this.decisionReasonInput
)
}
@action.bound onFlagSuggestedChartRevision() {
this.updateSuggestedChartRevision(
SuggestedChartRevisionStatus.flagged,
this.decisionReasonInput
)
}
@action.bound async updateSuggestedChartRevision(
status: SuggestedChartRevisionStatus,
decisionReason: string | undefined
) {
this._isGraphersSet = false
if (!this.suggestedChartRevision) return
const { admin } = this.context
const data = { status, decisionReason }
await admin.requestJSON(
`/api/suggested-chart-revisions/${this.suggestedChartRevision.id}/update`,
data,
"POST"
)
// KLUDGE to prevent error that otherwise occurs when this.refresh() is
// called when the user is viewing the very last suggested revision.
if (status !== SuggestedChartRevisionStatus.pending) {
this.numTotalRows -= 1
}
this.refresh()
}
@action.bound onFirst() {
if (!this.prevBtnIsDisabled) {
this.rowNum = 1
this.refresh()
}
}
@action.bound onPrev() {
if (!this.prevBtnIsDisabled) {
this.rowNum = this.rowNumValid - 1
this.refresh()
}
}
@action.bound onNext() {
if (!this.nextBtnIsDisabled) {
this.rowNum = this.rowNumValid + 1
this.refresh()
}
}
@action.bound onLast() {
if (!this.nextBtnIsDisabled) {
this.rowNum = this.numTotalRows
this.refresh()
}
}
@action.bound onRandom() {
if (!this.randomBtnIsDisabled) {
this.rowNum = Math.floor(Math.random() * this.numTotalRows + 1)
this.refresh()
}
}
@action.bound onDecisionReasonInput(input: string) {
this.decisionReasonInput = input
}
@action.bound clearDecisionReasonInput() {
this.decisionReasonInput = ""
}
@action.bound onRowNumInput(input: number | undefined) {
if (input === undefined || input === null) {
return
}
this.rowNum = input
setTimeout(() => {
this.refresh()
}, 100)
}
@action.bound onChangeDesktopPreviewSize(value: string) {
this.desktopPreviewSize = value
this.rerenderGraphers()
}
@action.bound onChangePreviewSvgOrJson(value: string) {
this.previewSvgOrJson = value
this.rerenderGraphers()
}
@action.bound onSortByChange(selected: any) {
this.sortBy = selected.value
this.refresh()
}
@action.bound onSortOrderChange(value: SortOrder) {
this.sortOrder = value
this.refresh()
}
@action.bound onToggleShowPendingOnly(value: boolean) {
this.showPendingOnly = value
this.refresh()
}
@action.bound onToggleShowExistingChart(value: boolean) {
this.showExistingChart = value
// this.refresh()
}
@action.bound onToggleShowReadme() {
this.showReadme = !this.showReadme
}
@action.bound onToggleShowSettings() {
this.showSettings = !this.showSettings
}
componentDidMount() {
this.refresh().then(() => {
this.admin.loadingIndicatorSetting = "off"
})
}
render() {
return (
<AdminLayout
title="Approval tool for suggested chart revisions"
noSidebar
>
<main className="SuggestedChartRevisionApproverPage">
<h3>
Approval tool for suggested chart revisions
<Link
to="/suggested-chart-revisions"
className="btn btn-outline-primary"
style={{ marginLeft: "20px" }}
>
View all suggested revisions
</Link>
</h3>
<p>
Use this tool to approve or reject chart revisions that
have been suggested by an automated bulk update script.
The purpose of this tool is to provide a layer of
quality assurance for our charts that are updated by
automated scripts. This tool is a work in progress.
Start a thread in{" "}
<a
href="https://owid.slack.com/messages/tech-issues/"
rel="noreferrer"
target="_blank"
>
#tech-issues
</a>{" "}
if you find a bug, want to request a feature, or have
other feedback.
</p>
<p className="text-danger">
WARNING: This tool is new and may contain bugs that
cause unexpected behavior. Use with caution.
</p>
{this.renderReadme()}
{this.renderSettings()}
{this.numTotalRows > 0 || !this.listMode ? (
this.renderApprovalTool()
) : (
<div style={{ paddingBottom: 20 }}>
0 pending chart revisions found. All suggested chart
revisions have already been approved, flagged, or
rejected. If you wish to see all suggested chart
revisions, either uncheck the{" "}
<i>Show "pending" revisions only</i> box in the
Settings tab or{" "}
<Link to="/suggested-chart-revisions">
click here
</Link>{" "}
to view a complete list of suggested chart
revisions.
</div>
)}
</main>
</AdminLayout>
)
}
renderApprovalTool() {
const status =
this.suggestedChartRevision && this.suggestedChartRevision.status
return (
<React.Fragment>
{this.renderControls()}
<h3>
Suggested revision{" "}
{this.suggestedChartRevision
? this.suggestedChartRevision.id
: ""}
<span
className={classNames({
"text-primary":
status ===
SuggestedChartRevisionStatus.approved,
"text-danger":
status ===
SuggestedChartRevisionStatus.rejected,
"text-warning":
status === SuggestedChartRevisionStatus.flagged,
"text-secondary":
status === SuggestedChartRevisionStatus.pending,
})}
style={{ marginLeft: "20px" }}
>
{status ? (
<>
<SuggestedChartRevisionStatusIcon
status={status}
/>{" "}
<i>
{status.charAt(0).toUpperCase() +
status.slice(1)}
</i>
</>
) : (
""
)}
</span>
</h3>
{this.renderGraphers()}
{this.renderMeta()}
</React.Fragment>
)
}
renderReadme() {
return (
<div className="collapsible">
<h3>
README
<button
className="btn btn-outline-dark"
type="button"
onClick={this.onToggleShowReadme}
aria-expanded={this.showReadme}
title="Show/hide README"
style={{ marginLeft: "10px" }}
>
{this.showReadme ? "Hide" : "Show"}
</button>
</h3>
<div
className={`readme ${
this.showReadme ? "show" : "collapse"
}`}
>
<h5>Terminology</h5>
<ul>
<li>
<b>Suggested chart revision.</b> A suggested chart
revision is simply an amended OWID chart, but where
the amendments have not yet been applied to the
chart in question. A suggested chart revision is
housed in the <code>suggested_chart_revisions</code>{" "}
table in <code>MySQL</code>. If the suggested chart
revision gets approved, then the amendments are
applied to the chart (which overwrites and
republishes the chart).
</li>
<li>
<b>Original chart.</b> The chart as it originally
was when the suggested chart revision was created.
</li>
<li>
<b>Existing chart.</b> The chart as it currently
exists on the OWID website.
</li>
</ul>
<h5>How to use</h5>
<p>
You are shown one suggested chart revision at a time,
alongside the corresponding original chart as it was
when the suggested chart revision was created.
</p>
<p>
For each suggested revision, choose one of the following
actions:
</p>
<ol>
<li>
<b>Approve the revision</b> by clicking{" "}
<button
className="btn btn-outline-primary"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.approved
}
setColor={false}
/>{" "}
Approve
</button>
. This approves the suggestion, replacing the
original chart with the suggested chart (also
republishes the chart). Note: if a chart has been
edited since the suggested revision was created, you
will not be allowed to approve the suggested
revision.
</li>
<li>
<b>Reject the suggested revision</b> by clicking{" "}
<button
className="btn btn-outline-danger btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.rejected
}
setColor={false}
/>{" "}
Reject
</button>
. This rejects the suggestion, keeping the original
chart as it is.
</li>
<li>
<b>Flag the suggested revision</b> for further
inspection by clicking{" "}
<button
className="btn btn-outline-warning btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.flagged
}
setColor={false}
/>{" "}
Flag
</button>
.
</li>
<li>
<b>Edit the original chart</b> by clicking{" "}
<Link
className="btn btn-outline-secondary"
to=""
style={{ pointerEvents: "none" }}
>
Edit{" "}
<FontAwesomeIcon icon={faExternalLinkAlt} />
</Link>
. This opens the original chart in the chart editor.
If you save your changes to the original chart
within the chart editor, you will no longer have the
option to approve the suggested revision.
</li>
<li>
<b>
Edit the suggested chart revision as the
original chart
</b>{" "}
by clicking{" "}
<Link
className="btn btn-outline-secondary"
to=""
style={{ pointerEvents: "none" }}
>
Edit as chart [chartId]{" "}
<FontAwesomeIcon icon={faExternalLinkAlt} />
</Link>
. This opens the suggested chart revision in the
chart editor. If you make changes to the chart
within the chart editor,{" "}
<i>
your changes will overwrite the original chart,
but will NOT overwrite the suggested revision.
</i>{" "}
If you save your changes within the chart editor,
you will no longer have the option to approve the
suggested revision.
</li>
</ol>
<h5>Other useful information</h5>
<ul>
<li>
When you click the{" "}
<button
className="btn btn-outline-primary"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.approved
}
setColor={false}
/>{" "}
Approve
</button>{" "}
,{" "}
<button
className="btn btn-outline-danger btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.rejected
}
setColor={false}
/>{" "}
Reject
</button>{" "}
or{" "}
<button
className="btn btn-outline-warning btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.flagged
}
setColor={false}
/>{" "}
Flag
</button>{" "}
button, anything you write in the "Notes" text field
will be saved. You can view these saved notes in the
"Decision reason" column{" "}
<Link to="/suggested-chart-revisions">here</Link>.
If you reject or flag a suggested chart revision, it
is <i>strongly recommended</i> that you describe
your reasoning in the "Notes" field.
</li>
<li>
If a suggested revision has been approved and the
chart has not changed since the revision was
approved, then you can undo the revision by clicking
the{" "}
<button
className="btn btn-outline-danger btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.rejected
}
setColor={false}
/>{" "}
Reject
</button>{" "}
button.
</li>
<li>
If a suggested revision has been rejected and the
chart has not changed since the revision was
rejected, then you can still approve the revision by
clicking the{" "}
<button
className="btn btn-outline-primary btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.approved
}
setColor={false}
/>{" "}
Approve
</button>{" "}
button.
</li>
<li>
If one or more of the{" "}
<button
className="btn btn-outline-primary"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.approved
}
setColor={false}
/>{" "}
Approve
</button>{" "}
,{" "}
<button
className="btn btn-outline-danger btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.rejected
}
setColor={false}
/>{" "}
Reject
</button>{" "}
or{" "}
<button
className="btn btn-outline-warning btn"
style={{ pointerEvents: "none" }}
disabled={true}
>
<SuggestedChartRevisionStatusIcon
status={
SuggestedChartRevisionStatus.flagged
}
setColor={false}
/>{" "}
Flag
</button>{" "}
buttons are disabled, this is because these actions
are not allowed for the suggested revision in
question. For example, if a chart has changed since
the suggested revision was created, you will not be
allowed to approve the revision.
</li>
</ul>
</div>
</div>
)
}
renderSettings() {
return (
<div className="collapsible">
<h3>
Settings
<button
className="btn btn-outline-dark"
type="button"
aria-expanded={this.showSettings}
onClick={this.onToggleShowSettings}
title="Show/hide settings"
style={{ marginLeft: "10px" }}
>
{this.showSettings ? "Hide" : "Show"}
</button>
</h3>
<div
className={`settings ${
this.showSettings ? "show" : "collapse"
}`}
>
{this.listMode && (
<div>
<Toggle
value={this.showPendingOnly}
onValue={this.onToggleShowPendingOnly}
label='Show "pending" revisions only'
/>
</div>
)}
<div>
<Toggle
value={this.showExistingChart}
onValue={this.onToggleShowExistingChart}
label="Show existing chart (as it appears on the OWID site)"
/>
</div>
<div className="flex-row">
<div style={{ marginRight: "20px" }}>
Preview mode:
<br />
<div
className="btn-group"
data-toggle="buttons"
style={{ whiteSpace: "nowrap" }}
>
<label
className={
"btn btn-light" +
(this.previewMode === "mobile"
? " active"
: "")
}
title="Mobile preview"
>
<input
type="radio"
onChange={action(() => {
this.previewMode = "mobile"
this.rerenderGraphers()
})}
name="previewSize"
id="mobile"
checked={this.previewMode === "mobile"}
/>{" "}
<FontAwesomeIcon icon={faMobile} />
</label>
<label
className={
"btn btn-light" +
(this.previewMode === "desktop"
? " active"
: "")
}
title="Desktop preview"
>
<input
onChange={action(() => {
this.previewMode = "desktop"
this.rerenderGraphers()
})}
type="radio"
name="previewSize"
id="desktop"
checked={this.previewMode === "desktop"}
/>{" "}
<FontAwesomeIcon icon={faDesktop} />
</label>
</div>
</div>
<div>
Preview size (desktop only):
<RadioGroup
options={[
{ label: "Small", value: "small" },
{ label: "Normal", value: "normal" },
]}
value={this.desktopPreviewSize}
onChange={this.onChangeDesktopPreviewSize}
/>
</div>
</div>
{this.listMode && (
<div className="flex-row">
<div style={{ width: 250, marginRight: "10px" }}>
Sort by:{" "}
<Select
options={[
{
value: "id",
label: "Suggestion ID",
},
{
value: "updatedAt",
label: "Date suggestion last updated",
},
{
value: "createdAt",
label: "Date suggestion created",
},
{
value: "status",
label: "Suggestion status",
},
{
value: "suggestedReason",
label: "Reason suggested",
},
{
value: "chartUpdatedAt",
label: "Date chart last updated",
},
{
value: "chartCreatedAt",
label: "Date chart created",
},
{
value: "chartId",
label: "Chart ID",
},
{
value: "variableId",
label: "Variable ID",
},
]}
onChange={this.onSortByChange}
defaultValue={{
value: "updatedAt",
label: "Date suggestion last updated",
}}
menuPlacement="top"
styles={getStylesForTargetHeight(30)}
/>
</div>
<div>
<br />
<div
className="btn-group"
data-toggle="buttons"
style={{ whiteSpace: "nowrap" }}
>
<label
className={
"btn btn-light" +
(this.sortOrder === SortOrder.asc
? " active"
: "")
}
title="Sort ascending"
>
<input
type="radio"
onChange={() =>
this.onSortOrderChange(
SortOrder.asc
)
}
name="sortOrder"
id="asc"
checked={
this.sortOrder === SortOrder.asc
}
/>{" "}
<FontAwesomeIcon
icon={faSortAlphaDown}
/>
</label>
<label
className={
"btn btn-light" +
(this.sortOrder === SortOrder.desc
? " active"
: "")
}
title="Sort descending"
>
<input
onChange={() =>
this.onSortOrderChange(
SortOrder.desc
)
}
type="radio"
name="sortOrder"
id="desc"
checked={
this.sortOrder ===
SortOrder.desc
}
/>{" "}
<FontAwesomeIcon
icon={faSortAlphaUpAlt}
/>
</label>
</div>
</div>
</div>
)}
<div>
View SVG or JSON?
<RadioGroup
options={[
{ label: "SVG", value: "svg" },
{ label: "JSON", value: "json" },
]}
value={this.previewSvgOrJson}
onChange={this.onChangePreviewSvgOrJson}
/>
</div>
<div style={{ width: 250 }}>
Emulate vision deficiency:{" "}
<VisionDeficiencyDropdown
onChange={action(
(option: VisionDeficiencyEntity) =>
(this.simulateVisionDeficiency =
option.deficiency)
)}
/>
<VisionDeficiencySvgFilters />
</div>
</div>
</div>
)
}
renderGraphers() {
return (
<React.Fragment>
<div className="charts-view">
<div
className="chart-view"
style={{
height: this.grapherBounds.height + 100,