Skip to content

Commit d4dfa6f

Browse files
authored
Merge pull request #2474 from devtron-labs/feat/text-field
feat: update the API for CustomInput
2 parents cacf575 + 02a0f95 commit d4dfa6f

97 files changed

Lines changed: 974 additions & 1427 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ src/components/common/edge/rectangularEdge.tsx
248248
src/components/common/edge/straightEdge.tsx
249249
src/components/common/errorBoundary.tsx
250250
src/components/common/formFields/CopyButton.tsx
251-
src/components/common/formFields/CustomPassword.tsx
252251
src/components/common/formFields/DevtronSwitch.tsx
253252
src/components/common/formFields/Typeahead.tsx
254253
src/components/common/helpers/Helpers.tsx

README.md

Lines changed: 59 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,211 +1,85 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
# Devtron Dashboard
22

3-
## Available Scripts
3+
<p align="start">
4+
<a href="https://github.com/devtron-labs/devtron/releases"><img src="https://img.shields.io/github/v/release/devtron-labs/devtron"></a>
5+
<a href="https://discord.gg/jsRG5qx2gp"><img src="https://img.shields.io/discord/687207715902193673?logo=discord&label=Discord&color=5865F2&logoColor=white" alt="Join Discord"></a>
6+
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
7+
<img src="https://img.shields.io/github/contributors/devtron-labs/dashboard" alt="contributors">
8+
<img src="https://img.shields.io/github/commit-activity/m/devtron-labs/devtron" alt="Commit Activity">
9+
</p>
410

5-
In the project directory, you can run:
11+
[![Dashboard CI](https://github.com/devtron-labs/dashboard/actions/workflows/ci.yml/badge.svg)](https://github.com/devtron-labs/dashboard/actions/workflows/ci.yml)
612

7-
### `yarn start`
13+
This is the client side web app for [devtron](https://github.com/devtron-labs/devtron).
14+
This web app is written in [React](https://react.dev/) frontend-library. Uses a typescript + vite for setup.
815

9-
Runs the app in the development mode.<br>
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
16+
## Local Development
1117

12-
The page will reload if you make edits.<br>
13-
You will also see any lint errors in the console.
18+
This project uses `yarn` as package manager. By default the backend is pointed to [https://preview.devtron.ai](https://preview.devtron.ai). To change it, update the `TARGET_URL` in `./vite.config.mts` to your devtron instance url.
1419

15-
### `yarn test`
20+
- To install all dependencies and initialize the project just run the command:
1621

17-
Launches the test runner in the interactive watch mode.<br>
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19-
20-
### `yarn run build`
21-
22-
Builds the app for production to the `build` folder.<br>
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
24-
25-
The build is minified and the filenames include the hashes.<br>
26-
Your app is ready to be deployed!
27-
28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29-
30-
### `yarn run eject`
31-
32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33-
34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35-
36-
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37-
38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39-
40-
### `commit process`
41-
42-
- Now before commiting lint will run and check for errors.
43-
- It will not allow to commit if there are lint errors.
44-
- To fix them run `yarn lint-fix` (check package.json). It is not capable of fixing everything so some fixes has to be done manually.
45-
46-
### Do's
47-
48-
- Try to make only one state per page rest every thing shall be pure.
49-
- A method should do one and only one thing.
50-
- Do function and variable namings so good you don't need comments.
51-
- While making smaller Components make them reusable.
52-
- Do most of the heavy lifting tasks inside smaller components not in the state component.
53-
- Do all the parsing and error handling on service state component should not get anything more than (success and data) or (error and data).
54-
- Use BEM to name CSS classes and structure it.
55-
56-
### Don'ts
57-
58-
- Don't add if else on render add functions which render checks on smaller functions.
59-
- Don't add IDs for CSS if done correctly you never need ids.
60-
- Don't add unnecessary Indentations it doesn't improve readability.
61-
- Never add checks on the basis of text.
62-
- Don't use float use display instead, use display flex-box, inline, inline-block.
63-
- Don't use mix type methods in a class
64-
65-
### Sentry Config
66-
67-
- SENTRY_AUTH_TOKEN=""
68-
- SENTRY_ORG="devtron-labs"
69-
- SENTRY_PROJECT="dashboard"
70-
- DSN=""
71-
- SENTRY_TRACES_SAMPLE_RATE="0.2"
72-
73-
### Sentry sourcemap upload
74-
75-
```console
76-
foo@bar:~$ sh sentry.sh
22+
```bash
23+
yarn install
7724
```
7825

79-
### Set custom sentry environment during production deployment, default is staging
26+
- To start a dev server at [http://localhost:3000](http://localhost:3000), execute:
8027

81-
```console
82-
foo@bar~$ docker run -p 3000:80 -e SENTRY_ENV=my-custom-env -t artifact/tag
28+
```bash
29+
yarn start
8330
```
8431

85-
### Disable sentry error logging during production deployment, default enabled
32+
Check out `package.json` for more scripts.
8633

87-
```console
88-
foo@bar~$ docker run -p 3000:80 -e ENTRY_ERROR_ENABLED=false -t artifact/tag
89-
```
34+
### Commit Process
9035

91-
### Disable sentry performance monitoring during production deployment, default enabled
36+
- We use husky to run compile and lint-staged before commit staged changes
37+
- If husky finds any errors during either the compilation stage or linting stage, the attempt to commit will fail
38+
- To fix auto-fixable issues, execute:
9239

93-
```console
94-
foo@bar~$ docker run -p 3000:80 -e SENTRY_PERFORMANCE_ENABLED=false -t artifact/tag
40+
```bash
41+
yarn lint-fix
9542
```
9643

97-
### Enable Hotjar during production deployment, default disabled
98-
99-
```console
100-
foo@bar~$ docker run -p 3000:80 -e HOTJAR_ENABLED=false -t artifact/tag
101-
```
102-
103-
### Enable google analytics during production deployment, default disabled
104-
105-
```console
106-
foo@bar~$ docker run -p 3000:80 -e GA_ENABLED=true -t artifact/tag
107-
```
108-
109-
### Create test coverage report and save summary in report.txt
110-
111-
```console
112-
foo@bar~$ npm run test -- --coverage --watchAll=false > report.txt
113-
```
114-
115-
### Upload Summary on slack
116-
117-
```console
118-
foo@bar~$ python uploadTestReport.py
119-
```
120-
121-
### Run Following Scripts after release
44+
### Do's
12245

123-
```console
124-
foo@bar~$ sh sentry.sh
125-
foo@bar~$ npm run test -- --coverage --watchAll=false > report.txt
126-
foo@bar~$ python uploadTestReport.py
127-
```
46+
- Try to make only one state per page rest every thing shall be pure.
47+
- A method should do one and only one thing.
48+
- Do function and variable namings so good you don't need comments.
49+
- While making smaller Components make them reusable.
50+
- Do most of the heavy lifting tasks inside smaller components not in the state component.
51+
- Do all the parsing and error handling on service state component should not get anything more than (success and data) or (error and data).
52+
- Use BEM to name CSS classes and structure it.
12853

129-
### Development setup with proxy.
130-
131-
#### **`vite.config.ts`**
132-
Update the `vite.config.ts` file to include the proxy configuration.
133-
In proxy object, add the target URL of the orchestrator and grafana.
134-
135-
```js
136-
server: {
137-
port: 3000,
138-
proxy: {
139-
'/orchestrator': {
140-
target: 'https://preview.devtron.ai/',
141-
changeOrigin: true,
142-
},
143-
'/grafana': 'https://preview.devtron.ai/',
144-
},
145-
}
146-
```
54+
### Don'ts
14755

148-
#### **`.env.development`**
56+
- Don't add if else on render add functions which render checks on smaller functions.
57+
- Don't add IDs for CSS if done correctly you never need ids.
58+
- Don't add unnecessary Indentations it doesn't improve readability.
59+
- Never add checks on the basis of text.
60+
- Don't use float use display instead, use display flex-box, inline, inline-block.
61+
- Don't use mix type methods in a class
14962

150-
```console
151-
VITE_GRAFANA_ORG_ID=2
152-
REACT_APP_EDITOR=code
153-
VITE_ORCHESTRATOR_ROOT=/orchestrator
154-
REACT_APP_PASSWORD=argocd-server-74b7b94945-nxxnh
155-
```
63+
## How do I make a contribution?
15664

157-
### Development setup without proxy.
65+
Never made an open source contribution before? Wondering how contributions work in our project? Here's a quick rundown!
15866

159-
#### **`.env.development`**
67+
- Find an issue that you are interested in addressing or a feature that you would like to add.
68+
- Fork this repository to your local GitHub organization. This means that you will have a copy of the repository under your-GitHub-username/repository-name.
69+
- Clone the repository to your local machine using:
16070

161-
```console
162-
VITE_GRAFANA_ORG_ID=2
163-
REACT_APP_EDITOR=code
164-
VITE_ORCHESTRATOR_ROOT=http://demo.devtron.info:32080/orchestrator
165-
REACT_APP_PASSWORD=argocd-server-74b7b94945-nxxnh
71+
```bash
72+
git clone https://github.com/github-username/dashboard.git
16673
```
16774

168-
## How do I make a contribution?
169-
170-
Never made an open source contribution before? Wondering how contributions work in our project? Here's a quick rundown!
171-
172-
- Find an issue that you are interested in addressing or a feature that you would like to add.
173-
- Fork the repository https://github.com/devtron-labs/dashboard.git to your local GitHub organization. This means that you will have a copy of the repository under your-GitHub-username/repository-name.
174-
- Clone the repository to your local machine using
175-
`git clone https://github.com/github-username/dashboard.git.`
176-
- Create a new branch for your fix using `git checkout -b branch-name-here`.
177-
- Make the appropriate changes for the issue you are trying to address or the feature that you want to add.
178-
- Use `git add insert-paths-of-changed-files-here` to add the file contents of the changed files to the "snapshot" git uses to manage the state of the project, also known as the index.
179-
- Use `git commit -m ‘Insert a short message of the changes made here’` to store the contents of the index with a descriptive message.
180-
- Push the changes to the remote repository using `git push origin branch-name-here`.
181-
- Submit a pull request to the upstream repository.
182-
- Title the pull request with a short description of the changes made and the issue or bug number associated with your change. For example, you can title an issue like so "Added failsafe check to resolve #1423".
183-
- In the description of the pull request, explain the changes that you made, any issues you think exist with the pull request you made, and any questions you have for the maintainer. It's OK if your pull request is not perfect (no pull request is), the reviewer will be able to help you fix any problems and improve it!
184-
- Wait for the pull request to be reviewed by a maintainer.
185-
- Make changes to the pull request if the reviewing maintainer recommends them.
186-
- Celebrate your success after your pull request is merged!
187-
188-
## How do I run it locally?
189-
190-
First you need to have the backend project up and running and the dashboard repo cloned on your machine after that follow the below process:
191-
192-
- Run yarn in the dashboard repo root
193-
- Open the project in your preferred IDE
194-
- Open the `vite.config.ts` file
195-
- Change the target URL of the orchestrator. Replace it with the URL of your orchestrator
196-
- Save the file
197-
- Run `yarn start`
198-
- Go to `localhost:3000`
199-
- Click Login as administrator
200-
- Provide Admin as username and password from Devtron BE
201-
- After login, you will be able to see the dashboard running on your local machine
202-
203-
## Code walkthrough/Project structure
204-
205-
We have a `src` folder at the root level which holds everything related to the dashboard
206-
207-
- `src/assets` have all the image folders like logo, icons, gif etc. These folders have, the related files
208-
- `src/components` have all the components used in the project further divided into folder component specific folders. Specific component folders hold their local CSS file specific to that component, service file specific to that component, and some required child component.tsx as well
209-
- `src/config` has config files like constants, route, etc which holds all the constants, route path constants respectively
210-
- `src/css has` the common CSS files
211-
- `src/services` have the common services used across projects
75+
- Create a new branch for your fix using `git checkout -b branch-name-here`.
76+
- Make the appropriate changes for the issue you are trying to address or the feature that you want to add.
77+
- Use `git add insert-paths-of-changed-files-here` to add the file contents of the changed files to the "snapshot" git uses to manage the state of the project, also known as the index.
78+
- Use `git commit -m ‘Insert a short message of the changes made here’` to store the contents of the index with a descriptive message.
79+
- Push the changes to the remote repository using `git push origin branch-name-here`.
80+
- Submit a pull request to the upstream repository.
81+
- Title the pull request with a short description of the changes made and the issue or bug number associated with your change. For example, you can title an issue like so `fix: Added failsafe check to resolve #1423`.
82+
- In the description of the pull request, explain the changes that you made, any issues you think exist with the pull request you made, and any questions you have for the maintainer. It's OK if your pull request is not perfect (no pull request is), the reviewer will be able to help you fix any problems and improve it!
83+
- Wait for the pull request to be reviewed by a maintainer.
84+
- Make changes to the pull request if the reviewing maintainer recommends them.
85+
- Celebrate your success after your pull request is merged!

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.7.2",
7+
"@devtron-labs/devtron-fe-common-lib": "1.7.3",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/Pages/GlobalConfigurations/Authorization/APITokens/CreateAPIToken.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ const CreateAPIToken = ({
263263
onChange={onChangeHandler}
264264
error={formDataErrorObj.invalidName && formDataErrorObj.invalidNameMessage}
265265
label="Name"
266-
isRequiredField
266+
required
267267
/>
268268
<Textarea
269269
label="Description"

src/Pages/GlobalConfigurations/Authorization/APITokens/EditAPIToken.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ const EditAPIToken = ({
228228
<div className="flexbox-col dc__gap-16">
229229
{renderRegenerateInfoBar()}
230230
<CustomInput
231+
placeholder="Enter name"
231232
label="Name"
232233
data-testid="api-token-name-textbox"
233234
value={editData.name}

src/Pages/GlobalConfigurations/Authorization/PermissionGroups/AddEdit/PermissionGroupForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const PermissionGroupForm = ({ isAddMode }: { isAddMode: boolean }) => {
178178
value={name.value}
179179
data-testid="permission-group-name-textbox"
180180
onChange={handleGroupNameChange}
181-
isRequiredField
181+
required
182182
error={name.error}
183183
placeholder="Eg. Project managers"
184184
/>

src/Pages/GlobalConfigurations/Authorization/SSOLoginServices/SSOLogin.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,10 @@ class SSOLogin extends Component<SSOLoginProps, SSOLoginState> {
800800
<CustomInput
801801
value={this.state.ssoConfig.url || window.__ORCHESTRATOR_ROOT__}
802802
onChange={this.handleURLChange}
803-
data-testid="sso-url-input"
804803
name="sso-url"
805804
label="URL"
806-
isRequiredField
805+
placeholder="Enter URL"
806+
required
807807
error={this.state.isError.url}
808808
/>
809809
<div className="flex left fw-4 pt-4">

src/Pages/GlobalConfigurations/Authorization/Shared/components/K8sObjectPermissions/K8sListItemCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
ButtonVariantType,
3232
ButtonStyleType,
3333
ResourceListPayloadType,
34+
SelectPickerOptionType,
3435
} from '@devtron-labs/devtron-fe-common-lib'
3536
import { K8S_EMPTY_GROUP } from '@Components/ResourceBrowser/Constants'
3637
import {
@@ -79,7 +80,7 @@ const K8sListItemCard = ({
7980
}: K8sListItemCardType) => {
8081
const { customRoles } = useAuthorizationContext()
8182
const { showStatus, userStatus } = usePermissionConfiguration()
82-
const [clusterOptions, setClusterOptions] = useState<OptionType[]>([])
83+
const [clusterOptions, setClusterOptions] = useState<SelectPickerOptionType<string>[]>([])
8384
const [processedData, setProcessedData] = useState<Map<string, K8SObjectType>>()
8485
const [allInKindMapping, setAllInKindMapping] = useState<OptionType[]>([])
8586
const [

src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,32 @@ export const ClusterEnvironmentDrawer = ({
254254
<form
255255
className="flex-grow-1 flexbox-col mh-0"
256256
onSubmit={handleSubmit(namespaceLabels.labels ? withLabelEditValidation : onValidation())}
257+
noValidate
257258
>
258259
<div className="dc__overflow-auto p-20 flex-grow-1">
259260
<div className="mb-16">
260261
<CustomInput
261-
dataTestid="environment-name"
262-
labelClassName="dc__required-field"
263262
disabled={!!environmentName}
264263
placeholder={id ? 'sample-env-name' : 'Eg. production'}
265264
value={data.environmentName}
266265
error={errors.environmentName}
267266
{...register('environmentName')}
268267
label="Environment Name"
269268
autoFocus={!id}
270-
noTrim
269+
shouldTrim={false}
270+
required
271271
/>
272272
</div>
273273
<div className="mb-16">
274274
<CustomInput
275-
dataTestid="enter-namespace"
276-
labelClassName={isVirtual ? '' : 'dc__required-field'}
277275
disabled={!!namespace}
278276
placeholder={id ? 'sample-namespace' : 'Eg. prod'}
279277
value={data.namespace}
280278
error={errors.namespace}
281279
{...register('namespace')}
282280
label="Namespace"
283-
noTrim
281+
shouldTrim={false}
282+
required={!isVirtual}
284283
/>
285284
</div>
286285
{!isVirtual && (
@@ -317,7 +316,7 @@ export const ClusterEnvironmentDrawer = ({
317316
{...register('description')}
318317
label="Description (Maximum 40 characters allowed)"
319318
autoFocus={!!id}
320-
noTrim
319+
shouldTrim={false}
321320
/>
322321
</div>
323322
{EnvironmentLabels && !isVirtual && (

0 commit comments

Comments
 (0)