Skip to content

Commit 3c292b7

Browse files
authored
Use extension for type when adding an abstract document to a server-side Project (#1720)
1 parent 14e196f commit 3c292b7

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/commands/project.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export async function deleteProject(node: ProjectNode | undefined): Promise<any>
215215

216216
/**
217217
* @param Name The name of the item to add.
218-
* @param Type The type of the item to add. Either "MAC", "CLS", "PKG", "CSP", "DIR" or "OTH".
218+
* @param Type The type of the item to add. Either "MAC", "CLS", "PKG", "CSP", "DIR", or an abstract document type like "OTH" or "LUT".
219219
* @param items The items currently in the project.
220220
*/
221221
function addProjectItem(
@@ -268,7 +268,7 @@ function addProjectItem(
268268
(item.Type == "CSP" || item.Type == "DIR") && item.Name.toLowerCase().startsWith(`${Name.toLowerCase()}/`)
269269
)
270270
);
271-
} else if (Type == "OTH" && !items.some((item) => item.Name.toLowerCase() == Name.toLowerCase())) {
271+
} else if (!items.some((item) => item.Name.toLowerCase() == Name.toLowerCase())) {
272272
add.push({ Name, Type });
273273
}
274274

@@ -321,8 +321,15 @@ export function removeProjectItem(Name: string, Type: string, items: ProjectItem
321321
)
322322
);
323323
}
324-
} else if (Type == "OTH" && items.some((item) => item.Name.toLowerCase() == Name.toLowerCase())) {
325-
remove.push({ Name, Type: items.find((item) => item.Name.toLowerCase() == Name.toLowerCase())?.Type ?? Type });
324+
} else if (Type == "OTH") {
325+
// Remove all items of any abstract document type that have the same name as the target item
326+
remove.concat(
327+
items.filter(
328+
(item) =>
329+
item.Name.toLowerCase() == Name.toLowerCase() &&
330+
!["MAC", "CLS", "PKG", "CSP", "DIR", "GBL"].includes(item.Type)
331+
)
332+
);
326333
}
327334

328335
return remove;
@@ -680,7 +687,9 @@ export async function modifyProject(
680687
type = "DIR";
681688
}
682689
} else {
683-
type = "OTH";
690+
// Other tools like Production deployment expect the Type of
691+
// an abstract document item to be the document's extension
692+
type = ext.toUpperCase();
684693
}
685694

686695
let newAdd: ProjectItem[] = [];
@@ -952,7 +961,9 @@ export async function addIsfsFileToProject(project: string, fileName: string, ap
952961
? "CLS"
953962
: ["mac", "int", "inc"].includes(ext)
954963
? "MAC"
955-
: "OTH";
964+
: // Other tools like Production deployment expect the Type of
965+
// an abstract document item to be the document's extension
966+
ext.toUpperCase();
956967
const items: ProjectItem[] = await api
957968
.actionQuery("SELECT Name, Type FROM %Studio.Project_ProjectItemsList(?,?) WHERE Type != 'GBL'", [project, "1"])
958969
.then((data) => data.result.content);

0 commit comments

Comments
 (0)