Skip to content

Commit

Permalink
Show model version (to managers only) on project page
Browse files Browse the repository at this point in the history
Regular users won't be shown the model version because it's a little too
technical, but project managers (and org & site admins) can see it.
  • Loading branch information
rmunn committed Sep 27, 2024
1 parent 3b5ee77 commit 30c2c20
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/src/lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia
"description": "Description",
"created_at": "Created",
"last_commit": "Last Commit",
"model_version": "Model Version",
"vernacular_langs": "Vernacular writing systems",
"analysis_langs": "Analysis writing systems",
"organization": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import FormatRetentionPolicy from '$lib/components/FormatRetentionPolicy.svelte';
import HgLogView from '$lib/components/HgLogView.svelte';
import DeleteModal from '$lib/components/modals/DeleteModal.svelte';
import t, { date, number } from '$lib/i18n';
import t, { date, NULL_LABEL, number } from '$lib/i18n';
import { z } from 'zod';
import type { PageData } from './$types';
import {
Expand All @@ -14,6 +14,7 @@
_deleteProjectUser,
_leaveProject,
_removeProjectFromOrg,
_updateFLExModelVersion,
_updateProjectLanguageList,
_updateProjectLexEntryCount,
type ProjectUser,
Expand Down Expand Up @@ -70,6 +71,7 @@
});
$: lexEntryCount = project.flexProjectMetadata?.lexEntryCount;
$: flexModelVersion = project.flexProjectMetadata?.flexModelVersion;
$: vernacularLangTags = project.flexProjectMetadata?.writingSystems?.vernacularWss;
$: analysisLangTags = project.flexProjectMetadata?.writingSystems?.analysisWss;
Expand Down Expand Up @@ -98,6 +100,13 @@
loadingEntryCount = false;
}
let loadingModelVersion = false;
async function updateModelVersion(): Promise<void> {
loadingModelVersion = true;
await _updateFLExModelVersion(project.code);
loadingModelVersion = false;
}
let loadingLanguageList = false;
async function updateLanguageList(): Promise<void> {
loadingLanguageList = true;
Expand Down Expand Up @@ -379,6 +388,20 @@
</AdminContent>
</DetailItem>
{/if}
<!-- Only show model version to project managers and admins, too technical to show to regular members -->
{#if project.type === ProjectType.FlEx && canManage}
<DetailItem title={$t('project_page.model_version')} text={flexModelVersion?.toString() ?? NULL_LABEL}>
<IconButton
slot="extras"
loading={loadingModelVersion}
icon="i-mdi-refresh"
size="btn-sm"
variant="btn-ghost"
outline={false}
on:click={updateModelVersion}
/>
</DetailItem>
{/if}
{#if project.type === ProjectType.FlEx}
<DetailItem title={$t('project_page.vernacular_langs')}>
<WritingSystemList writingSystems={vernacularLangTags} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export async function load(event: PageLoadEvent) {
}
flexProjectMetadata {
lexEntryCount
flexModelVersion
writingSystems {
vernacularWss {
tag
Expand Down Expand Up @@ -304,6 +305,33 @@ export async function _updateProjectLexEntryCount(code: string): $OpResult<Updat
return result;
}

export async function _updateFLExModelVersion(code: string): Promise<unknown> { // $OpResult<UpdateFLExModelVersionMutation> {
//language=GraphQL
const result = await getClient()
.mutation(
graphql(`
mutation UpdateFLExModelVersion($input: UpdateFLExModelVersionInput!) {
updateFLExModelVersion(input: $input) {
project {
id
flexProjectMetadata {
flexModelVersion
}
}
errors {
__typename
... on Error {
message
}
}
}
}
`),
{ input: { code } },
);
return result;
}

export async function _updateLangProjectId(code: string): $OpResult<UpdateLangProjectIdMutation> {
//language=GraphQL
const result = await getClient()
Expand Down

0 comments on commit 30c2c20

Please sign in to comment.