Skip to content

Commit 98c877e

Browse files
committed
additional refactor and fix tests
1 parent c23fb69 commit 98c877e

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/components/header/SourceHeaderControls.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export default class SourceHeaderControls extends WebComponent {
2424

2525
private setEditable() {
2626
const sourcePaneState = this.sourceContext?.sourcePaneState
27-
if (!sourcePaneState || sourcePaneState.broken) return
27+
const { canEdit } = this.sourceContext?.headerMetadata ?? { canEdit: false }
28+
const subject = this.sourceContext?.subject
29+
if (!sourcePaneState || !canEdit || sourcePaneState.broken || (subject && subject.endsWith('/'))) return
30+
2831
this.sourceContext?.setEditing?.()
2932
}
3033

src/components/source-provider/SourceProvider.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,14 @@ export default class SourceProvider extends WebComponent {
102102
private accessor editorCard: SourceEditorCard | null = null
103103

104104
private loadContentAndMetadata = async () => {
105-
if (!this.context) {
106-
throw new Error('The element is missing the required `context` property.')
107-
}
108-
if (!this.subject) {
109-
throw new Error('The element is missing the required `subject` property.')
110-
}
111105
try {
106+
if (!this.context) {
107+
throw new Error('The element is missing the required `context` property.')
108+
}
109+
if (!this.subject) {
110+
throw new Error('The element is missing the required `subject` property.')
111+
}
112+
112113
const { content, metadata } = await fetchContentAndMetadata(this.context.session.store as any, this.subject)
113114
this.originalContent = content
114115
this.updateEditorMetadata(metadata)

0 commit comments

Comments
 (0)