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

fix: handle sonarqube warnings alpha (and one plugin thing) #898

Merged
merged 9 commits into from
Dec 10, 2024
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
4 changes: 2 additions & 2 deletions cli/config/makeViteConfig.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import dynamicImport from 'vite-plugin-dynamic-import'
* merged with the main config if the `--allowJsxInJs` flag is passed
* to the CLI
*
* todo: deprecate -- this config has a performance cost, especially on startup
* ! deprecated -- this config has a performance cost, especially on startup
*/
const jsxInJsConfig = {
plugins: [
Expand Down Expand Up @@ -178,7 +178,7 @@ export default ({ paths, config, env, host, force, allowJsxInJs }) => {
dynamicImport(),
react({
babel: { plugins: ['styled-jsx/babel'] },
// todo: deprecate with other jsx-in-js config
// ! deprecated with other jsx-in-js config
// This option allows HMR of JSX-in-JS files,
// but it isn't possible to add with merge config:
jsxRuntime: allowJsxInJs ? 'classic' : 'automatic',
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const handler = async ({ cwd = process.cwd(), timeout, ...params }) => {
}

// todo: modify for multiple/named plugins
// https://dhis2.atlassian.net/browse/LIBS-394
const appUrl = constructAppUrl({
baseUrl: dhis2Config.baseUrl,
config,
Expand Down
7 changes: 4 additions & 3 deletions cli/src/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,12 @@ const handler = async ({
})
const server = await createServer(viteConfig)

const location = config.entryPoints.plugin
? config.entryPoints.app
let location = ''
if (config.entryPoints.plugin) {
location = config.entryPoints.app
? ' at / and /plugin.html'
: ' at /plugin.html'
: ''
}

reporter.print(
`The app ${chalk.bold(
Expand Down
1 change: 1 addition & 0 deletions cli/src/lib/compiler/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const compile = async ({
inputDir: paths.src,
outputDir: outDir,
// todo: handle lib compilations with Vite
// https://dhis2.atlassian.net/browse/LIBS-722
processFileCallback: isAppType ? copyFile : compileFile,
watch,
}),
Expand Down
11 changes: 2 additions & 9 deletions examples/simple-app/src/Alerter.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useAlert } from '@dhis2/app-runtime'
import { InputField, CheckboxField, Button } from '@dhis2/ui'
import React, { useState } from 'react'
import styles from './Alerter.module.css'

export const Alerter = () => {
const [message, setMessage] = useState('')
Expand All @@ -12,7 +13,7 @@ export const Alerter = () => {
)

return (
<div>
<div className={styles.flexContainer}>
<InputField
placeholder="Type alert message"
value={message}
Expand All @@ -25,14 +26,6 @@ export const Alerter = () => {
/>
<Button onClick={() => show(message)}>Show alert</Button>
<Button onClick={hide}>Hide alert</Button>
<style jsx>{`
div {
display: flex;
align-items: center;
justify-content: space-between;
width: 500px;
}
`}</style>
</div>
)
}
6 changes: 6 additions & 0 deletions examples/simple-app/src/Alerter.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.flexContainer {
display: flex;
align-items: center;
justify-content: space-between;
width: 500px;
}
5 changes: 2 additions & 3 deletions examples/simple-app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useDataQuery } from '@dhis2/app-runtime'
import moment from 'moment'
import React from 'react'
import { Alerter } from './Alerter.jsx'
import style from './App.style.js'
import styles from './App.module.css'
import i18n from './locales/index.js'

const query = {
Expand All @@ -14,8 +14,7 @@ const query = {
const Component = () => {
const { error, loading, data } = useDataQuery(query)
return (
<div>
<style jsx>{style}</style>
<div className={styles.appContainer}>
{error && <span>ERROR</span>}
{loading && <span>...</span>}
{data && (
Expand Down
10 changes: 10 additions & 0 deletions examples/simple-app/src/App.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.appContainer {
width: 100%;
height: 100%;

display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 1rem;
}
14 changes: 0 additions & 14 deletions examples/simple-app/src/App.style.js

This file was deleted.

11 changes: 7 additions & 4 deletions shell/src/PluginLoader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ const PluginResizeInner = ({
const innerDivRef = useRef()
useEffect(() => {
if (divRef && divRef.current && resizePluginHeight) {
const container = divRef.current
const resizeObserver = new ResizeObserver(() => {
// the additional pixels currently account for possible horizontal scroll bar
if (resizePluginHeight) {
resizePluginHeight(divRef.current.offsetHeight + 20)
}
resizePluginHeight(container.offsetHeight + 20)
})
resizeObserver.observe(divRef.current)
resizeObserver.observe(container)
return () => {
resizeObserver.unobserve(container)
resizeObserver.disconnect()
}
}
}, [resizePluginHeight])

Expand Down
Loading