From be8159a03330901a7515db7ce6a695551c02f442 Mon Sep 17 00:00:00 2001 From: Tim Haasdyk Date: Fri, 20 Oct 2023 11:54:17 +0200 Subject: [PATCH] Finish tus/project-reset UI changes --- .../src/lib/components/MoreSettings.svelte | 2 +- frontend/src/lib/components/TusUpload.svelte | 14 +++++++------- frontend/src/lib/i18n/locales/en.json | 8 +++++++- .../project/[project_code]/+page.svelte | 11 ++++++++--- .../project/[project_code]/+page.ts | 17 ++++++++++++++--- .../[project_code]/ResetProjectModal.svelte | 19 +++++++++++++------ 6 files changed, 50 insertions(+), 21 deletions(-) diff --git a/frontend/src/lib/components/MoreSettings.svelte b/frontend/src/lib/components/MoreSettings.svelte index 0d6b8803d..ec1b93bec 100644 --- a/frontend/src/lib/components/MoreSettings.svelte +++ b/frontend/src/lib/components/MoreSettings.svelte @@ -7,7 +7,7 @@
{$t('more_settings.title')}
-
+
diff --git a/frontend/src/lib/components/TusUpload.svelte b/frontend/src/lib/components/TusUpload.svelte index 643675b4c..4c4b4cd5d 100644 --- a/frontend/src/lib/components/TusUpload.svelte +++ b/frontend/src/lib/components/TusUpload.svelte @@ -27,13 +27,13 @@ let status = UploadStatus.NoFile; let percent = 0; - let error: string | undefined = undefined; let fileError: string | undefined = undefined; + let uploadError: string | undefined = undefined; let upload: Upload | undefined; const maxUploadChunkSizeMb = parseInt(env.PUBLIC_TUS_CHUNK_SIZE_MB); function fileSelected(e: Event): void { - error = fileError = upload = undefined; + uploadError = fileError = upload = undefined; status = UploadStatus.NoFile; let inputElement = e.target as HTMLInputElement; if (!inputElement.files?.length) return; @@ -63,10 +63,10 @@ status = UploadStatus.Error; const errorCode = getErrorCode(err); if (errorCode !== 'unknown') { - error = $t('tus.server_error_codes.' + errorCode); + uploadError = $t('tus.server_error_codes.' + errorCode); return; } - error = err.message; + uploadError = err.message; }, onShouldRetry: (err) => { //probably won't do anything as this is what the library does already, more to make ts happy and to avoid breaking if the library changes it's implementation @@ -131,14 +131,14 @@ on:cancel|stopPropagation on:change={fileSelected}/> - +
-

Upload progress

- +

{$t('tus.upload_progress')}

+
diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index 96ae08aa7..073c3cbf7 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -166,19 +166,24 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia "i_have_working_backup": "I have a working backup", "next": "Next", "back": "Back", + "download_instruction": "First, download a backup of the project that you can use to restore it in step 3:", "download_button": "Download project backup", "confirm_downloaded": "I confirm that I have downloaded a backup of the project and verified that it works. I am ready to completely reset/delete the contents of the project repository.", - "confirm_downloaded_error": "Please check the box to confirm you have downloaded the backup file", + "confirm_downloaded_error": "Please confirm you have downloaded a backup", "confirm_project_code": "Enter project code to confirm reset", "confirm_project_code_error": "Please type the project code to confirm reset", "reset_project_notification": "Successfully reset project {code}", + "upload_instruction": "The project repository was successfully reset. Now upload a zip file to restore it:", "upload_project": "Upload Project", "select_zip": "Project zip file", "should_only_contain_hg": "Should only contain the .hg folder at the root", + "reset_success": "Project successfully reset.", "backup_step": "Backup", "reset_step": "Reset", "restore_step": "Restore", "finished_step": "Finished", + "reset_in_progress": "Project Reset in progress", + "click_to_continue": "Click to continue", }, "notifications": { "role_change": "Project role of {name} set to {role}.", @@ -345,6 +350,7 @@ the [Linguistics Institute at Payap University](https://li.payap.ac.th/) in Chia }, "tus": { "upload": "Upload", + "upload_progress": "Upload progress", "status": "Status: {status, select, NoFile {No file} Ready {Ready} Error {Error} Uploading {Uploading} Paused {Paused} Complete {Complete} other {Unknown}}", "zip_only": "Only .zip files are allowed", "no_file_selected": "Please choose a file", diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte index 372faff84..b66732704 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/+page.svelte @@ -251,8 +251,13 @@ {migrationStatusTable[migrationStatus]} {/if} {#if project.resetStatus === ResetStatus.InProgress} - Project Reset in progress - + {/if}
@@ -352,7 +357,7 @@ {$t('delete_project_modal.submit')} - diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts b/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts index 42a26a7b6..44d01c653 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts +++ b/frontend/src/routes/(authenticated)/project/[project_code]/+page.ts @@ -14,6 +14,7 @@ import type { import { getClient, graphql } from '$lib/gql'; import type { PageLoadEvent } from './$types'; +import { invalidate } from '$app/navigation'; type Project = NonNullable; export type ProjectUser = Project['users'][number]; @@ -32,7 +33,7 @@ export async function load(event: PageLoadEvent) { description type migrationStatus - resetStatus + resetStatus lastCommit createdDate retentionPolicy @@ -180,13 +181,21 @@ export async function _deleteProjectUser(projectId: string, userId: string): $Op return result; } -export async function _refreshProjectStatus(projectCode: string): Promise { +export async function _refreshProjectMigrationStatusAndRepoInfo(projectCode: string): Promise { const result = await getClient().query(graphql(` query refreshProjectStatus($projectCode: String!) { - projectByCode(code: $projectCode){ + projectByCode(code: $projectCode) { id resetStatus migrationStatus + lastCommit + changesets { + node + parents + date + user + desc + } } } `), { projectCode }, { requestPolicy: 'network-only' }); @@ -195,4 +204,6 @@ export async function _refreshProjectStatus(projectCode: string): Promise // this should be meaningless, but just in case and it makes the linter happy throw result.error; } + + await invalidate(`project:${projectCode}`); } diff --git a/frontend/src/routes/(authenticated)/project/[project_code]/ResetProjectModal.svelte b/frontend/src/routes/(authenticated)/project/[project_code]/ResetProjectModal.svelte index 6a625e33e..69922c059 100644 --- a/frontend/src/routes/(authenticated)/project/[project_code]/ResetProjectModal.svelte +++ b/frontend/src/routes/(authenticated)/project/[project_code]/ResetProjectModal.svelte @@ -9,7 +9,9 @@ import Form from '$lib/forms/Form.svelte'; import TusUpload from '$lib/components/TusUpload.svelte'; import {ResetStatus} from '$lib/gql/generated/graphql'; - import {_refreshProjectStatus} from './+page'; + import {_refreshProjectMigrationStatusAndRepoInfo} from './+page'; + import { scale } from 'svelte/transition'; + import { bounceIn } from 'svelte/easing'; enum ResetSteps { Download, @@ -52,14 +54,14 @@ const resetResponse = await fetch(url, {method: 'post'}); //we should do the reset via a mutation, but this is easier for now //we need to refresh the status so if the admin closes the dialog they can resume back where they left off. - await _refreshProjectStatus(code); + await _refreshProjectMigrationStatusAndRepoInfo(code); if (resetResponse.ok) { nextStep(); } }); async function uploadComplete(): Promise { - await _refreshProjectStatus(code); + await _refreshProjectMigrationStatusAndRepoInfo(code); nextStep(); } @@ -83,7 +85,9 @@