Skip to content

Commit 6f5f0d6

Browse files
committed
chore(core): remove unused code/comments
1 parent 3e0616b commit 6f5f0d6

File tree

17 files changed

+1961
-329
lines changed

17 files changed

+1961
-329
lines changed

plugins/networking/app/javascript/widgets/ports/components/ports/show.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState, useEffect } from "react"
22
// @ts-expect-error – missing types for react-bootstrap
3-
import { Modal, Button, Tabs, Tab } from "react-bootstrap"
4-
import { Link } from "react-router-dom"
3+
import { Modal, Button} from "react-bootstrap"
54

65
interface RowProps {
76
label: string
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import React, { useState, useEffect } from "react"
2+
// @ts-expect-error - no types available
3+
import { DefeatableLink } from "lib/components/defeatable_link"
4+
// @ts-expect-error - no types available
5+
import { policy } from "lib/policy"
6+
import { Modal, Button } from "react-bootstrap"
7+
import ErrorMessageItem from "./item"
8+
9+
interface ErrorMessage {
10+
id: string
11+
message: string
12+
level: string
13+
created_at: string
14+
[key: string]: unknown
15+
}
16+
17+
interface ErrorMessagesState {
18+
items: ErrorMessage[]
19+
isFetching: boolean
20+
}
21+
22+
interface ErrorMessageListProps {
23+
errorMessages?: ErrorMessagesState
24+
loadErrorMessagesOnce: () => void
25+
match?: {
26+
params: {
27+
type?: string
28+
}
29+
}
30+
history: {
31+
replace: (path: string) => void
32+
}
33+
}
34+
35+
const ErrorMessageList: React.FC<ErrorMessageListProps> = ({
36+
errorMessages,
37+
loadErrorMessagesOnce,
38+
match,
39+
history,
40+
}) => {
41+
const [show, setShow] = useState(true)
42+
43+
// Load dependencies on mount and when they change
44+
useEffect(() => {
45+
loadErrorMessagesOnce()
46+
}, [loadErrorMessagesOnce])
47+
48+
const restoreUrl = () => {
49+
const type = match && match.params.type
50+
if (!show) history.replace(type || "shares")
51+
}
52+
53+
const hide = (e?: React.MouseEvent) => {
54+
if (e) e.stopPropagation()
55+
setShow(false)
56+
}
57+
58+
return (
59+
<Modal show={show} onExited={restoreUrl} onHide={hide} size="lg" aria-labelledby="contained-modal-title-lg">
60+
<Modal.Header closeButton>
61+
<Modal.Title id="contained-modal-title-lg">Error Log</Modal.Title>
62+
</Modal.Header>
63+
<Modal.Body>
64+
{!errorMessages || errorMessages.isFetching ? (
65+
<div>
66+
<span className="spinner" />
67+
Loading...
68+
</div>
69+
) : (
70+
<table className="table error-messages">
71+
<thead>
72+
<tr>
73+
<th>Level</th>
74+
<th>Error</th>
75+
<th>Created</th>
76+
</tr>
77+
</thead>
78+
<tbody>
79+
{errorMessages.items.length === 0 && (
80+
<tr>
81+
<td colSpan={3}>No errors found.</td>
82+
</tr>
83+
)}
84+
{errorMessages.items.map((errorMessage, index) => (
85+
<ErrorMessageItem key={errorMessage.id} errorMessage={errorMessage} />
86+
))}
87+
</tbody>
88+
</table>
89+
)}
90+
</Modal.Body>
91+
<Modal.Footer>
92+
<Button onClick={hide}>Close</Button>
93+
</Modal.Footer>
94+
</Modal>
95+
)
96+
}
97+
98+
export default ErrorMessageList
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import React from "react"
2+
import { Link } from "react-router-dom"
3+
// @ts-expect-error - lib/policy has no TypeScript definitions
4+
import { policy } from "lib/policy"
5+
6+
interface SecurityService {
7+
id: string
8+
name?: string
9+
type: string
10+
isDeleting?: boolean
11+
}
12+
13+
interface ItemProps {
14+
securityService: SecurityService
15+
handleDelete: (id: string) => void
16+
}
17+
18+
const Item: React.FC<ItemProps> = ({ securityService, handleDelete }) => (
19+
<tr className={securityService.isDeleting ? "updating" : ""}>
20+
<td>
21+
<Link to={`/security-services/${securityService.id}/show`}>{securityService.name || securityService.id}</Link>
22+
{securityService.name && (
23+
<>
24+
<br />
25+
<span className="info-text">{securityService.id}</span>
26+
</>
27+
)}
28+
</td>
29+
<td>{securityService.type}</td>
30+
<td className="snug">
31+
{(policy.isAllowed("shared_filesystem_storage:security_service_delete") ||
32+
policy.isAllowed("shared_filesystem_storage:security_service_update")) && (
33+
<div className="btn-group">
34+
<button
35+
className="btn btn-default btn-sm dropdown-toggle"
36+
type="button"
37+
data-toggle="dropdown"
38+
aria-expanded={true}
39+
>
40+
<span className="fa fa-cog"></span>
41+
</button>
42+
43+
<ul className="dropdown-menu dropdown-menu-right" role="menu">
44+
{policy.isAllowed("shared_filesystem_storage:security_service_delete") && (
45+
<li>
46+
<a
47+
href="#"
48+
onClick={(e) => {
49+
e.preventDefault()
50+
handleDelete(securityService.id)
51+
}}
52+
>
53+
Delete
54+
</a>
55+
</li>
56+
)}
57+
{policy.isAllowed("shared_filesystem_storage:security_service_update") && (
58+
<li>
59+
<Link to={`/security-services/${securityService.id}/edit`}>Edit</Link>
60+
</li>
61+
)}
62+
<li>
63+
<Link to={`/security-services/${securityService.id}/error-log`}>Error Log</Link>
64+
</li>
65+
</ul>
66+
</div>
67+
)}
68+
</td>
69+
</tr>
70+
)
71+
72+
export default Item
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/* eslint-disable react/no-unescaped-entities */
2+
import React, { useEffect } from "react"
3+
import SecurityServiceItem from "./item"
4+
// @ts-expect-error - lib/policy has no TypeScript definitions
5+
import { policy } from "lib/policy"
6+
// @ts-expect-error - lib/components/defeatable_link has no TypeScript definitions
7+
import { DefeatableLink } from "lib/components/defeatable_link"
8+
// @ts-expect-error - lib/components/Overlay has no TypeScript definitions
9+
import { Popover } from "lib/components/Overlay"
10+
11+
interface SecurityService {
12+
id: string
13+
name?: string
14+
type: string
15+
isDeleting?: boolean
16+
}
17+
18+
interface SecurityServiceListProps {
19+
active: boolean
20+
isFetching: boolean
21+
securityServices: SecurityService[]
22+
loadSecurityServicesOnce: () => void
23+
handleDelete: (id: string) => void
24+
}
25+
26+
const CreateNewButton: React.FC = () => {
27+
if (!policy.isAllowed("shared_filesystem_storage:share_network_create")) {
28+
return (
29+
<Popover
30+
title="Missing Create Permission"
31+
content="You don't have permission to create a security service. Please check if
32+
you have the role sharedfilesystem_admin."
33+
placement="top"
34+
>
35+
<button className="btn btn-primary disabled">
36+
<i className="fa fa-fw fa-exclamation-triangle fa-2"></i> Create New
37+
</button>
38+
</Popover>
39+
)
40+
}
41+
42+
return (
43+
<DefeatableLink to="/security-services/new" className="btn btn-primary">
44+
Create New
45+
</DefeatableLink>
46+
)
47+
}
48+
49+
const SecurityServiceList: React.FC<SecurityServiceListProps> = ({
50+
active,
51+
isFetching,
52+
securityServices,
53+
loadSecurityServicesOnce,
54+
handleDelete,
55+
}) => {
56+
useEffect(() => {
57+
if (active) {
58+
loadSecurityServicesOnce()
59+
}
60+
}, [active, loadSecurityServicesOnce])
61+
62+
return (
63+
<>
64+
<div className="toolbar">
65+
<div className="main-buttons">
66+
<CreateNewButton />
67+
</div>
68+
</div>
69+
70+
{isFetching ? (
71+
<div className="loadig">
72+
<span className="spinner" />
73+
{"Loading..."}
74+
</div>
75+
) : (
76+
<table className="table security-services">
77+
<thead>
78+
<tr>
79+
<th>Name</th>
80+
<th>Type</th>
81+
<th></th>
82+
</tr>
83+
</thead>
84+
85+
<tbody>
86+
{securityServices.length === 0 ? (
87+
<tr>
88+
<td colSpan={3}>No Security Service found.</td>
89+
</tr>
90+
) : (
91+
securityServices.map((securityService) => (
92+
<SecurityServiceItem
93+
key={securityService.id}
94+
securityService={securityService}
95+
handleDelete={handleDelete}
96+
/>
97+
))
98+
)}
99+
</tbody>
100+
</table>
101+
)}
102+
</>
103+
)
104+
}
105+
106+
export default SecurityServiceList
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React, { useState, useEffect } from "react"
2+
import { Modal, Button } from "react-bootstrap"
3+
// @ts-expect-error - lib/elektra-form has no TypeScript definitions
4+
import { Form } from "lib/elektra-form"
5+
6+
interface ShareNetwork {
7+
id: string
8+
name?: string
9+
description?: string
10+
}
11+
12+
interface EditShareNetworkFormProps {
13+
shareNetwork: ShareNetwork | null
14+
history: {
15+
replace: (path: string) => void
16+
}
17+
handleSubmit: (values: ShareNetwork) => Promise<void>
18+
}
19+
20+
const EditShareNetworkForm: React.FC<EditShareNetworkFormProps> = ({ shareNetwork, history, handleSubmit }) => {
21+
const [show, setShow] = useState(shareNetwork !== null)
22+
23+
useEffect(() => {
24+
setShow(shareNetwork !== null)
25+
}, [shareNetwork])
26+
27+
const validate = (values: ShareNetwork): boolean => {
28+
return Boolean(values.name)
29+
}
30+
31+
const close = (e?: React.MouseEvent) => {
32+
if (e) e.stopPropagation()
33+
setShow(false)
34+
setTimeout(() => history.replace("/share-networks"), 300)
35+
}
36+
37+
const onSubmit = (values: ShareNetwork) => {
38+
return handleSubmit(values).then(() => close())
39+
}
40+
41+
return (
42+
<Modal show={show} onHide={close} size="lg" aria-labelledby="contained-modal-title-lg">
43+
<Modal.Header closeButton>
44+
<Modal.Title id="contained-modal-title-lg">Edit Share Network</Modal.Title>
45+
</Modal.Header>
46+
47+
<Form validate={validate} initialValues={shareNetwork} className="form form-horizontal" onSubmit={onSubmit}>
48+
<Modal.Body>
49+
<Form.Errors />
50+
51+
<Form.ElementHorizontal label="Name" name="name">
52+
<Form.Input elementType="input" type="text" name="name" />
53+
</Form.ElementHorizontal>
54+
55+
<Form.ElementHorizontal label="Description" name="description">
56+
<Form.Input elementType="textarea" className="text optional form-control" name="description" />
57+
</Form.ElementHorizontal>
58+
</Modal.Body>
59+
<Modal.Footer>
60+
<Button onClick={close}>Cancel</Button>
61+
<Form.SubmitButton label="Save" />
62+
</Modal.Footer>
63+
</Form>
64+
</Modal>
65+
)
66+
}
67+
68+
export default EditShareNetworkForm

0 commit comments

Comments
 (0)