Skip to content

Commit 0f71e93

Browse files
authored
Merge pull request #94 from defineEditor/dev
0.6.3
2 parents 3973de6 + 2133b59 commit 0f71e93

File tree

9 files changed

+107
-43
lines changed

9 files changed

+107
-43
lines changed

.github/workflows/build-macos.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,12 @@ jobs:
5555
env:
5656
npm_config_arch: ${{ matrix.arch }}
5757

58-
- name: Upload artifacts (x64)
58+
- name: Upload artifacts (x64, arm64)
5959
if: matrix.arch == 'x64'
6060
uses: actions/upload-artifact@v4
6161
with:
62-
name: mac-${{ matrix.arch }}
62+
name: mac-x64-arm64
6363
path: |
6464
release/build/vde-dataset-viewer-[0-9]*.[0-9]*.[0-9]*.dmg
6565
release/build/vde-dataset-viewer-[0-9]*.[0-9]*.[0-9]*.dmg.blockmap
6666
release/build/latest-mac.yml
67-
68-
- name: Upload artifacts (arm64)
69-
if: matrix.arch == 'arm64'
70-
uses: actions/upload-artifact@v4
71-
with:
72-
name: mac-${{ matrix.arch }}
73-
path: |
74-
release/build/vde-dataset-viewer-[0-9]*.[0-9]*.[0-9]*-arm64.dmg
75-
release/build/vde-dataset-viewer-[0-9]*.[0-9]*.[0-9]*-arm64.dmg.blockmap

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 0.6.3
2+
### Improvements
3+
* Improved handling of invalid Define-XML files and adding Open File button to the Define-XML screen [#92](https://github.com/defineEditor/vde-dataset-viewer/issues/92)
4+
5+
### Fixes
6+
* Fix TIG substandard selection for CORE 0.14 [#90](https://github.com/defineEditor/vde-dataset-viewer/issues/90)
7+
* Drag and dropping SAS7BDAT does not open the dataset [#91](https://github.com/defineEditor/vde-dataset-viewer/issues/91)
8+
19
# 0.6.2
210
### Core Changes
311
* Render Define-XML 2.0 and 2.1 in a format similar to the stylesheet [#83](https://github.com/defineEditor/vde-dataset-viewer/issues/83)

release/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vde-dataset-viewer",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "VDE Dataset Viewer",
55
"license": "MIT",
66
"author": {

src/interfaces/electron.api.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export interface ElectronApi {
100100
props?: NewWindowProps,
101101
) => Promise<void>;
102102
openDefineXml: (filePath?: string) => Promise<DefineFileInfo | null>;
103-
getDefineXmlContent: (fileId: string) => Promise<DefineXmlContent | null>;
103+
getDefineXmlContent: (
104+
fileId: string,
105+
) => Promise<DefineXmlContent | { error: string }>;
104106
closeDefineXml: (fileId: string) => Promise<boolean>;
105107
isWindows: boolean;
106108
resizeWindow: (

src/main/managers/defineXmlManager.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -192,26 +192,35 @@ class DefineXmlManager {
192192
public getDefineXmlContent = async (
193193
_event: IpcMainInvokeEvent,
194194
fileId: string,
195-
): Promise<DefineXmlContent> => {
195+
): Promise<DefineXmlContent | { error: string }> => {
196196
const fileInfo = this.openedXmlFiles[fileId];
197197
if (!fileInfo) {
198-
throw new Error(`Define file not found for ID: ${fileId}`);
198+
return { error: `Define file not found for ID: ${fileId}` };
199199
}
200200

201-
const xmlContent = await fsPromises.readFile(fileInfo.fullPath, 'utf8');
202-
203-
// Parse XML content
204-
const parsedXml = await parseDefineXml(
205-
xmlContent,
206-
fileInfo.defineVersion,
207-
fileInfo.arm,
208-
);
209-
return {
210-
defineVersion: fileInfo.defineVersion,
211-
arm: fileInfo.arm,
212-
type: 'xml',
213-
content: parsedXml,
214-
};
201+
try {
202+
const xmlContent = await fsPromises.readFile(
203+
fileInfo.fullPath,
204+
'utf8',
205+
);
206+
207+
// Parse XML content
208+
const parsedXml = await parseDefineXml(
209+
xmlContent,
210+
fileInfo.defineVersion,
211+
fileInfo.arm,
212+
);
213+
return {
214+
defineVersion: fileInfo.defineVersion,
215+
arm: fileInfo.arm,
216+
type: 'xml',
217+
content: parsedXml,
218+
};
219+
} catch (error) {
220+
return {
221+
error: `Error reading/parsing Define-XML: ${error instanceof Error ? error.message : String(error)}`,
222+
};
223+
}
215224
};
216225

217226
/**

src/renderer/components/DefineXmlStylesheet/index.tsx

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import React, { useContext, useState, useEffect } from 'react';
2-
import { Box } from '@mui/material';
2+
import { Box, Button, Stack } from '@mui/material';
33
import AppContext from 'renderer/utils/AppContext';
44
import { DefineXmlContent } from 'interfaces/defineXml';
55
import { useAppSelector, useAppDispatch } from 'renderer/redux/hooks';
66
import StylesheetLayout from 'renderer/components/DefineXmlStylesheet/StylesheetLayout';
77
import handleOpenDataset from 'renderer/utils/handleOpenDataset';
8-
import { openSnackbar, setDefineIsLoading } from 'renderer/redux/slices/ui';
8+
import {
9+
openSnackbar,
10+
setDefineFileId,
11+
setDefineIsLoading,
12+
} from 'renderer/redux/slices/ui';
913
import Loading from 'renderer/components/Loading';
1014

1115
const styles = {
@@ -30,11 +34,18 @@ const styles = {
3034
color: '#888',
3135
textAlign: 'center',
3236
},
37+
openButton: {
38+
textTransform: 'none',
39+
padding: 0,
40+
marginRight: '4px',
41+
minWidth: 'auto',
42+
lineHeight: 1,
43+
},
3344
};
3445

3546
const DefineXml: React.FC = () => {
3647
const { apiService } = useContext(AppContext);
37-
const dispath = useAppDispatch();
48+
const dispatch = useAppDispatch();
3849

3950
const [content, setContent] = useState<DefineXmlContent | null>(null);
4051

@@ -50,6 +61,23 @@ const DefineXml: React.FC = () => {
5061
(state) => state.ui.currentFileId,
5162
);
5263

64+
const handleOpenDefine = async () => {
65+
const fileInfo = await apiService.openDefineXml();
66+
67+
if (fileInfo === null) {
68+
// User cancelled
69+
return;
70+
}
71+
72+
dispatch(
73+
openSnackbar({
74+
type: 'info',
75+
message: `Loaded ${fileInfo.filename}`,
76+
}),
77+
);
78+
dispatch(setDefineFileId(fileInfo.fileId));
79+
};
80+
5381
const handleOpenFile = async (
5482
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
5583
) => {
@@ -80,15 +108,15 @@ const DefineXml: React.FC = () => {
80108
handleOpenDataset(
81109
filePath,
82110
currentDatasetFileId,
83-
dispath,
111+
dispatch,
84112
apiService,
85113
);
86114
}
87115
// If it is a file, open it in the default application
88116
else {
89117
const result = await apiService.openFileInDefaultApp(filePath);
90118
if (result !== '') {
91-
dispath(
119+
dispatch(
92120
openSnackbar({
93121
type: 'error',
94122
message: `Failed to open file: ${result}`,
@@ -103,15 +131,28 @@ const DefineXml: React.FC = () => {
103131
if (currentFileId) {
104132
const defineContent =
105133
await apiService.getDefineXmlContent(currentFileId);
134+
if ('error' in defineContent) {
135+
dispatch(
136+
openSnackbar({
137+
type: 'error',
138+
message: `Failed to load Define-XML content: ${defineContent.error}`,
139+
}),
140+
);
141+
dispatch(setDefineFileId(null));
142+
return;
143+
}
106144
setContent(defineContent);
107145
}
108146
};
109147

110148
if (currentFileId) {
111-
dispath(setDefineIsLoading(true));
149+
dispatch(setDefineIsLoading(true));
112150
fetchDefineContent();
151+
} else {
152+
setContent(null);
153+
dispatch(setDefineIsLoading(false));
113154
}
114-
}, [currentFileId, apiService, dispath]);
155+
}, [currentFileId, apiService, dispatch]);
115156

116157
if (!content) {
117158
if (isDefineLoading) {
@@ -131,7 +172,12 @@ const DefineXml: React.FC = () => {
131172
justifyContent="center"
132173
height="100%"
133174
>
134-
Open a Define-XML file or drag and drop it here
175+
<Stack direction="row" alignItems="center">
176+
<Button sx={styles.openButton} onClick={handleOpenDefine}>
177+
Open file
178+
</Button>
179+
<Box>or drag and drop a Define-XML here</Box>
180+
</Stack>
135181
</Box>
136182
);
137183
}

src/renderer/components/DragAndDrop/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const DragAndDrop: React.FC<Props> = ({ children }) => {
4646
fileExtension === 'xpt' ||
4747
fileExtension === 'json' ||
4848
fileExtension === 'ndjson' ||
49+
fileExtension === 'sas7bdat' ||
4950
fileExtension === 'dsjc'
5051
) {
5152
const newDataInfo = await openNewDataset(

src/renderer/components/Validator/Configuration.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,17 @@ const ValidatorConfiguration: React.FC<ValidatorConfigurationProps> = ({
9090
} = {};
9191
validatorData.info.standards.forEach((rawStandard) => {
9292
const parsedStandard = rawStandard.split(',');
93-
const [name, version] = parsedStandard;
93+
const [name, version, substandard] = parsedStandard;
94+
const versionWithSubstandard = substandard
95+
? `${version},${substandard}`
96+
: version;
9497
if (!standards[name]) {
95-
standards[name] = { name, versions: [version] };
98+
standards[name] = {
99+
name,
100+
versions: [versionWithSubstandard],
101+
};
96102
} else {
97-
standards[name].versions.push(version);
103+
standards[name].versions.push(versionWithSubstandard);
98104
}
99105
});
100106
return standards;

src/renderer/services/ApiService.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,15 +904,16 @@ class ApiService {
904904

905905
public getDefineXmlContent = async (
906906
fileId: string,
907-
): Promise<DefineXmlContent | null> => {
907+
): Promise<DefineXmlContent | { error: string }> => {
908908
// Check if the content is already loaded
909909
if (this.openedDefineContents[fileId] !== undefined) {
910910
return this.openedDefineContents[fileId];
911911
}
912912
const content = await window.electron.getDefineXmlContent(fileId);
913-
if (content !== null) {
914-
this.openedDefineContents[fileId] = content;
913+
if ('error' in content) {
914+
return content;
915915
}
916+
this.openedDefineContents[fileId] = content;
916917
return content;
917918
};
918919

0 commit comments

Comments
 (0)