Skip to content

Commit

Permalink
Fix up Typescript types
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Nov 1, 2023
1 parent 0684368 commit a6820a1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
3 changes: 1 addition & 2 deletions frontend/src/lib/forms/MigrationStatusSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
export let value: ProjectMigrationStatus | "UNMIGRATED" | undefined;

Check failure on line 5 in frontend/src/lib/forms/MigrationStatusSelect.svelte

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontend/src/lib/forms/MigrationStatusSelect.svelte#L5

[@typescript-eslint/quotes] Strings must use singlequote.
export let error: string | string[] | undefined = undefined;
export let undefinedOptionLabel: string | undefined = undefined;
</script>
<div class="relative">
<Select id="migration-status" label="Migration status" bind:value {error} on:change>
<!-- No need to translate these as this is admin-only -->
<option value="">Any</option>
<option value={undefined}>Any</option>
<option value={ProjectMigrationStatus.Migrated}>Migrated</option>
<option value={ProjectMigrationStatus.Migrating}>Migrating</option>
<option value="UNMIGRATED">Unmigrated</option>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/(authenticated)/admin/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import type { AdminSearchParams, User } from './+page';
import ProjectTable from './ProjectTable.svelte';
import { getSearchParams, queryParam } from '$lib/util/query-params';
import type { ProjectType } from '$lib/gql/types';
import type { ProjectType, ProjectMigrationStatus } from '$lib/gql/types';
export let data: PageData;
$: allProjects = data.projects;
Expand All @@ -27,7 +27,7 @@
projectType: queryParam.string<ProjectType | undefined>(undefined),
userEmail: queryParam.string(undefined),
projectSearch: queryParam.string<string>(''),
migrationStatus: queryParam.string<string>(''),
migrationStatus: queryParam.string<ProjectMigrationStatus | "UNMIGRATED" | undefined>(undefined),

Check failure on line 30 in frontend/src/routes/(authenticated)/admin/+page.svelte

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontend/src/routes/(authenticated)/admin/+page.svelte#L30

[@typescript-eslint/quotes] Strings must use singlequote.
});
const { queryParamValues } = queryParams;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/(authenticated)/admin/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { PageLoadEvent } from './$types';
import { isAdmin, type LexAuthUser } from '$lib/user';
import { redirect } from '@sveltejs/kit';
import { getBoolSearchParam, getSearchParam } from '$lib/util/query-params';
import type { $OpResult, ChangeUserAccountByAdminInput, ChangeUserAccountByAdminMutation, ProjectFilterInput, ProjectType } from '$lib/gql/types';
import type { $OpResult, ChangeUserAccountByAdminInput, ChangeUserAccountByAdminMutation, ProjectFilterInput, ProjectType, ProjectMigrationStatus } from '$lib/gql/types';
import type { LoadAdminDashboardProjectsQuery, LoadAdminDashboardUsersQuery } from '$lib/gql/types';

export const _FILTER_PAGE_SIZE = 100;
Expand All @@ -15,7 +15,7 @@ export type AdminSearchParams = {
projectType: ProjectType | undefined,
userEmail: string | undefined,
projectSearch: string,
migrationStatus: string,
migrationStatus: ProjectMigrationStatus | "UNMIGRATED" | undefined,

Check failure on line 18 in frontend/src/routes/(authenticated)/admin/+page.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontend/src/routes/(authenticated)/admin/+page.ts#L18

[@typescript-eslint/quotes] Strings must use singlequote.
};

export type Project = LoadAdminDashboardProjectsQuery['projects'][number];
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/routes/(authenticated)/admin/ProjectTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async function softDeleteProject(project: Project): Promise<void> {
[ProjectMigrationStatus.PrivateRedmine]: 'i-mdi-checkbox-blank-circle-outline',
[ProjectMigrationStatus.PublicRedmine]: 'i-mdi-checkbox-blank-circle-outline',
} satisfies Record<ProjectMigrationStatus, string>;
function migrationStatusIcon(migrationStatus) {
function migrationStatusIcon(migrationStatus?: ProjectMigrationStatus) {

Check warning on line 77 in frontend/src/routes/(authenticated)/admin/ProjectTable.svelte

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

frontend/src/routes/(authenticated)/admin/ProjectTable.svelte#L77

[@typescript-eslint/explicit-function-return-type] Missing return type on function.
migrationStatus = migrationStatus ?? ProjectMigrationStatus.Unknown;
return migrationStatusTable[migrationStatus] ?? migrationStatusTable[ProjectMigrationStatus.Unknown];
}
Expand Down Expand Up @@ -160,8 +160,7 @@ async function softDeleteProject(project: Project): Promise<void> {
undefinedOptionLabel={$t('project_type.any')}/>
</div>
<div class="form-control">
<MigrationStatusSelect bind:value={$filters.migrationStatus}
undefinedOptionLabel="Any"/>
<MigrationStatusSelect bind:value={$filters.migrationStatus} />
</div>
<div class="form-control">
<label class="cursor-pointer label gap-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@
const migrationStatusIcon = {
[ProjectMigrationStatus.Migrated]: 'i-mdi-check-circle',
[ProjectMigrationStatus.Migrating]: 'loading loading-spinner loading-xs',
} satisfies Record<ProjectMigrationStatus, IconString>;
[ProjectMigrationStatus.Unknown]: undefined,
[ProjectMigrationStatus.PrivateRedmine]: undefined,
[ProjectMigrationStatus.PublicRedmine]: undefined,
} satisfies Record<ProjectMigrationStatus, IconString|undefined>;
const migrationStatusBadgeVariant = {
[ProjectMigrationStatus.Migrated]: 'badge-success',
[ProjectMigrationStatus.Migrating]: 'badge-warning',
Expand Down

0 comments on commit a6820a1

Please sign in to comment.