Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update the API for CustomInput #2474

Open
wants to merge 34 commits into
base: feat/info-bar
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9d43b19
refactor: typing clean up for custom input
eshankvaish Jan 29, 2025
a458472
feat: add storybook for text field
eshankvaish Jan 29, 2025
3b807cd
fix: styling issues on login page
eshankvaish Jan 29, 2025
5a27b42
refactor: code clean up
eshankvaish Jan 29, 2025
360ec02
feat: add util classes
eshankvaish Jan 30, 2025
947cfcc
Merge branch 'feat/fe-enhancements' of github.com:devtron-labs/dashbo…
eshankvaish Jan 30, 2025
00ca8f0
fix: padding in host url input
eshankvaish Jan 30, 2025
6202055
Revert "feat: add util classes"
eshankvaish Jan 30, 2025
08d1f38
fix: typing in button stories
eshankvaish Jan 31, 2025
b86660d
feat: add support for end icon
eshankvaish Jan 31, 2025
9e5b93e
refactor: remove unused styling
eshankvaish Jan 31, 2025
5ab4087
fix: styling issues
eshankvaish Jan 31, 2025
217e75e
feat: stories for password field
eshankvaish Jan 31, 2025
e79c30c
feat: update storybook with tooltip label
eshankvaish Jan 31, 2025
eaeddf6
refactor: replace Protected Input with PasswordField
eshankvaish Jan 31, 2025
3b6f722
chore: version bump
eshankvaish Jan 31, 2025
65a6277
refactor: update select in docker and label
eshankvaish Jan 31, 2025
87b0528
refactor: usage of custom input
eshankvaish Jan 31, 2025
9c7b9c0
Merge branch 'develop' of github.com:devtron-labs/dashboard into feat…
eshankvaish Feb 13, 2025
d09cbd8
Merge branch 'develop' of github.com:devtron-labs/dashboard into feat…
eshankvaish Feb 13, 2025
8986a74
fix: custom input
eshankvaish Feb 13, 2025
fdf97f8
fix: update the select in ephemeral container drawer
eshankvaish Feb 13, 2025
b0fd0ea
fix: story book issues
eshankvaish Feb 14, 2025
9364e73
feat: update select and input in custom logs modal
eshankvaish Feb 14, 2025
0cdcba6
Merge branch 'feat/info-bar' of github.com:devtron-labs/dashboard int…
eshankvaish Feb 14, 2025
363a16c
Merge branch 'feat/info-bar' of github.com:devtron-labs/dashboard int…
eshankvaish Feb 14, 2025
677c788
fix: update custom input in gitops configuration
eshankvaish Feb 14, 2025
eb15c41
fix: styling in webhook details modal
eshankvaish Feb 14, 2025
82be184
fix: missing props for custom input usage
eshankvaish Feb 14, 2025
46728d0
refactor: replace with custom input
eshankvaish Feb 14, 2025
14f0360
fix: remove label
eshankvaish Feb 14, 2025
2521c18
fix: error state in create chart group
eshankvaish Feb 14, 2025
afa6e2c
fix: alignment issue in task detail
eshankvaish Feb 14, 2025
6a4974d
feat: update readme
eshankvaish Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ src/components/common/edge/rectangularEdge.tsx
src/components/common/edge/straightEdge.tsx
src/components/common/errorBoundary.tsx
src/components/common/formFields/CopyButton.tsx
src/components/common/formFields/CustomPassword.tsx
src/components/common/formFields/DevtronSwitch.tsx
src/components/common/formFields/Typeahead.tsx
src/components/common/helpers/Helpers.tsx
Expand Down
244 changes: 59 additions & 185 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,211 +1,85 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
# Devtron Dashboard

## Available Scripts
<p align="start">
<a href="https://github.com/devtron-labs/devtron/releases"><img src="https://img.shields.io/github/v/release/devtron-labs/devtron"></a>
<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>
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
<img src="https://img.shields.io/github/contributors/devtron-labs/dashboard" alt="contributors">
<img src="https://img.shields.io/github/commit-activity/m/devtron-labs/devtron" alt="Commit Activity">
</p>

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

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

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

The page will reload if you make edits.<br>
You will also see any lint errors in the console.
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.

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

Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn run build`

Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

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.

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.

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.

### `commit process`

- Now before commiting lint will run and check for errors.
- It will not allow to commit if there are lint errors.
- 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.

### Do's

- Try to make only one state per page rest every thing shall be pure.
- A method should do one and only one thing.
- Do function and variable namings so good you don't need comments.
- While making smaller Components make them reusable.
- Do most of the heavy lifting tasks inside smaller components not in the state component.
- Do all the parsing and error handling on service state component should not get anything more than (success and data) or (error and data).
- Use BEM to name CSS classes and structure it.

### Don'ts

- Don't add if else on render add functions which render checks on smaller functions.
- Don't add IDs for CSS if done correctly you never need ids.
- Don't add unnecessary Indentations it doesn't improve readability.
- Never add checks on the basis of text.
- Don't use float use display instead, use display flex-box, inline, inline-block.
- Don't use mix type methods in a class

### Sentry Config

- SENTRY_AUTH_TOKEN=""
- SENTRY_ORG="devtron-labs"
- SENTRY_PROJECT="dashboard"
- DSN=""
- SENTRY_TRACES_SAMPLE_RATE="0.2"

### Sentry sourcemap upload

```console
foo@bar:~$ sh sentry.sh
```bash
yarn install
```

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

```console
foo@bar~$ docker run -p 3000:80 -e SENTRY_ENV=my-custom-env -t artifact/tag
```bash
yarn start
```

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

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

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

```console
foo@bar~$ docker run -p 3000:80 -e SENTRY_PERFORMANCE_ENABLED=false -t artifact/tag
```bash
yarn lint-fix
```

### Enable Hotjar during production deployment, default disabled

```console
foo@bar~$ docker run -p 3000:80 -e HOTJAR_ENABLED=false -t artifact/tag
```

### Enable google analytics during production deployment, default disabled

```console
foo@bar~$ docker run -p 3000:80 -e GA_ENABLED=true -t artifact/tag
```

### Create test coverage report and save summary in report.txt

```console
foo@bar~$ npm run test -- --coverage --watchAll=false > report.txt
```

### Upload Summary on slack

```console
foo@bar~$ python uploadTestReport.py
```

### Run Following Scripts after release
### Do's

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

### Development setup with proxy.

#### **`vite.config.ts`**
Update the `vite.config.ts` file to include the proxy configuration.
In proxy object, add the target URL of the orchestrator and grafana.

```js
server: {
port: 3000,
proxy: {
'/orchestrator': {
target: 'https://preview.devtron.ai/',
changeOrigin: true,
},
'/grafana': 'https://preview.devtron.ai/',
},
}
```
### Don'ts

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

```console
VITE_GRAFANA_ORG_ID=2
REACT_APP_EDITOR=code
VITE_ORCHESTRATOR_ROOT=/orchestrator
REACT_APP_PASSWORD=argocd-server-74b7b94945-nxxnh
```
## How do I make a contribution?

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

#### **`.env.development`**
- Find an issue that you are interested in addressing or a feature that you would like to add.
- 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.
- Clone the repository to your local machine using:

```console
VITE_GRAFANA_ORG_ID=2
REACT_APP_EDITOR=code
VITE_ORCHESTRATOR_ROOT=http://demo.devtron.info:32080/orchestrator
REACT_APP_PASSWORD=argocd-server-74b7b94945-nxxnh
```bash
git clone https://github.com/github-username/dashboard.git
```

## How do I make a contribution?

Never made an open source contribution before? Wondering how contributions work in our project? Here's a quick rundown!

- Find an issue that you are interested in addressing or a feature that you would like to add.
- 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.
- Clone the repository to your local machine using
`git clone https://github.com/github-username/dashboard.git.`
- Create a new branch for your fix using `git checkout -b branch-name-here`.
- Make the appropriate changes for the issue you are trying to address or the feature that you want to add.
- 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.
- Use `git commit -m ‘Insert a short message of the changes made here’` to store the contents of the index with a descriptive message.
- Push the changes to the remote repository using `git push origin branch-name-here`.
- Submit a pull request to the upstream repository.
- 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".
- 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!
- Wait for the pull request to be reviewed by a maintainer.
- Make changes to the pull request if the reviewing maintainer recommends them.
- Celebrate your success after your pull request is merged!

## How do I run it locally?

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:

- Run yarn in the dashboard repo root
- Open the project in your preferred IDE
- Open the `vite.config.ts` file
- Change the target URL of the orchestrator. Replace it with the URL of your orchestrator
- Save the file
- Run `yarn start`
- Go to `localhost:3000`
- Click Login as administrator
- Provide Admin as username and password from Devtron BE
- After login, you will be able to see the dashboard running on your local machine

## Code walkthrough/Project structure

We have a `src` folder at the root level which holds everything related to the dashboard

- `src/assets` have all the image folders like logo, icons, gif etc. These folders have, the related files
- `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
- `src/config` has config files like constants, route, etc which holds all the constants, route path constants respectively
- `src/css has` the common CSS files
- `src/services` have the common services used across projects
- Create a new branch for your fix using `git checkout -b branch-name-here`.
- Make the appropriate changes for the issue you are trying to address or the feature that you want to add.
- 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.
- Use `git commit -m ‘Insert a short message of the changes made here’` to store the contents of the index with a descriptive message.
- Push the changes to the remote repository using `git push origin branch-name-here`.
- Submit a pull request to the upstream repository.
- 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`.
- 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!
- Wait for the pull request to be reviewed by a maintainer.
- Make changes to the pull request if the reviewing maintainer recommends them.
- Celebrate your success after your pull request is merged!
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ const CreateAPIToken = ({
onChange={onChangeHandler}
error={formDataErrorObj.invalidName && formDataErrorObj.invalidNameMessage}
label="Name"
isRequiredField
required
/>
<Textarea
label="Description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const EditAPIToken = ({
<div className="flexbox-col dc__gap-16">
{renderRegenerateInfoBar()}
<CustomInput
placeholder="Enter name"
label="Name"
data-testid="api-token-name-textbox"
value={editData.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const PermissionGroupForm = ({ isAddMode }: { isAddMode: boolean }) => {
value={name.value}
data-testid="permission-group-name-textbox"
onChange={handleGroupNameChange}
isRequiredField
required
error={name.error}
placeholder="Eg. Project managers"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,10 @@ class SSOLogin extends Component<SSOLoginProps, SSOLoginState> {
<CustomInput
value={this.state.ssoConfig.url || window.__ORCHESTRATOR_ROOT__}
onChange={this.handleURLChange}
data-testid="sso-url-input"
name="sso-url"
label="URL"
isRequiredField
placeholder="Enter URL"
required
error={this.state.isError.url}
/>
<div className="flex left fw-4 pt-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
ButtonVariantType,
ButtonStyleType,
ResourceListPayloadType,
SelectPickerOptionType,
} from '@devtron-labs/devtron-fe-common-lib'
import { K8S_EMPTY_GROUP } from '@Components/ResourceBrowser/Constants'
import {
Expand Down Expand Up @@ -79,7 +80,7 @@ const K8sListItemCard = ({
}: K8sListItemCardType) => {
const { customRoles } = useAuthorizationContext()
const { showStatus, userStatus } = usePermissionConfiguration()
const [clusterOptions, setClusterOptions] = useState<OptionType[]>([])
const [clusterOptions, setClusterOptions] = useState<SelectPickerOptionType<string>[]>([])
const [processedData, setProcessedData] = useState<Map<string, K8SObjectType>>()
const [allInKindMapping, setAllInKindMapping] = useState<OptionType[]>([])
const [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,29 +258,26 @@
<div className="dc__overflow-auto p-20 flex-grow-1">
<div className="mb-16">
<CustomInput
dataTestid="environment-name"
labelClassName="dc__required-field"
disabled={!!environmentName}
placeholder={id ? 'sample-env-name' : 'Eg. production'}
value={data.environmentName}
error={errors.environmentName}
{...register('environmentName')}
label="Environment Name"
autoFocus={!id}
noTrim
shouldTrim={false}

Check failure on line 268 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx

View workflow job for this annotation

GitHub Actions / ci

Type '{ label: string; autoFocus: boolean; shouldTrim: boolean; onChange: (e: any) => void; onBlur: () => void; onFocus: () => void; name: keyof ClusterEnvironmentDrawerFormProps; disabled: boolean; placeholder: string; value: string; error: string[]; }' is not assignable to type 'IntrinsicAttributes & CustomInputProps'.
/>
</div>
<div className="mb-16">
<CustomInput
dataTestid="enter-namespace"
labelClassName={isVirtual ? '' : 'dc__required-field'}
disabled={!!namespace}
placeholder={id ? 'sample-namespace' : 'Eg. prod'}
value={data.namespace}
error={errors.namespace}
{...register('namespace')}
label="Namespace"
noTrim
shouldTrim={false}

Check failure on line 279 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx

View workflow job for this annotation

GitHub Actions / ci

Type '{ label: string; shouldTrim: boolean; required: boolean; onChange: (e: any) => void; onBlur: () => void; onFocus: () => void; name: keyof ClusterEnvironmentDrawerFormProps; disabled: boolean; placeholder: string; value: string; error: string[]; }' is not assignable to type 'IntrinsicAttributes & CustomInputProps'.
required={!isVirtual}
/>
</div>
{!isVirtual && (
Expand Down Expand Up @@ -317,7 +314,7 @@
{...register('description')}
label="Description (Maximum 40 characters allowed)"
autoFocus={!!id}
noTrim
shouldTrim={false}

Check failure on line 317 in src/Pages/GlobalConfigurations/ClustersAndEnvironments/ClusterEnvironmentDrawer/ClusterEnvironmentDrawer.tsx

View workflow job for this annotation

GitHub Actions / ci

Type '{ label: string; autoFocus: boolean; shouldTrim: boolean; onChange: (e: any) => void; onBlur: () => void; onFocus: () => void; name: keyof ClusterEnvironmentDrawerFormProps; placeholder: string; value: string; error: string[]; }' is not assignable to type 'IntrinsicAttributes & CustomInputProps'.
/>
</div>
{EnvironmentLabels && !isVirtual && (
Expand Down
Loading
Loading