Skip to content

Commit 264e8c2

Browse files
Updated server logic file to add customjs as suffix (#1353)
* Updated server logic file to add customjs as suffix * Moved serverlogic extension name to constants --------- Co-authored-by: Ashwani Kumar <[email protected]> Co-authored-by: ashwani123p <[email protected]>
1 parent e41e443 commit 264e8c2

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/web/client/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,4 @@ export const WEB_EXTENSION_COLLABORATION_OPTIONS_CONTACT = "Contact";
147147

148148
//Business logic constants
149149
export const SERVERLOGICS = "server-logics";
150+
export const SERVERLOGIC_FILE_EXTENSION = ".serverlogic.customjs.js";

src/web/client/dal/remoteFetchProvider.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,13 @@ async function processDataAndCreateFile(
426426
else {
427427
let fileCreationValid = true;
428428
let fileNameWithExtension = GetFileNameWithExtension(entityName, fileName, languageCode, fileExtension);
429-
429+
if (entityName === schemaEntityName.SERVERLOGICS) {
430+
// Modify filename for serverlogics: test.js -> test.serverlogics.customjs.js
431+
if (fileNameWithExtension.endsWith('.js')) {
432+
const baseName = fileNameWithExtension.slice(0, -3); // Remove .js
433+
fileNameWithExtension = `${baseName}${Constants.SERVERLOGIC_FILE_EXTENSION}`;
434+
}
435+
}
430436
if (defaultFileInfo?.fileName) {
431437
fileCreationValid = defaultFileInfo?.fileName === fileNameWithExtension ||
432438
(defaultFileInfo?.fileName.startsWith(fileName) && defaultFileInfo?.fileName.endsWith(fileExtension));

src/web/client/dal/remoteSaveProvider.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getCommonHeadersForDataverse } from "../../../common/services/Authentic
99
import { BAD_REQUEST, MIMETYPE, queryParameters } from "../common/constants";
1010
import { showErrorDialog } from "../../../common/utilities/errorHandlerUtil";
1111
import { FileData } from "../context/fileData";
12-
import { httpMethod } from "../common/constants";
12+
import { httpMethod, SERVERLOGIC_FILE_EXTENSION } from "../common/constants";
1313
import {
1414
getEntity,
1515
isWebFileV2,
@@ -94,7 +94,12 @@ async function getSaveParameters(
9494
if (webFileV2) {
9595
let fileName = fileDataMap.get(fileUri.fsPath)?.fileName as string;
9696
if (entityName === MultiFileSupportedEntityName.SERVERLOGICS && fileName && !fileName.endsWith('.sl')) {
97-
const baseName = fileName.endsWith('.js') ? fileName.slice(0, -3) : fileName;
97+
// Handle filenames like test.serverlogic.customjs.js -> extract base name (test) and append .sl
98+
let baseName = fileName;
99+
// Remove .serverlogic.customjs.js if present
100+
if (baseName.endsWith(SERVERLOGIC_FILE_EXTENSION)) {
101+
baseName = baseName.slice(0, -24); // Remove .serverlogic.customjs.js (24 characters)
102+
}
98103
fileName = `${baseName}.sl`;
99104
}
100105
saveCallParameters.requestInit.headers = {

0 commit comments

Comments
 (0)