eehitus-building-project-file-ui 0.13.4 → 0.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,41 +1,193 @@
1
- ## Description
1
+ # eehitus-building-project-file-ui library
2
2
 
3
- Previously known as either: ehr-minu-menetlused-ui or ehr-my-views-ui
3
+ E-Ehitus building project file UI is the library used by eehitus-document-ui to manage certain documents file section.
4
4
 
5
- This is a UI project for eehitus-my-proceeding-api. Previously known as ehr-minu-menetlused-api
5
+ ---
6
6
 
7
- ## How to run?
7
+ ## Table of Contents
8
8
 
9
- to start the project on local. First do yarn install and yarn start in root folder.
10
- Second thing is to open up another terminal with the first on running and cd in to example folder. There also do yarn install and yarn run.
9
+ * [Getting started with development](#getting-started-with-development)
10
+ * [Prerequisites](#prerequisites)
11
+ * [Running locally](#running-locally)
12
+ * [Local development](#local-development)
13
+ * [Development patterns overview](#development-patterns-overview)
14
+ * [Common components](#common-components)
15
+ * [Form validation](#form-validation)
16
+ * [Translations](#translations)
17
+ * [API requests](#api-requests)
18
+ * [Testing](#testing)
19
+ * [Debugging with source-maps](#debugging-with-source-maps)
20
+ * [Branching](#branching)
11
21
 
12
- ## Available Scripts
22
+ ---
13
23
 
14
- In the project directory, you can run:
24
+ ## Getting started with development
15
25
 
16
- ### `yarn start`
26
+ ### Prerequisites
17
27
 
18
- Runs the app in the development mode.<br />
19
- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
28
+ - Node.js (v18.20.6)
29
+ - Yarn (v1.x)
20
30
 
21
- The page will reload if you make edits.<br />
22
- You will also see any lint errors in the console.
31
+ * Recommendation:
32
+ * [Node version manager](https://github.com/nvm-sh/nvm)
33
+ * [Node version manager for Windows](https://github.com/coreybutler/nvm-windows)
23
34
 
24
- ### `yarn test`
35
+ ### Running locally
25
36
 
26
- Launches the test runner in the interactive watch mode.<br />
37
+ Follow these steps:
27
38
 
39
+ * Create .npmrc file in root of project
28
40
 
29
- ## Generating OpenApi API
41
+ #### Template file location: `./config/.npmrc-template`
30
42
 
31
- **openapi-generator version = 6.6.0**
43
+ * You can run terminal command in root project folder:
44
+ ```sh
45
+ cp ./config/.npmrc-template ./.npmrc
46
+ ```
47
+ * For when running Windows Command Promt(cmd)
48
+ ```sh
49
+ copy config\.npmrc-template .npmrc
50
+ ```
51
+
52
+ #### If you have setup the env variables and created the .npmrc file run next commands:
53
+ * `npm i yarn -g` - If you don't have yarn installed locally for given node version
54
+ * `yarn install`
55
+ * `yarn start`
56
+
57
+ ### Local development
58
+
59
+ `yarn start` opens `http://localhost:3000`
60
+
61
+ You have to look for BrowserRouter definition to find the urls you can navigate to.
62
+ Usually can be found at `./src/App.tsx` or in the component rendered inside it.
63
+
64
+ * `./public/config.js` contains all the endpoint URL-s for different microservices.
65
+ * Default endpoint should end with `/v1`
66
+ * You can specify a certain API to point to your projects API `/project_ingress`
67
+
68
+ ---
69
+
70
+ ## Development patterns overview
71
+
72
+ ---
73
+
74
+ ### Common components
75
+ * [eehitus-ui-extras](https://git.ehr.ee/ehr/ehr-k8s-pipeline/ui-extras)
76
+ * New common business logic components or enums, should be added to this library
77
+ * [TEDI library](https://github.com/TEHIK-EE/tedi-design-system) - E-Ehitus is moving to use Estonian TEDI library for react.
78
+ * New features should be developed using them, if possible.
79
+ * [ehr-components](https://git.ehr.ee/ehr/ehr-k8s-pipeline/ehr-components) Old components
80
+ * These are old components and you should not create new functionality with them if possible.
81
+ * [eehitus-visuaal](https://git.ehr.ee/ehr/ehr-k8s-pipeline/e-ehitus_visuaal) eehitus-ui has usage of global styles
82
+ * When making changes there, make sure your change does not have impact to the rest of the UI libraries
83
+ ---
84
+
85
+ ### Form validation
86
+
87
+ For form validation we use [Yup](https://www.npmjs.com/package/yup).
88
+
89
+ If you have not used it before look find examples used in eehitus-document-ui.
90
+
91
+ For an Example find usage of: `useYupValidation`
92
+
93
+ ---
94
+
95
+ ### Translations
96
+
97
+ All the translations exist in `./src/translations`
98
+
99
+ Webpack at build time merges all the translations into 3 specific files:
100
+ * example_project_name_et.json
101
+ * example_project_name_en.json
102
+ * example_project_name_ru.json
103
+
104
+ To add new translation files under `./src/translations`
105
+
106
+ Follow that the file ends with `*_et.json` pattern
107
+
108
+ ---
109
+
110
+ ### API requests
111
+
112
+ We use axios and we generate the entire API interface for all service requests using OpenApi Generator.
113
+
114
+ The API clients are located in `./src/services`
115
+
116
+ #### Generating API with OpenApi Generator
117
+
118
+ openapi-generator version = 6.6.0
32
119
 
33
120
  version 6 is required for axios 0.x
121
+ ```cmd
122
+ $ npm install -g @openapitools/openapi-generator-cli
123
+ ```
124
+ ```cmd
125
+ $ openapi-generator-cli version-manager set 6
126
+ ```
127
+ If backend is running and openapi doc is accessible (change the port to your matching BE running port)
128
+ ```cmd
129
+ $ openapi-generator-cli generate -i http://localhost:9000/v3/api-docs -g typescript-axios --additional-properties=modelPropertyNaming=original --type-mappings=DateTime=Date --type-mappings=object=any
130
+ ```
131
+ If you need to update service clients with master yaml
132
+ * Find the yaml in [Gitlab swagger project](https://git.ehr.ee/ehr/ehr-k8s-pipeline/swaggerui/-/tree/master/src/swaggers?ref_type=heads) and download it
133
+ * Create a new folder
134
+ * Open terminal in the same folder with the yaml
135
+ ```cmd
136
+ $ openapi-generator-cli generate -i rename-this-to-your-file.yaml -g typescript-axios --additional-properties=modelPropertyNaming=original --type-mappings=DateTime=Date --type-mappings=object=any
137
+ ```
138
+ * Copy the .ts files into your projects `./src/services/you-api` folder
139
+
140
+
141
+ ---
142
+
143
+ ### Testing
144
+
145
+ For library unit testing we use Jest.
146
+
147
+ [E2E Tests](https://git.ehr.ee/ehr/ehr-k8s-pipeline/ehr-e2e) are located in this project.
148
+
149
+ ---
150
+
151
+ ### Debugging with source-maps
152
+
153
+ If you have developed locally and when you update the library version in eehitus-ui project and start receiving errors,
154
+ it's wise to generate local build using `yarn cibuild:debug`
155
+
156
+ This generates `./dist` folder
157
+
158
+ Then go into `eehitus-ui` project
159
+ * Remove .cache `eehitus-ui/node_modules/.cache`
160
+ * Remove old dist `eehitus-ui/node_modules/eehitus-*project_name*/dist`
161
+ * Copy your project local debug build dist folder to `eehitus-ui/node_modules/eehitus-*project_name*`
162
+ * Start `eehitus-ui` using `yarn start` now the error should have source-maps and debugging it, should be easier.
163
+
164
+ ---
165
+
166
+ ### Branching
167
+
168
+ For developing we use `Git Flow` branching pattern
169
+
170
+ Example branch names
171
+ * release/project_name
172
+ * fix/TICKET_NR-short-description
173
+ * feature/TICKET_NR-short-description
174
+ * company_name/feature/TICKET_NR-short-description
175
+
176
+ We don't recommend creating `develop` branch.
177
+
178
+ Good approach is to create a `release/*` branch and all new development in `company_name/feature/*` you create a Merge Request against `release/*`
179
+
180
+ You create tags on the `release/*` branch and you have a separate `project namespace` in rancher where you update `eehitus-ui`
34
181
 
35
- `$ openapi-generator-cli version-manager set 6`
36
- `$ openapi-generator-cli generate -i http://localhost:9090/v3/api-docs -g typescript-axios --additional-properties=modelPropertyNaming=original --type-mappings=DateTime=Date --type-mappings=object=any`
182
+ ---
37
183
 
38
- ## Form Validation
184
+ ### Publishing
39
185
 
40
- Validation with YUP, using a custom hook useYupValidation.ts.
186
+ To get new version of the library up.
41
187
 
188
+ 1. Go to [Gitlab](https://git.ehr.ee/)
189
+ 2. Find your project and go to tags page [document-ui as example](https://git.ehr.ee/ehr/ehr-k8s-pipeline/ehr-document-ui/-/tags)
190
+ 3. Create a New tag, specify version in semver pattern `version-*.*.*` add a description of project tag or other description
191
+ 4. Update your projects `eehitus-ui/package.json` version and run `yarn` to generate new `yarn.lock` file and commit it
192
+ 5. Create a New tag for `eehitus-ui`
193
+ 6. Update the `eehitus-ui` in rancher project_namespace, you should never update the `v1` ingress `eehitus-ui`. `v1` represents master and should always be in stable state.