Skip to content

Commit 2e03334

Browse files
Pietroemettely
authored andcommitted
Fix #133 speaker not editable in read only mode (#207)
* fixes issue #133 * Working if isEditable is true can edit speaker label, if false, cannot * adjusted CSS accordingly
1 parent 0859ca9 commit 2e03334

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

packages/components/timed-text-editor/SpeakerLabel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import style from './WrapperBlock.module.css';
99
class SpeakerLabel extends PureComponent {
1010
render() {
1111
return (
12-
<span className={ style.speaker }
12+
<span className={ this.props.isEditable? [style.speaker, style.speakerEditable].join(' '): [style.speaker, style.speakerNotEditable].join(' ')}
1313
title={ this.props.name }
14-
onClick={ this.props.handleOnClickEdit }>
14+
onClick={ this.props.isEditable? this.props.handleOnClickEdit: null } >
1515
<span className={ style.EditLabel }>
1616
<FontAwesomeIcon icon={ faUserEdit } />
1717
</span>

packages/components/timed-text-editor/WrapperBlock.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class WrapperBlock extends React.Component {
5555
return true;
5656
}
5757

58+
if (nextProps.blockProps.isEditable !== this.props.blockProps.isEditable) {
59+
return true;
60+
}
61+
5862
return false;
5963
};
6064

@@ -125,6 +129,7 @@ class WrapperBlock extends React.Component {
125129
<SpeakerLabel
126130
name={ this.state.speaker }
127131
handleOnClickEdit={ this.handleOnClickEdit }
132+
isEditable={this.props.blockProps.isEditable}
128133
/>
129134
);
130135

packages/components/timed-text-editor/WrapperBlock.module.css

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ to get text out of component with timecodes and speaker names in the interim */
5454
}
5555
}
5656

57+
58+
.time {
59+
font-weight: lighter;
60+
cursor: pointer;
61+
justify-self: start;
62+
}
63+
64+
.time:hover {
65+
text-decoration: underline;
66+
67+
/* color: blue; */
68+
}
69+
70+
.speakerEditable {
71+
cursor: pointer;
72+
}
73+
74+
.speakerNotEditable {
75+
cursor: no-drop;
76+
}
77+
78+
.EditLabel {
79+
margin-right: 0.5em;
80+
}
81+
82+
5783
/* Mobile devices */
5884
@media (max-width: 768px) {
5985

@@ -92,23 +118,3 @@ to get text out of component with timecodes and speaker names in the interim */
92118
/* clear: right; */
93119
}
94120
}
95-
96-
.time {
97-
font-weight: lighter;
98-
cursor: pointer;
99-
justify-self: start;
100-
}
101-
102-
.time:hover {
103-
text-decoration: underline;
104-
105-
/* color: blue; */
106-
}
107-
108-
.speaker {
109-
cursor: pointer;
110-
}
111-
112-
.EditLabel {
113-
margin-right: 0.5em;
114-
}

packages/components/timed-text-editor/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class TimedTextEditor extends React.Component {
4343
if (
4444
prevProps.timecodeOffset !== this.props.timecodeOffset ||
4545
prevProps.showSpeakers !== this.props.showSpeakers ||
46-
prevProps.showTimecodes !== this.props.showTimecodes
46+
prevProps.showTimecodes !== this.props.showTimecodes ||
47+
prevProps.isEditable !== this.props.isEditable
4748
) {
4849
// forcing a re-render is an expensive operation and
4950
// there might be a way of optimising this at a later refactor (?)
@@ -531,6 +532,7 @@ class TimedTextEditor extends React.Component {
531532
setEditorNewContentState={this.setEditorNewContentState}
532533
onWordClick={this.onWordClick}
533534
handleAnalyticsEvents={this.props.handleAnalyticsEvents}
535+
isEditable={this.props.isEditable}
534536
/>
535537
</section>
536538
);
@@ -608,7 +610,8 @@ class CustomEditor extends React.Component {
608610
editorState: this.props.editorState,
609611
setEditorNewContentState: this.props.setEditorNewContentState,
610612
onWordClick: this.handleWordClick,
611-
handleAnalyticsEvents: this.props.handleAnalyticsEvents
613+
handleAnalyticsEvents: this.props.handleAnalyticsEvents,
614+
isEditable: this.props.isEditable
612615
}
613616
};
614617
};
@@ -619,6 +622,10 @@ class CustomEditor extends React.Component {
619622
return true;
620623
}
621624

625+
if (nextProps.isEditable !== this.props.isEditable) {
626+
return true;
627+
}
628+
622629
return false;
623630
}
624631

0 commit comments

Comments
 (0)