Skip to content

Commit f6f7d8e

Browse files
committed
feat: add validation for excluded directories in file path handling and disabled field dropdows which has no options
1 parent de0f2ac commit f6f7d8e

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

ui/src/components/ContentMapper/index.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
overflow-x: hidden;
6060
}
6161
.ct-list {
62-
border-right: 1px solid $color-brand-secondary-lightest;
6362
list-style-type: none;
6463
padding: 15px 0 15px 0;
6564
li {
@@ -151,7 +150,7 @@
151150
}
152151
.Table {
153152
border-left: 0 none;
154-
min-height: 26.25rem;
153+
min-height: 24.25rem;
155154
.Table__body__row {
156155
.Table-select-body {
157156
>.checkbox-wrapper {

ui/src/components/ContentMapper/index.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,20 +1324,15 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
13241324
options={option}
13251325
menuPlacement="auto"
13261326
isDisabled={
1327-
data?.contentstackFieldType === 'group' ||
1328-
(data?.contentstackFieldType === 'text') ||
1329-
(data?.contentstackFieldType === 'url') ||
1330-
data?.backupFieldType === 'reference' ||
1331-
data?.contentstackFieldType === "global_field" ||
1327+
!(data?.contentstackFieldType === 'single_line_text' ||
1328+
data?.contentstackFieldType === 'multi_line_text' || data?.contentstackFieldType === 'html' || data?.contentstackFieldType === 'json') ||
13321329
data?.otherCmsType === undefined ||
1333-
newMigrationData?.project_current_step > 4 ||
1334-
data?.backupFieldType === 'extension' ||
1335-
data?.backupFieldType === 'app'
1330+
newMigrationData?.project_current_step > 4
13361331
}
13371332
/>
13381333
</div>
13391334
{!(
1340-
data?.contentstackFieldType === 'Group' ||
1335+
data?.contentstackFieldType === 'group' ||
13411336
data?.contentstackFieldType === 'text' ||
13421337
data?.contentstackFieldType === 'url' ||
13431338
data?.contentstackFieldType === 'global_field' ||
@@ -1792,14 +1787,10 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
17921787
? {
17931788
label: Fields[data?.contentstackFieldType]?.label ?? 'No Option',
17941789
value: Fields[data?.contentstackFieldType]?.label ?? 'No Option',
1795-
isDisabled: data?.contentstackFieldType === 'text' ||
1796-
data?.contentstackFieldType === 'group' ||
1797-
data?.contentstackFieldType === 'url' ||
1798-
data?.backupFieldType === "reference" ||
1799-
data?.contentstackFieldType === "global_field" ||
1800-
data?.otherCmsType === undefined ||
1801-
data?.backupFieldType === 'app' ||
1802-
data?.backupFieldType === 'extension'
1790+
isDisabled: !(data?.contentstackFieldType === 'single_line_text' ||
1791+
data?.contentstackFieldType === 'multi_line_text' || data?.contentstackFieldType === 'html' || data?.contentstackFieldType === 'json') ||
1792+
data?.otherCmsType === undefined
1793+
18031794
}
18041795
: {
18051796
label: `${selectedOption} matches`,

upload-api/src/routes/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,21 @@ router.get('/validator', express.json(), fileOperationLimiter, async function (r
168168
res.status(data?.status || 200).json(data);
169169

170170
if (data?.status === 200) {
171-
const filePath = path.join(__dirname, '..', '..', 'extracted_files', name);
171+
let filePath = path.join(__dirname, '..', '..', 'extracted_files', name);
172+
173+
// Define excluded directories that should not be used in file paths
174+
const EXCLUDED_DIRECTORIES = ['blob', 'installer', 'items', 'metadata', 'properties'];
175+
176+
// Check if data.file is a valid, non-excluded directory
177+
const isValidFile = data?.file &&
178+
typeof data?.file === 'string' &&
179+
data?.file?.trim() !== '' &&
180+
!EXCLUDED_DIRECTORIES.includes(data?.file?.toLowerCase());
181+
182+
if (isValidFile && data?.file) {
183+
filePath = path.join(__dirname, '..', '..', 'extracted_files', name, data?.file);
184+
}
185+
172186
createMapper(filePath, projectId, app_token, affix, config);
173187
}
174188
} catch (error) {

0 commit comments

Comments
 (0)