Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions src/common/api-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ export const setSpec = (inSpec): void => {
spec = inSpec
}

// TODO: check if needed after form rework
export const deleteAlertEndpoints = (schema, formData) => {
// schema.properties.receivers.items.enum.forEach((receiver) => {
// set(schema, `properties.${receiver}.required`, false)
// // if (!(formData?.receivers || []).includes(receiver) && !(formData?.drone || []).includes(receiver))
// // // eslint-disable-next-line no-param-reassign
// // // delete schema.properties[receiver]
// })
}

export const setSecretsEnum = (schema, secrets) => {
if (secrets.length) {
const secretNames = secrets.filter((s) => s.secret.type !== 'docker_registry').map((s) => s.name)
Expand Down
2 changes: 1 addition & 1 deletion src/components/AccountPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function AccountPopover({ email }: Props) {
height: '100%',
borderRadius: '50%',
position: 'absolute',
bgcolor: (theme) => alpha(theme.palette.grey[900], 0.8),
bgcolor: (theme) => alpha(String(theme.palette.grey[900]), 0.8),
},
}),
}}
Expand Down
18 changes: 6 additions & 12 deletions src/components/AdvancedSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React from 'react'
import { styled } from '@mui/material/styles'
import { Accordion, AccordionDetails, AccordionSummary } from '@mui/material'
import { KeyboardArrowRight } from '@mui/icons-material'
Expand All @@ -13,7 +13,7 @@ const StyledDescription = styled(Typography)(({ theme }) => ({
color: theme.palette.cl.text.subTitle,
}))

const StyledAccordion = styled(Accordion)(({ theme }) => ({
const StyledAccordion = styled(Accordion)(() => ({
backgroundColor: 'transparent',
boxShadow: 'none !important',
margin: '0px !important',
Expand All @@ -22,7 +22,7 @@ const StyledAccordion = styled(Accordion)(({ theme }) => ({
},
}))

const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({
const StyledAccordionDetails = styled(AccordionDetails)(() => ({
backgroundColor: 'transparent',
boxShadow: 'none',
marginTop: '0px',
Expand All @@ -32,7 +32,7 @@ const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({
},
}))

const StyledAccordionSummary = styled(AccordionSummary)(({ theme }) => ({
const StyledAccordionSummary = styled(AccordionSummary)(() => ({
padding: '0',
'.MuiAccordionSummary-content': {
margin: '0', // Remove margin between text and icon
Expand All @@ -45,20 +45,14 @@ interface Props {
description?: string
title?: string
children?: React.ReactNode
noPaddingTop?: boolean
closed?: boolean
}

export default function AdvancedSettings(props: Props) {
const { title = 'Advanced Settings', description, children, noPaddingTop, closed = false } = props
const [expanded, setExpanded] = useState(true)

const handleAccordionChange = () => {
setExpanded((prev) => !prev)
}
const { title = 'Advanced Settings', description, children, closed = false } = props

return (
<StyledAccordion defaultExpanded={!closed} disableGutters onChange={handleAccordionChange}>
<StyledAccordion defaultExpanded={!closed} disableGutters>
<StyledAccordionSummary
expandIcon={<KeyboardArrowRight />}
sx={{
Expand Down
108 changes: 10 additions & 98 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import TableCell from '@mui/material/TableCell'
import TableContainer from '@mui/material/TableContainer'
import TableRow from '@mui/material/TableRow'
import { getSpec } from 'common/api-spec'
import { JSONSchema7 } from 'json-schema'
import { cloneDeep, isEqual, set, unset } from 'lodash'
import { cloneDeep, isEqual } from 'lodash'
import { CrudProps, ValuesSchema } from 'pages/types'
import React, { useEffect, useState } from 'react'
import Helmet from 'react-helmet'
Expand All @@ -15,7 +14,7 @@ import { useLocation } from 'react-router-dom'
import { GetTeamAppApiResponse } from 'redux/otomiApi'
import { makeStyles } from 'tss-react/mui'
import { cleanLink, getAppData } from 'utils/data'
import { extract, getAppSchemaName, isOf } from 'utils/schema'
import { getAppSchemaName } from 'utils/schema'
import YAML from 'yaml'
import { useSession } from 'providers/Session'
import CodeEditor from './CodeEditor'
Expand All @@ -42,7 +41,6 @@ const useStyles = makeStyles()((theme) => ({
paddingTop: theme.spacing(1),
paddingRight: theme.spacing(2),
display: 'inline-flex',
// width: theme.spacing(8),
},
img: {
height: theme.spacing(6),
Expand All @@ -67,9 +65,6 @@ const useStyles = makeStyles()((theme) => ({
tableRow: {
'&:last-child td, &:last-child th': { border: 0 },
},
tableHead: {
// minWidth: theme.spacing(12),
},
}))

export const getAppSchema = (appId: string, formData): any => {
Expand All @@ -86,88 +81,11 @@ export const getAppSchema = (appId: string, formData): any => {
return schema
}

export const getAppUiSchema = (appsEnabled: Record<string, any>, appId: string, formData): any => {
const modelName = getAppSchemaName(appId)
const model = getSpec().components.schemas[modelName].properties.values
const uiSchema = {}
if (model) {
const leafs = Object.keys(extract(model, (o: JSONSchema7) => o.type === 'object' && !o.properties && !isOf(o)))
leafs.forEach((path) => {
set(uiSchema, path, { 'ui:widget': CodeEditor })
})
}
switch (appId) {
case 'cert-manager':
set(uiSchema, 'customRootCA.ui:widget', 'hidden')
set(uiSchema, 'customRootCAKey.ui:widget', 'hidden')
set(uiSchema, 'byoWildcardCert.ui:widget', 'hidden')
set(uiSchema, 'byoWildcardCertKey.ui:widget', 'hidden')
set(uiSchema, 'stage.ui:widget', 'hidden')
set(uiSchema, 'email.ui:widget', 'hidden')
if (formData.issuer === 'letsencrypt') {
unset(uiSchema, 'stage.ui:widget')
unset(uiSchema, 'email.ui:widget')
}

if (formData.issuer === 'byo-wildcard-cert') {
unset(uiSchema, 'byoWildcardCert.ui:widget')
set(uiSchema, 'byoWildcardCert.ui:widget', 'TextareaWidget')
unset(uiSchema, 'byoWildcardCertKey.ui:widget')
}
if (formData.issuer === 'custom-ca') {
unset(uiSchema, 'customRootCA.ui:widget')
unset(uiSchema, 'customRootCAKey.ui:widget')
set(uiSchema, 'customRootCA.ui:widget', 'TextareaWidget')
}
break
case 'gitea':
set(uiSchema, 'adminPassword.ui:widget', 'hidden')
set(uiSchema, 'postgresqlPassword.ui:widget', 'hidden')
break
case 'harbor':
set(uiSchema, 'databasePassword.ui:widget', 'hidden')
set(uiSchema, 'adminPassword.ui:widget', 'hidden')
set(uiSchema, 'core.ui:widget', 'hidden')
set(uiSchema, 'registry.ui:widget', 'hidden')
set(uiSchema, 'jobservice.ui:widget', 'hidden')
set(uiSchema, 'secretKey.ui:widget', 'hidden')
set(uiSchema, 'database.ui:widget', 'hidden')

break
case 'grafana':
set(uiSchema, 'adminPassword.ui:widget', 'hidden')
break
case 'keycloak':
set(uiSchema, 'adminPassword.ui:widget', 'hidden')
set(uiSchema, 'postgresqlPassword.ui:widget', 'hidden')
break
case 'loki':
set(uiSchema, 'adminPassword.ui:widget', 'hidden')
break
case 'prometheus':
set(uiSchema, 'remoteWrite.rwConfig.customConfig.ui:widget', 'textarea')
break
default:
break
}
return uiSchema
}

interface Props extends CrudProps, GetTeamAppApiResponse {
teamId: string
setAppState: CallableFunction
managed?: boolean
}
export default function App({
id,
teamId,
enabled,
values: inValues,
rawValues: inRawValues,
mutating,
managed,
onSubmit,
}: Props): React.ReactElement {
export default function App({ id, teamId, enabled, values: inValues, managed, onSubmit }: Props): React.ReactElement {
const location = useLocation()
const hash = location.hash.substring(1)
const hashMap = {
Expand All @@ -176,11 +94,10 @@ export default function App({
}
const { classes } = useStyles()
const session = useSession()
const { appsEnabled } = session
const { appInfo, deps, logo, logoAlt } = getAppData(session, teamId, id)
const defTab = hashMap[hash] ?? hashMap.info
const [tab, setTab] = useState(defTab)
const handleTabChange = (event, tab) => {
const handleTabChange = (_, tab) => {
setTab(tab)
}
const [isEdit, setIsEdit] = useState(false)
Expand Down Expand Up @@ -208,11 +125,6 @@ export default function App({
if (validValues) onSubmit(data)
}

const handleValuesChange = (values: Props['values'], errors: any[]) => {
setValues(values)
setValidValues(errors.length === 0)
}

const prefixedDeps = () => {
let dependencies: string
if (!deps) return 'None'
Expand Down Expand Up @@ -270,13 +182,13 @@ export default function App({
<Table size='small' aria-label='simple table'>
<TableBody>
<TableRow key='version' className={classes.tableRow}>
<TableCell component='th' scope='row' align='right' className={classes.tableHead}>
<TableCell component='th' scope='row' align='right'>
<Chip label={t('Version:')} />
</TableCell>
<TableCell align='left'>{appInfo.appVersion}</TableCell>
</TableRow>
<TableRow key='repo' className={classes.tableRow}>
<TableCell component='th' scope='row' align='right' className={classes.tableHead}>
<TableCell component='th' scope='row' align='right'>
<Chip label={t('Repo:')} />
</TableCell>
<TableCell align='left'>
Expand All @@ -286,13 +198,13 @@ export default function App({
</TableCell>
</TableRow>
<TableRow key='maintainers' className={classes.tableRow}>
<TableCell component='th' scope='row' align='right' className={classes.tableHead}>
<TableCell component='th' scope='row' align='right'>
<Chip label={t('Maintainers:')} />
</TableCell>
<TableCell align='left'>{appInfo.maintainers}</TableCell>
</TableRow>
<TableRow key='links' className={classes.tableRow}>
<TableCell component='th' scope='row' align='right' className={classes.tableHead}>
<TableCell component='th' scope='row' align='right'>
<Chip label={t('Related links:')} />
</TableCell>
<TableCell align='left'>
Expand All @@ -307,7 +219,7 @@ export default function App({
</TableCell>
</TableRow>
<TableRow key='dependencies' className={classes.tableRow}>
<TableCell component='th' scope='row' align='right' className={classes.tableHead}>
<TableCell component='th' scope='row' align='right'>
<Chip label={t('Dependencies:')} />
</TableCell>
<TableCell align='left'>{prefixedDeps()}</TableCell>
Expand Down Expand Up @@ -335,7 +247,7 @@ export default function App({
<CodeEditor
code={valuesYaml}
onChange={(data) => {
setValues(data || {})
setValues((data || {}) as { [key: string]: any })
}}
disabled={!isEdit}
setValid={setValidValues}
Expand Down
7 changes: 4 additions & 3 deletions src/components/AppCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ export default function ({
draggable={false}
className={classes.img}
src={img}
onError={({ currentTarget }) => {
currentTarget.onerror = null // prevents looping
currentTarget.src = imgAlt
onError={(event) => {
const target = event.currentTarget
target.onerror = null // prevents looping
target.src = imgAlt
}}
alt={`Logo for ${title} app`}
/>
Expand Down
28 changes: 3 additions & 25 deletions src/components/Apps.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-plusplus */
import { Box, Grid } from '@mui/material'
import { useSession } from 'providers/Session'
import React, { useState } from 'react'
Expand All @@ -16,12 +15,7 @@ import ObjAppModal from './ObjAppModal'

const useStyles = makeStyles()((theme) => {
const p = theme.palette
const m = p.mode

// Disabled app styling:
// filter: grayscale(1);
// opacity: 0.5;
// background-color: #eeeeee;
return {
root: {
color: theme.palette.text.secondary,
Expand All @@ -31,12 +25,6 @@ const useStyles = makeStyles()((theme) => {
searchbar: {
backgroundColor: '#444444',
},
// enabled: {
// '& .MuiTypography-root': {
// color: '#585656',
// fontWeight: '200',
// },
// },
out: {
backgroundColor: p.error.main,
},
Expand Down Expand Up @@ -83,14 +71,6 @@ function sortArray(a, b) {
return 1
}

// function sortArray(a, b) {
// // Treat undefined as true
// if (a.id < b.id) return -1
// if (a.id > b.id) return 1

// return 0
// }

function getDeprecatedApps(apps, session, teamId) {
return apps
?.map((app) => {
Expand Down Expand Up @@ -120,8 +100,8 @@ export default function Apps({ teamId, apps, teamSettings, setAppState, objSetti
const session = useSession()
const { classes, cx } = useStyles()
const [filterName, setFilterName] = useState('')
const [orderBy, setOrderBy] = useState('enabled')
const [order, setOrder] = useState<'asc' | 'desc'>('asc')
const [orderBy] = useState('enabled')
const [order] = useState<'asc' | 'desc'>('asc')
const [openModal, setOpenModal] = useState('')
const [openObjAppModal, setOpenObjAppModal] = useState('')
const objStorageApps = (session?.objectStorage?.objStorageApps || []) as ObjStorageApp[]
Expand Down Expand Up @@ -150,7 +130,6 @@ export default function Apps({ teamId, apps, teamSettings, setAppState, objSetti

const handleFilterName = (filterName: string) => {
setFilterName(filterName)
// setPage(0)
}

// END HOOKS
Expand All @@ -165,7 +144,6 @@ export default function Apps({ teamId, apps, teamSettings, setAppState, objSetti
})

const deprecatedApps = getDeprecatedApps(dataFiltered, session, teamId)
// const filteredApps = apps.filter((app) => app.id.toLowerCase().includes(searchTerm.toLowerCase()))

const out = (items) =>
items?.map((item) => {
Expand Down Expand Up @@ -203,7 +181,7 @@ export default function Apps({ teamId, apps, teamSettings, setAppState, objSetti
return deprecatedApps?.map((app) => {
const handleCancel = () => {
setOpenModal('')
window.open(app?.externalUrl, '_blank')
window.open(String(app?.externalUrl), '_blank')
}
const handleAction = () => {
setOpenModal('')
Expand Down
Loading
Loading