Skip to content

Commit

Permalink
Merge pull request #19680 from jmchilton/fix_tsc_4
Browse files Browse the repository at this point in the history
Yet More Vue Typing Error Fixes
  • Loading branch information
jmchilton authored Feb 26, 2025
2 parents 49fa860 + 79e97c3 commit ca4faaa
Show file tree
Hide file tree
Showing 49 changed files with 143 additions and 104 deletions.
4 changes: 4 additions & 0 deletions client/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export type DatasetCollectionAttributes = components["schemas"]["DatasetCollecti

export type ConcreteObjectStoreModel = components["schemas"]["ConcreteObjectStoreModel"];

export interface SelectableObjectStore extends ConcreteObjectStoreModel {
object_store_id: string;
}

/**
* A SubCollection is a DatasetCollectionElement of type `dataset_collection`
* with additional information to simplify its handling.
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Common/ObjectStoreSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface RelocateProps {
defineProps<RelocateProps>();
const emit = defineEmits<{
(e: "select", value: string | undefined | null): void;
(e: "select", value: string | null): void;
}>();
const toWhat = "Datasets will be filtered to those stored in";
Expand All @@ -28,7 +28,7 @@ const toWhat = "Datasets will be filtered to those stored in";
class="filter-target-object-store-select-button"
variant="outline-primary"
:object-store="objectStore"
@click="emit('select', objectStore.object_store_id)" />
@click="emit('select', objectStore.object_store_id ?? null)" />
</b-button-group>
<ObjectStoreSelectButtonDescribePopover
v-for="objectStore in objectStores"
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Common/PublishedItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Item {
name: string;
model_class?: string;
owner?: string;
username?: string;
username?: string | null;
email_hash?: string;
author_deleted?: boolean;
tags?: string[];
Expand Down
15 changes: 4 additions & 11 deletions client/src/components/Dataset/DatasetStorage/RelocateDialog.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import { type ConcreteObjectStoreModel } from "@/api";
import { type ConcreteObjectStoreModel, type SelectableObjectStore } from "@/api";
import ObjectStoreSelectButton from "@/components/ObjectStore/ObjectStoreSelectButton.vue";
import ObjectStoreSelectButtonDescribePopover from "@/components/ObjectStore/ObjectStoreSelectButtonDescribePopover.vue";
interface RelocateProps {
fromObjectStore: ConcreteObjectStoreModel;
targetObjectStores: ConcreteObjectStoreModel[];
targetObjectStores: SelectableObjectStore[];
}
defineProps<RelocateProps>();
Expand All @@ -16,15 +16,8 @@ const emit = defineEmits<{
(e: "closeModal"): void;
}>();
function relocate(objectStoreId: string | undefined | null) {
if (objectStoreId) {
// all the target object stores will have an object store id - they were
// generated thusly. But the type system doesn't know this. So this function
// wraps the emit.
emit("relocate", objectStoreId);
} else {
console.error("Serious logic problem, this branch should be unreachable.");
}
function relocate(objectStoreId: string) {
emit("relocate", objectStoreId);
}
const fromWhat = "This dataset location is";
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/Dataset/DatasetStorage/RelocateLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed, ref } from "vue";
import { type ConcreteObjectStoreModel, type DatasetStorageDetails } from "@/api";
import { type ConcreteObjectStoreModel, type DatasetStorageDetails, type SelectableObjectStore } from "@/api";
import { updateObjectStore } from "@/api/objectStores";
import { useObjectStoreStore } from "@/stores/objectStoreStore";
Expand Down Expand Up @@ -39,7 +39,7 @@ const currentObjectStore = computed<ConcreteObjectStoreModel | null>(() => {
return filtered && filtered.length > 0 ? (filtered[0] as ConcreteObjectStoreModel) : null;
});
const validTargets = computed<ConcreteObjectStoreModel[]>(() => {
const validTargets = computed<SelectableObjectStore[]>(() => {
const isLoadedVal = isLoaded.value;
const objectStores = selectableObjectStores.value;
const currentObjectStoreId = props.datasetStorageDetails.object_store_id;
Expand All @@ -57,13 +57,13 @@ const validTargets = computed<ConcreteObjectStoreModel[]>(() => {
if (!currentDevice) {
return [];
}
const validTargets: ConcreteObjectStoreModel[] = objectStores.filter(
const validTargets = objectStores.filter(
(objectStore) =>
objectStore.device == currentDevice &&
objectStore.object_store_id &&
objectStore.object_store_id != currentObjectStoreId
);
return validTargets as ConcreteObjectStoreModel[];
) as SelectableObjectStore[];
return validTargets;
});
const relocatable = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/FilesDialog/FilesDialog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const initComponent = async (props: { multiple: boolean; mode?: string }) => {
);

const testingPinia = createTestingPinia({ stubActions: false });
const wrapper = mount(FilesDialog, {
const wrapper = mount(FilesDialog as object, {
localVue,
propsData: { ...props, modalStatic: true },
pinia: testingPinia,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ARCHIVE_HISTORY_BTN = "#archive-history-btn";
const CONFIRM_DELETE_CHECKBOX = "[type='checkbox']";

async function mountComponentWithHistory(history: HistorySummary) {
const wrapper = shallowMount(HistoryArchiveExportSelector, {
const wrapper = shallowMount(HistoryArchiveExportSelector as object, {
propsData: { history },
localVue,
stubs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function mountComponentWithHistory(history?: HistorySummary) {
// this is a work-around
jest.spyOn(historyStore, "getHistoryById").mockImplementation((_history_id: string) => history as HistorySummary);

const wrapper = shallowMount(HistoryArchiveWizard, {
const wrapper = shallowMount(HistoryArchiveWizard as object, {
propsData: { historyId: TEST_HISTORY_ID },
localVue,
pinia,
Expand Down
14 changes: 9 additions & 5 deletions client/src/components/History/Content/GenericElement.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<script setup lang="ts">
import { type PropType, ref, set } from "vue";
import { type components } from "@/api/schema";
import { type DCESummary, type DCObject } from "@/api";
import ContentItem from "./ContentItem.vue";
defineProps({
dsc: {
type: Object as PropType<components["schemas"]["DCObject"]>,
type: Object as PropType<DCObject>,
required: true,
},
});
const expandCollections = ref({});
const expandDatasets = ref({});
const expandCollections = ref<Record<string, boolean>>({});
const expandDatasets = ref<Record<string, boolean>>({});
function toggle(expansionMap: Record<string, boolean>, itemId: string) {
set(expansionMap, itemId, !expansionMap[itemId]);
}
function childObject(item: DCESummary): DCObject {
return item.object as DCObject;
}
</script>

<template>
Expand All @@ -33,7 +37,7 @@ function toggle(expansionMap: Record<string, boolean>, itemId: string) {
@update:expand-dataset="toggle(expandDatasets, item.id)"
@view-collection="toggle(expandCollections, item.id)" />
<div v-if="!!expandCollections[item.id]" class="mx-3">
<GenericElement :dsc="item.object" />
<GenericElement :dsc="childObject(item)" />
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions client/src/components/History/Content/GenericItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default {
case "dce":
return "DatasetCollectionElementProvider";
default:
// Failed on LDDAs https://github.com/galaxyproject/galaxy/issues/19687
throw Error(`Unknown element src ${this.itemSrc}`);
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script setup lang="ts">
import { computed } from "vue";
import { type HDCADetailed } from "@/api";
import { type HDCASummary } from "@/api";
import { JobStateSummary } from "@/components/History/Content/Collection/JobStateSummary.js";
import CollectionDescription from "@/components/History/Content/Collection/CollectionDescription.vue";
import DetailsLayout from "@/components/History/Layout/DetailsLayout.vue";
interface Props {
dsc: HDCADetailed;
dsc: HDCASummary;
writeable: boolean;
}
Expand All @@ -21,7 +21,7 @@ const jobState = computed(() => {

<template>
<DetailsLayout
:name="dsc.name"
:name="dsc.name ?? ''"
:tags="dsc.tags"
:writeable="writeable"
:show-annotation="false"
Expand All @@ -33,7 +33,7 @@ const jobState = computed(() => {
<CollectionDescription
:job-state-summary="jobState"
:collection-type="dsc.collection_type"
:element-count="dsc.element_count"
:element-count="dsc.element_count ?? undefined"
:elements-datatypes="dsc.elements_datatypes" />
</template>
</DetailsLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import { computed } from "vue";
import { useRouter } from "vue-router/composables";
import { type HDCADetailed } from "@/api";
import { type HDCASummary } from "@/api";
import { getAppRoot } from "@/onload/loadConfig";
const router = useRouter();
const props = defineProps<{
dsc: HDCADetailed;
dsc: HDCASummary; // typescript recognizes HDCADetailed IS_A HDCASummary
}>();
const downloadUrl = computed(() => `${getAppRoot()}api/dataset_collections/${props.dsc.id}/download`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";

import type { CollectionEntry, DCESummary, HistorySummary, SubCollection } from "@/api";
import { canMutateHistory, isCollectionElement, isHDCA } from "@/api";
import {
canMutateHistory,
type CollectionEntry,
type DCESummary,
type HDCASummary,
type HistorySummary,
isCollectionElement,
isHDCA,
type SubCollection,
} from "@/api";
import ExpandedItems from "@/components/History/Content/ExpandedItems";
import { updateContentFields } from "@/components/History/model/queries";
import { useCollectionElementsStore } from "@/stores/collectionElementsStore";
Expand Down Expand Up @@ -44,9 +52,8 @@ const dsc = computed(() => {
if (currentCollection === undefined) {
throw new Error("No collection selected");
}
return currentCollection;
return currentCollection as HDCASummary;
});

watch(
() => [dsc.value, offset.value],
() => {
Expand All @@ -71,7 +78,6 @@ const rootCollection = computed(() => {
});
const isRoot = computed(() => dsc.value == rootCollection.value);
const canEdit = computed(() => isRoot.value && canMutateHistory(props.history));

async function updateDsc(collection: CollectionEntry, fields: Object | undefined) {
if (!isHDCA(collection)) {
return;
Expand Down
16 changes: 12 additions & 4 deletions client/src/components/History/CurrentHistory/HistoryCounter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import prettyBytes from "pretty-bytes";
import { computed, onMounted, ref, toRef } from "vue";
import { useRouter } from "vue-router/composables";
import { type HistorySummaryExtended, userOwnsHistory } from "@/api";
import { type HistorySummaryExtended, type RegisteredUser, userOwnsHistory } from "@/api";
import { HistoryFilters } from "@/components/History/HistoryFilters.js";
import { useConfig } from "@/composables/config";
import { useHistoryContentStats } from "@/composables/historyContentStats";
Expand Down Expand Up @@ -131,6 +131,13 @@ function onUpdatePreferredObjectStoreId(preferredObjectStoreId: string | null) {
historyPreferredObjectStoreId.value = preferredObjectStoreId;
}
const registeredUser = computed<RegisteredUser>(() => {
if (isAnonymous.value) {
throw new Error("Invalid anonymous user object encountered");
}
return currentUser.value as RegisteredUser;
});
onMounted(() => {
updateTime();
// update every second
Expand Down Expand Up @@ -168,8 +175,8 @@ onMounted(() => {
<PreferredStorePopover
v-if="config && config.object_store_allows_id_selection && !isAnonymous"
:history-id="history.id"
:history-preferred-object-store-id="historyPreferredObjectStoreId"
:user="currentUser">
:history-preferred-object-store-id="historyPreferredObjectStoreId ?? undefined"
:user="registeredUser">
</PreferredStorePopover>

<BButtonGroup>
Expand Down Expand Up @@ -233,7 +240,8 @@ onMounted(() => {
size="sm"
hide-footer>
<SelectPreferredStore
:user-preferred-object-store-id="currentUser.preferred_object_store_id"
v-if="!isAnonymous"
:user-preferred-object-store-id="registeredUser.preferred_object_store_id ?? undefined"
:history="history"
@updated="onUpdatePreferredObjectStoreId" />
</BModal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const { isOnlyPreference } = useStorageLocationConfiguration();
interface Props {
historyId: string;
historyPreferredObjectStoreId?: string;
user: { preferred_object_store_id: string };
user: { preferred_object_store_id?: string | null };
}
const props = defineProps<Props>();
const preferredObjectStoreId = computed(() => {
let id = props.historyPreferredObjectStoreId;
if (!id) {
id = props.user.preferred_object_store_id;
id = props.user.preferred_object_store_id ?? undefined;
}
return id;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { storeToRefs } from "pinia";
import { computed } from "vue";
import { isAdminUser } from "@/api";
import { useJobDestinationParametersStore } from "@/stores/jobDestinationParametersStore";
import { useUserStore } from "@/stores/userStore";
Expand All @@ -20,7 +21,7 @@ const jobDestinationParams = computed(() => {
</script>

<template>
<div v-if="currentUser?.is_admin">
<div v-if="isAdminUser(currentUser)">
<h2 class="h-md">Destination Parameters</h2>
<table id="destination_parameters" class="tabletip info_data_table">
<tbody>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/JobParameters/JobParameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe("JobParameters/JobParameters.vue", () => {
jobId: JOB_ID,
};

const wrapper = mount(JobParameters, {
const wrapper = mount(JobParameters as object, {
propsData,
stubs: {
DatasetProvider: DatasetProvider,
Expand Down Expand Up @@ -92,7 +92,7 @@ describe("JobParameters/JobParameters.vue", () => {
};

const getSingleParam = async (propsData: { jobId: string; param: string }) => {
const wrapper = mount(JobParameters, {
const wrapper = mount(JobParameters as object, {
propsData,
stubs: {
DatasetProvider: DatasetProvider,
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Landing/WorkflowLanding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ claimWorkflow(props.uuid, props.public, props.secret).then(() => {
<WorkflowRun
:workflow-id="claimState.workflowId"
:prefer-simple-form="true"
:request-state="claimState.requestState"
:request-state="claimState.requestState ?? undefined"
:instance="claimState.instance" />
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Markdown/Elements/InstanceUrl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ interface InstanceUrlProps {
}
const props = withDefaults(defineProps<InstanceUrlProps>(), {
href: null,
title: null,
href: undefined,
title: undefined,
});
const effectiveTitle = computed(() => {
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Markdown/Elements/ToolStd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ interface ToolStdProps {
}
const props = withDefaults(defineProps<ToolStdProps>(), {
jobId: null,
implicitCollectionJobsId: null,
jobId: undefined,
implicitCollectionJobsId: undefined,
});
const jobStore = useJobStore();
Expand Down
Loading

0 comments on commit ca4faaa

Please sign in to comment.