Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/web/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ export const WEB_EXTENSION_COLLABORATION_OPTIONS_CONTACT = "Contact";

//Business logic constants
export const SERVERLOGICS = "server-logics";
export const SERVERLOGIC_FILE_EXTENSION = ".serverlogic.customjs.js";
8 changes: 7 additions & 1 deletion src/web/client/dal/remoteFetchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,13 @@ async function processDataAndCreateFile(
else {
let fileCreationValid = true;
let fileNameWithExtension = GetFileNameWithExtension(entityName, fileName, languageCode, fileExtension);

if (entityName === schemaEntityName.SERVERLOGICS) {
// Modify filename for serverlogics: test.js -> test.serverlogics.customjs.js
if (fileNameWithExtension.endsWith('.js')) {
const baseName = fileNameWithExtension.slice(0, -3); // Remove .js
fileNameWithExtension = `${baseName}${Constants.SERVERLOGIC_FILE_EXTENSION}`;
}
}
if (defaultFileInfo?.fileName) {
fileCreationValid = defaultFileInfo?.fileName === fileNameWithExtension ||
(defaultFileInfo?.fileName.startsWith(fileName) && defaultFileInfo?.fileName.endsWith(fileExtension));
Expand Down
9 changes: 7 additions & 2 deletions src/web/client/dal/remoteSaveProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getCommonHeadersForDataverse } from "../../../common/services/Authentic
import { BAD_REQUEST, MIMETYPE, queryParameters } from "../common/constants";
import { showErrorDialog } from "../../../common/utilities/errorHandlerUtil";
import { FileData } from "../context/fileData";
import { httpMethod } from "../common/constants";
import { httpMethod, SERVERLOGIC_FILE_EXTENSION } from "../common/constants";
import {
getEntity,
isWebFileV2,
Expand Down Expand Up @@ -94,7 +94,12 @@ async function getSaveParameters(
if (webFileV2) {
let fileName = fileDataMap.get(fileUri.fsPath)?.fileName as string;
if (entityName === MultiFileSupportedEntityName.SERVERLOGICS && fileName && !fileName.endsWith('.sl')) {
const baseName = fileName.endsWith('.js') ? fileName.slice(0, -3) : fileName;
// Handle filenames like test.serverlogic.customjs.js -> extract base name (test) and append .sl
let baseName = fileName;
// Remove .serverlogic.customjs.js if present
if (baseName.endsWith(SERVERLOGIC_FILE_EXTENSION)) {
baseName = baseName.slice(0, -24); // Remove .serverlogic.customjs.js (24 characters)
}
fileName = `${baseName}.sl`;
}
saveCallParameters.requestInit.headers = {
Expand Down