feat(frontend2): pass projectId props where needed
This commit is contained in:
@@ -53,7 +53,7 @@ const emit = defineEmits<{
|
||||
const props = defineProps<{
|
||||
versions: ProjectModelPageDialogDeleteVersionFragment[]
|
||||
open: boolean
|
||||
projectId?: string
|
||||
projectId: string
|
||||
modelId?: string
|
||||
}>()
|
||||
|
||||
@@ -71,10 +71,10 @@ const onDelete = async () => {
|
||||
loading.value = true
|
||||
const success = await deleteVersions(
|
||||
{
|
||||
projectId: props.projectId,
|
||||
versionIds: props.versions.map((v) => v.id)
|
||||
},
|
||||
{
|
||||
projectId: props.projectId,
|
||||
modelId: props.modelId
|
||||
}
|
||||
)
|
||||
|
||||
@@ -57,6 +57,7 @@ const emit = defineEmits<{
|
||||
}>()
|
||||
|
||||
const props = defineProps<{
|
||||
projectId: string
|
||||
version: Nullable<ProjectModelPageDialogDeleteVersionFragment>
|
||||
open: boolean
|
||||
}>()
|
||||
@@ -85,6 +86,7 @@ const onSubmit = handleSubmit(async ({ newMessage }) => {
|
||||
|
||||
loading.value = true
|
||||
const success = !!(await updateVersion({
|
||||
projectId: props.projectId,
|
||||
versionId: props.version?.id,
|
||||
message: newMessage
|
||||
}))
|
||||
|
||||
@@ -81,13 +81,13 @@ const onMove = async (targetModelName: string, newModelCreated?: boolean) => {
|
||||
loading.value = true
|
||||
const success = await moveVersions(
|
||||
{
|
||||
projectId: props.projectId,
|
||||
versionIds: props.versions.map((v) => v.id),
|
||||
targetModelName
|
||||
},
|
||||
{
|
||||
previousModelId: props.modelId,
|
||||
newModelCreated,
|
||||
projectId: props.projectId
|
||||
newModelCreated
|
||||
}
|
||||
)
|
||||
loading.value = false
|
||||
|
||||
@@ -867,7 +867,8 @@ export type DeleteUserEmailInput = {
|
||||
};
|
||||
|
||||
export type DeleteVersionsInput = {
|
||||
versionIds: Array<Scalars['String']['input']>;
|
||||
projectId: Scalars['ID']['input'];
|
||||
versionIds: Array<Scalars['ID']['input']>;
|
||||
};
|
||||
|
||||
export enum DiscoverableStreamsSortType {
|
||||
@@ -1200,9 +1201,10 @@ export type ModelsTreeItemCollection = {
|
||||
};
|
||||
|
||||
export type MoveVersionsInput = {
|
||||
projectId: Scalars['ID']['input'];
|
||||
/** If the name references a nonexistant model, it will be created */
|
||||
targetModelName: Scalars['String']['input'];
|
||||
versionIds: Array<Scalars['String']['input']>;
|
||||
versionIds: Array<Scalars['ID']['input']>;
|
||||
};
|
||||
|
||||
export type Mutation = {
|
||||
@@ -3493,7 +3495,8 @@ export type UpdateServerRegionInput = {
|
||||
/** Only non-null values will be updated */
|
||||
export type UpdateVersionInput = {
|
||||
message?: InputMaybe<Scalars['String']['input']>;
|
||||
versionId: Scalars['String']['input'];
|
||||
projectId: Scalars['ID']['input'];
|
||||
versionId: Scalars['ID']['input'];
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -350,7 +350,6 @@ export function useDeleteVersions() {
|
||||
* Various options for better cache updates, set if possible
|
||||
*/
|
||||
options?: Partial<{
|
||||
projectId: string
|
||||
modelId: string
|
||||
}>
|
||||
) => {
|
||||
@@ -372,26 +371,21 @@ export function useDeleteVersions() {
|
||||
}
|
||||
|
||||
// Update totalCounts in project
|
||||
if (options?.projectId) {
|
||||
modifyObjectFields<ProjectVersionsArgs, Project['versions']>(
|
||||
cache,
|
||||
getCacheId('Project', options.projectId),
|
||||
(_fieldName, _variables, data) => {
|
||||
return {
|
||||
...data,
|
||||
...(!isUndefined(data.totalCount)
|
||||
? {
|
||||
totalCount: Math.max(
|
||||
data.totalCount - input.versionIds.length,
|
||||
0
|
||||
)
|
||||
}
|
||||
: {})
|
||||
}
|
||||
},
|
||||
{ fieldNameWhitelist: ['versions'] }
|
||||
)
|
||||
}
|
||||
modifyObjectFields<ProjectVersionsArgs, Project['versions']>(
|
||||
cache,
|
||||
getCacheId('Project', input.projectId),
|
||||
(_fieldName, _variables, data) => {
|
||||
return {
|
||||
...data,
|
||||
...(!isUndefined(data.totalCount)
|
||||
? {
|
||||
totalCount: Math.max(data.totalCount - input.versionIds.length, 0)
|
||||
}
|
||||
: {})
|
||||
}
|
||||
},
|
||||
{ fieldNameWhitelist: ['versions'] }
|
||||
)
|
||||
|
||||
// Update totalCounts in model
|
||||
if (options?.modelId) {
|
||||
@@ -458,7 +452,6 @@ export function useMoveVersions() {
|
||||
options?: Partial<{
|
||||
previousModelId: string
|
||||
newModelCreated: boolean
|
||||
projectId: string
|
||||
}>
|
||||
) => {
|
||||
if (!input.versionIds.length || !input.targetModelName.trim()) return
|
||||
@@ -551,8 +544,8 @@ export function useMoveVersions() {
|
||||
{ fieldNameWhitelist: ['versions'] }
|
||||
)
|
||||
|
||||
if (options?.newModelCreated && options?.projectId) {
|
||||
evictProjectModels(options.projectId)
|
||||
if (options?.newModelCreated) {
|
||||
evictProjectModels(input.projectId)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user