- Add softwareReferenceHref helper function for generating resource links. - Create useGlobalResourceEditor hook for managing global application resources. - Implement useGlobalResourceForm hook for handling global resource forms. - Introduce GlobalSoftwareCatalogProvider for context management of global applications. - Develop GlobalOperatingSystemsPage to render global operating systems using the existing GlobalApplicationsPage. - Add operating system form identity helpers for managing OS-specific fields. - Create operating system specification labels for better localization. - Implement OperatingSystemIdentityReview component for reviewing OS identities. - Add OperatingSystemProductFields component for displaying OS product details. - Write tests for resource characteristic control to ensure proper translation and value handling. - Create a Python script for auditing global operating systems UI interactions. - Add tests for expanded workstation profiles to ensure proper functionality and responsiveness.
91 lines
2.9 KiB
TypeScript
91 lines
2.9 KiB
TypeScript
import type { QueryClient } from "@tanstack/react-query";
|
|
import { z } from "zod/v4";
|
|
|
|
import type {
|
|
GlobalApplicationCapabilitiesDTO,
|
|
ListGlobalApplicationsRequestDTO,
|
|
} from "../../../../common";
|
|
|
|
export function globalSoftwareKeys(root: string) {
|
|
return {
|
|
root: [root],
|
|
capabilities: [root, "capabilities"],
|
|
list: (query: ListGlobalApplicationsRequestDTO) => [root, "list", query],
|
|
detail: (id: string) => [root, "detail", id],
|
|
admin: (id: string, actor: GlobalApplicationCapabilitiesDTO) => [
|
|
root,
|
|
"admin",
|
|
actor.actorId,
|
|
actor.authVersion,
|
|
id,
|
|
],
|
|
history: (id: string, actor: GlobalApplicationCapabilitiesDTO, cursor?: string) => [
|
|
root,
|
|
"history",
|
|
actor.actorId,
|
|
actor.authVersion,
|
|
id,
|
|
cursor,
|
|
],
|
|
};
|
|
}
|
|
|
|
export const globalApplicationKeys = globalSoftwareKeys("resource-global-applications");
|
|
|
|
export async function invalidateGlobalApplication(
|
|
client: QueryClient,
|
|
id: string,
|
|
root = "resource-global-applications"
|
|
) {
|
|
const applications = root === "resource-global-applications";
|
|
const consumers = applications
|
|
? ["software-installations", "application-configurations"]
|
|
: ["software-installations"];
|
|
|
|
await Promise.all([
|
|
...(applications
|
|
? [
|
|
client.invalidateQueries({ queryKey: ["company-application-catalog"] }),
|
|
client.invalidateQueries({ queryKey: ["resource-application-coincidences"] }),
|
|
]
|
|
: []),
|
|
client.invalidateQueries({ queryKey: [root, "list"] }),
|
|
client.invalidateQueries({ queryKey: globalSoftwareKeys(root).detail(id) }),
|
|
client.invalidateQueries({
|
|
predicate: (query) =>
|
|
query.queryKey[0] === root &&
|
|
["admin", "history"].includes(String(query.queryKey[1])) &&
|
|
query.queryKey.includes(id),
|
|
}),
|
|
client.invalidateQueries({
|
|
predicate: (query) =>
|
|
query.queryKey[0] === "resource-application-candidates" &&
|
|
(applications || query.queryKey[2] === "software-installation"),
|
|
}),
|
|
client.invalidateQueries({
|
|
predicate: (query) =>
|
|
query.queryKey[0] === "resource-application-references" &&
|
|
(applications || query.queryKey[2] === "software-installation") &&
|
|
Array.isArray(query.queryKey[3]) &&
|
|
query.queryKey[3].includes(id),
|
|
}),
|
|
client.invalidateQueries({
|
|
predicate: (query) => {
|
|
if (!consumers.includes(String(query.queryKey[0]))) {
|
|
return false;
|
|
}
|
|
// Inspección mínima de caché ya autorizada, sin importar DTO ni APIs del módulo consumidor.
|
|
const used = z
|
|
.object({
|
|
configurations: z.array(z.object({ values: z.object({ resourceId: z.uuid() }) })),
|
|
})
|
|
.safeParse(query.state.data);
|
|
|
|
return (
|
|
used.success && used.data.configurations.some((item) => item.values.resourceId === id)
|
|
);
|
|
},
|
|
}),
|
|
]);
|
|
}
|