DiSSCo / disscover

Search, discover and act upon data within the DiSSCo digital infrastructure.
https://dev.dissco.tech
Apache License 2.0
1 stars 0 forks source link

Type script update #11

Closed TomDijkema closed 1 year ago

TomDijkema commented 1 year ago

The Type Script Update:

This Pull Request updates the whole application to make use of Type Script in order to make the Javascript code strongly typed and help with type indications in code. Basically it becomes to indicate types of variables when programming and should help future contributors understand the code.

For the implementation of Type Script a general file containing all common types has been created. Types like: User, Specimen, DigitalMedia and Annotation are imported frequently and form the basis for a lot of the content. Other, less significant types, like element props, have been integrated into the code itself.

Apart from Type Script, has every file of the application been revised in order to make some quality of life changes with newer, more efficient learnt techniques. For example: a Redux Store has been integrated into the application which can hold primary scoped states which relieves a lot of components from setting loads of props to children and have the advantage to be callable and mutable from every location. Example: when landing on the Specimen Page, it will look if there is an active specimen in the specimen slice of the store, if not it will grab the specimen from the database and store it, able to persist it through navigating to other pages. Only a refresh causes the Redux store to be reconfigured.

All API functions have been transformed to asynchronous functions which return a promise. The promise can be fetched by the component that called on the API function to extract the returned data. This method gets rid of all the callbacks in the code which makes it more fluent and readable from top to bottom. Additionally, all functions have been transformed to arrow functions (example: function functionName() {} now is: const functionName = () => {}.

Introduced more comments in the code to explain what is happening. Also to split up the import statements by their respective source.

Changed the templates' folder name to: components. Changed the order of components recurring in folders: instead of using a 'body' in between the parent and child components, primary child components are now imported into the parent component which also includes most overarching functionality. Otherwise, specific functionality for components has been tried to keep to the child components them self.

The Annotate Modal has been refined even more to the point it can almost be imported at any point of the code, as long as there is a valid object (specimen, digitalMedia) to be annotated.

This update still needs some patches to resolve minor issues.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication