Skip to content

Commit

Permalink
Merge pull request #9 from ozovalihasan/update-gui
Browse files Browse the repository at this point in the history
Fix an issue related to association names
  • Loading branch information
ozovalihasan authored Sep 8, 2022
2 parents a01a221 + f40b4c1 commit ac49d5f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Then, there are two choices to use the generated JSON file;
- 'has_one' association can be added by using ![has_one](./documents/images/has_one.png).
- ':through' association can be added by using ![through](./documents/images/through.png).
- The EAD file can be downloaded by clicking the "Download EAD" button.
- Any EAD file can be uploaded by clicking the "Upload EAD" button and selecting a file. EAD file generated by v0.4.0 and v0.4.1 can be uploaded without any problem.
- Any EAD file can be uploaded by clicking the "Upload EAD" button and selecting a file. EAD file generated by v0.4.0, v0.4.1 and v0.4.2 can be uploaded without any problem.
- EAD can be reset to the initial state by clicking the 'Reset' button.

## Run EAD locally
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ead",
"private": true,
"version": "0.4.0",
"version": "0.4.2",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const Navbar = () => {
<EADLogo />
</a>
<div className='text-first-500 text-end text-xs '>
0.4.1
0.4.2
</div>
</div>
<button
Expand Down
12 changes: 6 additions & 6 deletions src/components/Navbar/test/__snapshots__/Navbar.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Object {
<div
class="text-first-500 text-end text-xs "
>
0.4.1
0.4.2
</div>
</div>
<button
Expand Down Expand Up @@ -100,7 +100,7 @@ Object {
<div
class="text-first-500 text-end text-xs "
>
0.4.1
0.4.2
</div>
</div>
<button
Expand Down Expand Up @@ -231,7 +231,7 @@ Object {
<div
class="text-first-500 text-end text-xs "
>
0.4.1
0.4.2
</div>
</div>
<button
Expand Down Expand Up @@ -305,7 +305,7 @@ Object {
<div
class="text-first-500 text-end text-xs "
>
0.4.1
0.4.2
</div>
</div>
<button
Expand Down Expand Up @@ -436,7 +436,7 @@ Object {
<div
class="text-first-500 text-end text-xs "
>
0.4.1
0.4.2
</div>
</div>
<button
Expand Down Expand Up @@ -510,7 +510,7 @@ Object {
<div
class="text-first-500 text-end text-xs "
>
0.4.1
0.4.2
</div>
</div>
<button
Expand Down
3 changes: 2 additions & 1 deletion src/components/TargetHandle/TargetHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const TargetHandle = ({nodeId} : {nodeId: string}) => {
return (
<Handle
id="top"
className={`border-none w-full h-full my-1 rounded-none opacity-20 hover:bg-first-500 z-10 ${(visibleTargetHandle) ? "visible" : "hidden"}`}
className={`border-none my-1 rounded-none opacity-20 hover:bg-first-500 z-10 ${(visibleTargetHandle) ? "w-full h-full" : "w-0 h-0"}`}

type="target"
position={Position.Top}
/>
Expand Down
8 changes: 4 additions & 4 deletions src/zustandStore/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export interface State {
}

const useStore = create(devtools<State>((set, get) => ({
version: "0.4.1",
version: "0.4.2",
idCounter: initialIdCounter(initialTables, initialNodes, initialEdges) ,
associationType: "has_one",
nodes: initialNodes,
Expand Down Expand Up @@ -315,14 +315,14 @@ const useStore = create(devtools<State>((set, get) => ({
if (event.target && (typeof event.target.result === 'string')){
data = JSON.parse(event.target.result) as State;

if (["0.4.0", "0.4.1"].includes(data.version)) {
data.version = "0.4.1";
if (["0.4.0", "0.4.1", "0.4.2"].includes(data.version)) {
data.version = "0.4.2";

set(
data
)
} else {
alert(`The version of your file is v${data.version}. It is not compatible with the version used(v0.4.1).`);
alert(`The version of your file is v${data.version}. It is not compatible with the version used(v0.4.2).`);
}

}else{
Expand Down
9 changes: 5 additions & 4 deletions src/zustandStore/test/store.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const fileReader = (uploadedFile: unknown) => (
)

describe('store', () => {
it('has a "version" attribute and its value should be "0.4.1" as default', () => {
expect(useStore.getState().version).toBe("0.4.1");
it('has a "version" attribute and its value should be "0.4.2" as default', () => {
expect(useStore.getState().version).toBe("0.4.2");
});

it('has a "idCounter" attribute and its value should exist as default', () => {
Expand Down Expand Up @@ -451,7 +451,7 @@ describe('store', () => {

it('installs the file successfully', () => {

fileReader({target: {result: JSON.stringify({version: "0.4.1", idCounter: 1234})}})
fileReader({target: {result: JSON.stringify({version: "0.4.2", idCounter: 1234})}})
useStore.getState().uploadStore({target: {files: {}}} as React.ChangeEvent<HTMLInputElement>)

expect(useStore.getState().idCounter).toBe(1234);
Expand All @@ -460,6 +460,7 @@ describe('store', () => {
useStore.getState().uploadStore({target: {files: {}}} as React.ChangeEvent<HTMLInputElement>)

expect(useStore.getState().idCounter).toBe(5678);
expect(useStore.getState().version).toBe("0.4.2");
});

it('warns about the file version if it is not compatible with the version used', () => {
Expand All @@ -470,7 +471,7 @@ describe('store', () => {
useStore.getState().uploadStore({target: {files: {}}} as React.ChangeEvent<HTMLInputElement>)

expect(global.alert).toHaveBeenCalledTimes(1);
expect(global.alert).toHaveBeenCalledWith("The version of your file is v0.3.1. It is not compatible with the version used(v0.4.1).");
expect(global.alert).toHaveBeenCalledWith("The version of your file is v0.3.1. It is not compatible with the version used(v0.4.2).");
});
});

Expand Down

0 comments on commit ac49d5f

Please sign in to comment.