Skip to content

Commit f3f4794

Browse files
committed
Show instructions for authenticated/not
If not authenticated, show login button If no annotation, show instruction box If annotation or edit-highight sequence has happened, show edit card
1 parent a34e3f3 commit f3f4794

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

src/app/content/highlights/components/EditCard.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,18 @@ function LoginOrEdit({
7575
aria-label={formatMessage({id: 'i18n:highlighter:edit-note:label'})}
7676
>
7777
{
78-
(authenticated || props.shouldFocusCard || props.data?.annotation) ?
79-
<form
80-
ref={mergeRefs(fref, element)}
81-
data-analytics-region='edit-note'
82-
data-highlight-card
83-
>
84-
{authenticated ? (
85-
<ActiveEditCard props={props} element={element}
86-
/>
87-
) : (
88-
<LoginConfirmation onBlur={props.onBlur} />
89-
)}
90-
</form> :
78+
authenticated ? (
79+
(props.shouldFocusCard || props.data?.annotation) ? (
80+
<form
81+
ref={mergeRefs(fref, element)}
82+
data-analytics-region='edit-note'
83+
data-highlight-card
84+
>
85+
<ActiveEditCard props={props} element={element} />
86+
</form>
87+
) :
9188
<i>Press Enter or double-click highlight to edit highlight</i>
89+
) : <LoginConfirmation onBlur={props.onBlur} />
9290
}
9391
</div>
9492
);

src/app/content/highlights/components/__snapshots__/EditCard.spec.tsx.snap

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -182,25 +182,20 @@ exports[`EditCard matches snapshot when focused 1`] = `
182182
className="c0"
183183
role="dialog"
184184
>
185-
<form
186-
data-analytics-region="edit-note"
187-
data-highlight-card={true}
188-
>
189-
<div
190-
data-props={
191-
Object {
192-
"confirmLink": "/accounts/login?r=/",
193-
"confirmMessage": "i18n:highlighting:login:link",
194-
"data-analytics-label": "login",
195-
"data-analytics-region": "highlighting-login",
196-
"drawFocus": false,
197-
"message": "i18n:highlighting:login:prompt",
198-
"onCancel": [MockFunction],
199-
}
185+
<div
186+
data-props={
187+
Object {
188+
"confirmLink": "/accounts/login?r=/",
189+
"confirmMessage": "i18n:highlighting:login:link",
190+
"data-analytics-label": "login",
191+
"data-analytics-region": "highlighting-login",
192+
"drawFocus": false,
193+
"message": "i18n:highlighting:login:prompt",
194+
"onCancel": [MockFunction],
200195
}
201-
mock-confirmation="true"
202-
/>
203-
</form>
196+
}
197+
mock-confirmation="true"
198+
/>
204199
</div>
205200
`;
206201

@@ -278,8 +273,19 @@ exports[`EditCard matches snapshot without data 1`] = `
278273
className="c0"
279274
role="dialog"
280275
>
281-
<i>
282-
Press Enter or double-click highlight to edit highlight
283-
</i>
276+
<div
277+
data-props={
278+
Object {
279+
"confirmLink": "/accounts/login?r=/",
280+
"confirmMessage": "i18n:highlighting:login:link",
281+
"data-analytics-label": "login",
282+
"data-analytics-region": "highlighting-login",
283+
"drawFocus": false,
284+
"message": "i18n:highlighting:login:prompt",
285+
"onCancel": [MockFunction],
286+
}
287+
}
288+
mock-confirmation="true"
289+
/>
284290
</div>
285291
`;

0 commit comments

Comments
 (0)