@devtron-labs/devtron-fe-common-lib 0.0.6-beta-8 → 0.0.6-beta-10
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/dist/Common/BreadCrumb/BreadCrumb.d.ts +33 -0
- package/dist/Common/BreadCrumb/BreadcrumbStore.d.ts +17 -0
- package/dist/Common/Drawer/Drawer.d.ts +16 -0
- package/dist/Common/EmptyState/EmptyState.d.ts +24 -0
- package/dist/Common/Error.d.ts +15 -0
- package/dist/Common/Helper.d.ts +9 -0
- package/dist/Common/Modals/Modal.d.ts +9 -0
- package/dist/Common/Modals/OpaqueModal.d.ts +12 -0
- package/dist/Common/Modals/VisibleModal.d.ts +15 -0
- package/dist/Common/Modals/VisibleModal2.d.ts +12 -0
- package/dist/Common/Progressing.d.ts +13 -0
- package/dist/Common/Reload.d.ts +5 -0
- package/dist/Common/ToastBody.d.ts +23 -0
- package/dist/Common/index.d.ts +13 -0
- package/dist/b5d52f036bdcd3ed.png +0 -0
- package/dist/index.js +1 -1
- package/package.json +46 -39
- package/rollup.config.js +16 -14
- package/src/Assets/Icon/ic-add.svg +3 -0
- package/src/Assets/Icon/ic-close.svg +9 -0
- package/src/Assets/Icon/ic-progressing.svg +6 -0
- package/src/Assets/Img/ic-loading-failure.png +0 -0
- package/src/Assets/Img/ic-not-authorized.svg +62 -0
- package/src/Common/BreadCrumb/BreadCrumb.tsx +115 -0
- package/src/Common/BreadCrumb/BreadcrumbStore.tsx +25 -0
- package/src/Common/Constants.ts +1 -1
- package/src/Common/Drawer/Drawer.scss +39 -0
- package/src/Common/Drawer/Drawer.tsx +49 -0
- package/src/Common/EmptyState/EmptyState.tsx +42 -0
- package/src/Common/EmptyState/emptyState.scss +83 -0
- package/src/Common/Error.tsx +55 -0
- package/src/Common/Helper.tsx +39 -0
- package/src/Common/Modals/Modal.tsx +53 -0
- package/src/Common/Modals/OpaqueModal.tsx +36 -0
- package/src/Common/Modals/VisibleModal.tsx +55 -0
- package/src/Common/Modals/VisibleModal2.tsx +35 -0
- package/src/Common/Progressing.tsx +60 -0
- package/src/Common/Reload.tsx +18 -0
- package/src/Common/ServerError.ts +19 -18
- package/src/Common/ToastBody.tsx +64 -0
- package/src/Common/Types.ts +8 -9
- package/src/Common/index.ts +14 -1
- package/src/custom.d.ts +13 -0
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
|
|
4
|
+
export class VisibleModal2 extends React.Component<{ className: string; close?: (e) => void; }> {
|
|
5
|
+
|
|
6
|
+
modalRef = document.getElementById('visible-modal-2');
|
|
7
|
+
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.escFunction = this.escFunction.bind(this);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
escFunction(event) {
|
|
14
|
+
if (event.keyCode === 27 && this.props.close) {
|
|
15
|
+
this.props.close(event);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
componentDidMount() {
|
|
20
|
+
document.addEventListener("keydown", this.escFunction);
|
|
21
|
+
this.modalRef.classList.add("show-with-bg");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
componentWillUnmount() {
|
|
25
|
+
document.removeEventListener("keydown", this.escFunction);
|
|
26
|
+
this.modalRef.classList.remove("show-with-bg");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
return ReactDOM.createPortal(
|
|
31
|
+
<div className={`visible-modal__body ${this.props.className}`} onClick={this.props?.close}>
|
|
32
|
+
{this.props.children}
|
|
33
|
+
</div>, document.getElementById('visible-modal-2'))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
interface ProgressingProps {
|
|
4
|
+
pageLoader?: boolean
|
|
5
|
+
loadingText?: string
|
|
6
|
+
size?: number
|
|
7
|
+
fullHeight?: boolean
|
|
8
|
+
theme?: 'white' | 'default'
|
|
9
|
+
styles?: React.CSSProperties
|
|
10
|
+
children?: React.ReactNode
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function Progressing({ pageLoader, size, theme, styles }: ProgressingProps): JSX.Element {
|
|
14
|
+
const loaderSize = size ? `${size}px` : pageLoader ? '48px' : '20px'
|
|
15
|
+
return (
|
|
16
|
+
<div className={`loader ${theme || 'default'}-background`} style={styles}>
|
|
17
|
+
<div style={{ width: loaderSize, height: loaderSize }}>
|
|
18
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" className="loader__svg">
|
|
19
|
+
<g fill="none" fillRule="evenodd" strokeLinecap="round">
|
|
20
|
+
<animateTransform
|
|
21
|
+
attributeName="transform"
|
|
22
|
+
attributeType="XML"
|
|
23
|
+
dur="0.5s"
|
|
24
|
+
from="0 12 12"
|
|
25
|
+
repeatCount="indefinite"
|
|
26
|
+
to="360 12 12"
|
|
27
|
+
type="rotate"
|
|
28
|
+
/>
|
|
29
|
+
<path
|
|
30
|
+
fill="#06C"
|
|
31
|
+
fillRule="nonzero"
|
|
32
|
+
d="M12 2.5A9.5 9.5 0 1 1 2.5 12a1.5 1.5 0 0 1 3 0A6.5 6.5 0 1 0 12 5.5a1.5 1.5 0 0 1 0-3z"
|
|
33
|
+
/>
|
|
34
|
+
</g>
|
|
35
|
+
</svg>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function DetailsProgressing({
|
|
42
|
+
loadingText,
|
|
43
|
+
size = 24,
|
|
44
|
+
fullHeight = false,
|
|
45
|
+
children,
|
|
46
|
+
styles,
|
|
47
|
+
}: ProgressingProps): JSX.Element {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
className={`details-loader bcn-0 flex column fs-14 fw-6 ${fullHeight ? 'h-100' : 'details-loader-height'}`}
|
|
51
|
+
style={styles}
|
|
52
|
+
>
|
|
53
|
+
<span style={{ width: `${size}px`, height: `${size}px` }}>
|
|
54
|
+
<Progressing size={size} />
|
|
55
|
+
</span>
|
|
56
|
+
{loadingText && <span className="mt-10">{loadingText}</span>}
|
|
57
|
+
{children}
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import loadingFailure from '../Assets/Img/ic-loading-failure.png';
|
|
3
|
+
|
|
4
|
+
export default function Reload({ reload = null, className = '' }) {
|
|
5
|
+
function refresh(e){
|
|
6
|
+
window.location.reload();
|
|
7
|
+
}
|
|
8
|
+
return (
|
|
9
|
+
<article className={`flex ${className}`} style={{ width: '100%', height: '100%' }}>
|
|
10
|
+
<div className="flex column" style={{ width: '250px', textAlign: 'center' }}>
|
|
11
|
+
<img src={loadingFailure} style={{ width: '100%', height: 'auto', marginBottom: '12px' }} alt="load-error" />
|
|
12
|
+
<h3 className="title dc__bold">Failed to load</h3>
|
|
13
|
+
<div className="dc__empty__subtitle" style={{ marginBottom: '20px' }}>We could not load this page. Please give us another try.</div>
|
|
14
|
+
<button type="button" className="cta ghosted" onClick={typeof reload === 'function' ? reload : refresh}>Retry</button>
|
|
15
|
+
</div>
|
|
16
|
+
</article>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
export class ServerError {
|
|
2
|
-
code: number
|
|
3
|
-
internalMessage: string | null
|
|
4
|
-
userMessage: string | null
|
|
5
|
-
moreInfo?: string | null
|
|
2
|
+
code: number
|
|
3
|
+
internalMessage: string | null
|
|
4
|
+
userMessage: string | null
|
|
5
|
+
moreInfo?: string | null
|
|
6
6
|
|
|
7
7
|
constructor(error) {
|
|
8
|
-
this.code = error.code || 0
|
|
9
|
-
this.userMessage = error.userMessage || ''
|
|
10
|
-
this.internalMessage = error.internalMessage || ''
|
|
11
|
-
this.moreInfo = error.moreInfo || ''
|
|
8
|
+
this.code = error.code || 0
|
|
9
|
+
this.userMessage = error.userMessage || ''
|
|
10
|
+
this.internalMessage = error.internalMessage || ''
|
|
11
|
+
this.moreInfo = error.moreInfo || ''
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export class ServerErrors extends Error {
|
|
16
|
-
code: number
|
|
17
|
-
errors: ServerError[]
|
|
16
|
+
code: number
|
|
17
|
+
errors: ServerError[]
|
|
18
18
|
|
|
19
19
|
constructor(obj: { code: number; errors: ServerError[] }) {
|
|
20
|
-
super()
|
|
21
|
-
this.code = obj.code
|
|
20
|
+
super()
|
|
21
|
+
this.code = obj.code
|
|
22
22
|
let message = obj.errors.reduce((str: string, err: ServerError) => {
|
|
23
|
-
str += `${err.internalMessage || err.userMessage}
|
|
24
|
-
return str
|
|
25
|
-
}, '')
|
|
26
|
-
this.name = `[${obj.code.toString()}]
|
|
27
|
-
this.message = message
|
|
28
|
-
this.errors = obj.errors.map((err) => new ServerError(err))
|
|
23
|
+
str += `${err.internalMessage || err.userMessage}`
|
|
24
|
+
return str
|
|
25
|
+
}, '')
|
|
26
|
+
this.name = `[${obj.code.toString()}]`
|
|
27
|
+
this.message = message
|
|
28
|
+
this.errors = obj.errors.map((err) => new ServerError(err))
|
|
29
|
+
Object.setPrototypeOf(this, ServerErrors.prototype)
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { toast } from 'react-toastify'
|
|
3
|
+
|
|
4
|
+
export class ToastBody extends React.Component<{
|
|
5
|
+
title: string
|
|
6
|
+
subtitle?: string
|
|
7
|
+
}> {
|
|
8
|
+
render() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="toast">
|
|
11
|
+
<div className="toast__title">{this.props.title}</div>
|
|
12
|
+
{this.props.subtitle && <div className="toast__subtitle">{this.props.subtitle}</div>}
|
|
13
|
+
</div>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class ToastBody3 extends React.Component<{
|
|
19
|
+
text: string
|
|
20
|
+
onClick: (...args) => void
|
|
21
|
+
buttonText: string
|
|
22
|
+
}> {
|
|
23
|
+
render() {
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex left column dc__app-update-toast">
|
|
26
|
+
<span className="info">{this.props.text}</span>
|
|
27
|
+
<button type="button" onClick={this.props.onClick}>
|
|
28
|
+
{this.props.buttonText}
|
|
29
|
+
</button>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ToastBodyWithButton extends React.Component<{
|
|
36
|
+
title: string
|
|
37
|
+
subtitle?: string
|
|
38
|
+
onClick: (...args) => void
|
|
39
|
+
buttonText: string
|
|
40
|
+
}> {
|
|
41
|
+
render() {
|
|
42
|
+
return (
|
|
43
|
+
<div className="toast dc__app-update-toast">
|
|
44
|
+
<div className="toast__title">{this.props.title}</div>
|
|
45
|
+
{this.props.subtitle && <div className="toast__subtitle">{this.props.subtitle}</div>}
|
|
46
|
+
<button type="button" onClick={this.props.onClick} style={{ float: 'right' }}>
|
|
47
|
+
{this.props.buttonText}
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const toastAccessDenied = (subtitle?: string) => {
|
|
55
|
+
return toast.info(
|
|
56
|
+
<ToastBody
|
|
57
|
+
title="Access denied"
|
|
58
|
+
subtitle={subtitle || "You do not have required access to perform this action"}
|
|
59
|
+
/>,
|
|
60
|
+
{
|
|
61
|
+
className: 'devtron-toast unauthorized',
|
|
62
|
+
},
|
|
63
|
+
)
|
|
64
|
+
}
|
package/src/Common/Types.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
1
|
export interface ResponseType {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
code: number
|
|
3
|
+
status: string
|
|
4
|
+
result?: any
|
|
5
|
+
errors?: any
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
export interface APIOptions {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
9
|
+
timeout?: number
|
|
10
|
+
signal?: AbortSignal
|
|
11
|
+
preventAutoLogout?: boolean
|
|
12
|
+
}
|
package/src/Common/index.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
export * from './Constants'
|
|
2
2
|
export * from './ServerError'
|
|
3
3
|
export * from './Types'
|
|
4
|
-
export * from './Api'
|
|
4
|
+
export * from './Api'
|
|
5
|
+
export * from './EmptyState/EmptyState'
|
|
6
|
+
export * from './ToastBody'
|
|
7
|
+
export * from './Reload'
|
|
8
|
+
export * from './Error'
|
|
9
|
+
export * from './Helper'
|
|
10
|
+
export * from './Progressing'
|
|
11
|
+
export * from './Drawer/Drawer'
|
|
12
|
+
export * from './Modals/Modal'
|
|
13
|
+
export * from './Modals/OpaqueModal'
|
|
14
|
+
export * from './Modals/VisibleModal'
|
|
15
|
+
export * from './Modals/VisibleModal2'
|
|
16
|
+
export { BreadCrumb, useBreadcrumb } from './BreadCrumb/BreadCrumb'
|
|
17
|
+
export { default as BreadcrumbStore } from './BreadCrumb/BreadcrumbStore'
|
package/src/custom.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module '*.svg' {
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
export const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
|
|
5
|
+
|
|
6
|
+
const src: string;
|
|
7
|
+
export default src;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module '*.png' {
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|