2222 <p class =" cdx-dialog__header__subtitle" >
2323 {{ props.subject.getSchemaName() }}
2424 <a
25+ v-if =" canEditSchema"
2526 class =" ext-neowiki-subject-editor-dialog__schema-link"
2627 href =" #"
2728 @click.prevent =" isSchemaEditorOpen = true"
@@ -85,6 +86,7 @@ import { Schema } from '@/domain/Schema.ts';
8586import { Statement } from '@/domain/Statement.ts';
8687import { PropertyDefinitionList } from '@/domain/PropertyDefinitionList.ts';
8788import SchemaEditorDialog from '@/components/SchemaEditor/SchemaEditorDialog.vue';
89+ import { NeoWikiServices } from '@/NeoWikiServices.ts';
8890
8991const props = defineProps<{
9092 subject: Subject;
@@ -103,21 +105,36 @@ const open = ref( false );
103105const isSchemaEditorOpen = ref( false );
104106const subjectEditorRef = ref<SubjectEditorInstance | null>( null );
105107const loadedSchema = ref<Schema | null>( null );
108+ const canEditSchema = ref( false );
106109
107110onMounted( async () => {
108111 if ( props.subject ) {
109- try {
110- loadedSchema.value = await schemaStore.getOrFetchSchema( props.subject.getSchemaName() );
111- } catch ( error ) {
112- console.error( 'Failed to load schema:', error );
113- mw.notify(
114- `Failed to load schema ${ props.subject.getSchemaName() }: ${ error instanceof Error ? error.message : String( error ) }`,
115- { type: 'error' }
116- );
117- }
112+ await loadSchemaPermissions();
113+ await loadSchema();
118114 }
119115} );
120116
117+ async function loadSchemaPermissions(): Promise<void > {
118+ try {
119+ canEditSchema.value = await NeoWikiServices.getSchemaAuthorizer().canEditSchema( props.subject.getSchemaName() );
120+ } catch ( error ) {
121+ console.error( 'Failed to check schema permissions:', error );
122+ canEditSchema.value = false;
123+ }
124+ }
125+
126+ async function loadSchema(): Promise<void > {
127+ try {
128+ loadedSchema.value = await schemaStore.getOrFetchSchema( props.subject.getSchemaName() );
129+ } catch ( error ) {
130+ console.error( 'Failed to load schema:', error );
131+ mw.notify(
132+ `Failed to load schema ${ props.subject.getSchemaName() }: ${ error instanceof Error ? error.message : String( error ) }`,
133+ { type: 'error' }
134+ );
135+ }
136+ }
137+
121138const schemaProperties = computed( (): PropertyDefinitionList =>
122139 loadedSchema.value?.getPropertyDefinitions() ?? new PropertyDefinitionList( [] )
123140);
0 commit comments