Skip to content

Commit

Permalink
Merge branch 'main' into MWPW-131664
Browse files Browse the repository at this point in the history
  • Loading branch information
honstar authored May 25, 2023
2 parents 0f29110 + 8befe08 commit 5cbca33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
3 changes: 1 addition & 2 deletions libs/blocks/tags/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getTaxonomyModule, loadTaxonomy, computeTaxonomyFromTopics, getLinkForT
import { createTag } from '../../utils/utils.js';

export default async function init(blockEl) {
let tags = blockEl.firstElementChild?.firstElementChild?.textContent;
const tags = blockEl.firstElementChild?.firstElementChild?.textContent;

if (!tags) return;

Expand All @@ -11,7 +11,6 @@ export default async function init(blockEl) {
}

blockEl.innerHTML = '';
tags = tags.replace(/[^a-zA-Z0-9,\s-]/g, '');
const tagsArray = tags.split(', ').map((tag) => tag.trim());
const articleTax = computeTaxonomyFromTopics(tagsArray);
const tagsWrapper = createTag('p');
Expand Down
48 changes: 23 additions & 25 deletions tools/floodgate/js/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getHelixAdminApiUrl,
readProjectFile,
} from '../../loc/project.js';
import { getFilesData } from '../../loc/sharepoint.js';
import { getSpFiles } from '../../loc/sharepoint.js';
import { getDocPathFromUrl, getFloodgateUrl } from './utils.js';

let project;
Expand All @@ -22,27 +22,25 @@ const PROJECT_STATUS = {
/**
* Makes the sharepoint file data part of `projectDetail` per URL.
*/
function injectSharepointData(projectUrls, filePaths, docPaths, spFiles, isFloodgate) {
for (let i = 0; i < spFiles.length; i += 1) {
let fileBody = {};
let status = 404;
if (!spFiles[i].error) {
fileBody = spFiles[i];
status = 200;
}
const filePath = docPaths[i];
const urls = filePaths.get(filePath);
urls.forEach((key) => {
const urlObjVal = projectUrls.get(key);
if (isFloodgate) {
urlObjVal.doc.fg.sp = fileBody;
urlObjVal.doc.fg.sp.status = status;
} else {
urlObjVal.doc.sp = fileBody;
urlObjVal.doc.sp.status = status;
}
function injectSharepointData(projectUrls, filePaths, docPaths, spBatchFiles, isFloodgate) {
spBatchFiles.forEach((spFiles) => {
if (!spFiles?.responses) return;
spFiles.responses.forEach(({ id, status, body }) => {
const filePath = docPaths[id];
const fileBody = status === 200 ? body : {};
const urls = filePaths.get(filePath);
urls.forEach((key) => {
const urlObjVal = projectUrls.get(key);
if (isFloodgate) {
urlObjVal.doc.fg.sp = fileBody;
urlObjVal.doc.fg.sp.status = status;
} else {
urlObjVal.doc.sp = fileBody;
urlObjVal.doc.sp.status = status;
}
});
});
}
});
}

async function updateProjectWithDocs(projectDetail) {
Expand All @@ -51,10 +49,10 @@ async function updateProjectWithDocs(projectDetail) {
}
const { filePaths } = projectDetail;
const docPaths = [...filePaths.keys()];
const spFiles = await getFilesData(docPaths);
injectSharepointData(projectDetail.urls, filePaths, docPaths, spFiles);
const fgSpFiles = await getFilesData(docPaths, true);
injectSharepointData(projectDetail.urls, filePaths, docPaths, fgSpFiles, true);
const spBatchFiles = await getSpFiles(docPaths);
injectSharepointData(projectDetail.urls, filePaths, docPaths, spBatchFiles);
const fgSpBatchFiles = await getSpFiles(docPaths, true);
injectSharepointData(projectDetail.urls, filePaths, docPaths, fgSpBatchFiles, true);
}

async function initProject() {
Expand Down

0 comments on commit 5cbca33

Please sign in to comment.