Skip to content
Open
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
5 changes: 1 addition & 4 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@
"@utils/*": ["src/utils/*"]
}
},
"include": [
"./node_modules/cypress",
"cypress/**/*.js"
]
"include": ["./node_modules/cypress", "cypress/**/*.js"]
}
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
config.plugins.push(new webpack.IgnorePlugin(/canvas/))
config.plugins.push(new webpack.IgnorePlugin({ resourceRegExp: /canvas/ }))

// Important: return the modified config
return config
Expand Down
82 changes: 44 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,61 +24,67 @@
"report:combined": "npx nyc report --reporter lcov --reporter text --report-dir coverage"
},
"dependencies": {
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.57",
"@sendgrid/mail": "^7.4.2",
"autoprefixer": "^10.1.0",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
"@mui/icons-material": "^5.8.4",
"@mui/lab": "^5.0.0-alpha.89",
"@mui/material": "^5.8.7",
"@mui/styles": "^5.8.7",
"@sendgrid/mail": "^7.7.0",
"autoprefixer": "^10.4.7",
"bible-reference-rcl": "1.1.0",
"core-js": "^3.8.3",
"core-js": "^3.23.4",
"deep-equal": "^2.0.5",
"gitea-react-toolkit": "1.11.0",
"gitea-react-toolkit": "2.1.2",
"localforage": "^1.9.0",
"markdown-translatable": "^2.0.3",
"next": "10.2.0",
"postcss": "^8.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"markdown-translatable": "^2.1.1",
"next": "12.2.2",
"postcss": "^8.4.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"regenerator-runtime": "^0.13.7",
"resource-workspace-rcl": "2.1.0",
"scripture-resources-rcl": "5.2.2",
"single-scripture-rcl": "3.2.0",
"tailwindcss": "^2.0.4",
"tc-ui-toolkit": "5.3.3",
"translation-helps-rcl": "3.2.0",
"tailwindcss": "^3.1.6",
"tc-ui-toolkit": "6.1.2",
"translation-helps-rcl": "3.3.2",
"use-deep-compare-effect": "^1.3.1",
"word-aligner": "^1.0.0"
},
"devDependencies": {
"@babel/core": "^7.15.8",
"@babel/preset-env": "^7.15.8",
"@cypress/code-coverage": "^3.9.11",
"@babel/core": "^7.18.6",
"@babel/preset-env": "^7.18.6",
"@cypress/code-coverage": "^3.10.0",
"@cypress/instrument-cra": "^1.4.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.1.2",
"@types/jest": "^27.0.2",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@types/jest": "^28.1.4",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.3.1",
"babel-jest": "^28.1.2",
"babel-plugin-istanbul": "^6.1.1",
"cross-env": "7.0.3",
"cypress": "^8.6.0",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-config-react-app": "^6.0.0",
"cypress": "^10.3.0",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-jsdoc": "^31.4.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^5.2.0",
"jest": "^27.3.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.5.3",
"eslint-plugin-jsdoc": "^39.3.3",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.1",
"jest": "^28.1.2",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"prop-types": "^15.7.2",
"prettier": "^2.7.1",
"prop-types": "^15.8.1",
"start-server-and-test": "^1.14.0"
},
"nyc": {
Expand Down
73 changes: 44 additions & 29 deletions src/components/ResourceCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
import { useEdit } from 'gitea-react-toolkit'
import { getResourceErrorMessage } from 'single-scripture-rcl'
import { getResourceMessage } from '@utils/resources'
import { RESOURCE_HTTP_CONFIG, SERVER_MAX_WAIT_TIME_RETRY } from '@common/constants'
import {
RESOURCE_HTTP_CONFIG,
SERVER_MAX_WAIT_TIME_RETRY,
} from '@common/constants'
import generateEditFilePath from '@utils/generateEditFilePath'
import getSha from '@utils/getSha'

Expand Down Expand Up @@ -48,7 +51,8 @@ export default function ResourceCard({
}) {
const [content, setContent] = useState('')
const [saved, setSaved] = useState(true)
const cardResourceId = (resourceId === 'twl') && (viewMode === 'markdown') ? 'tw' : resourceId
const cardResourceId =
resourceId === 'twl' && viewMode === 'markdown' ? 'tw' : resourceId

function updateTempContent(c) {
setContent(c)
Expand Down Expand Up @@ -78,12 +82,7 @@ export default function ResourceCard({
}, [cardResourceId, selectedQuote?.quote, selectedQuote?.occurrence])

const {
state: {
listRef,
contentRef,
usingUserBranch,
workingResourceBranch,
},
state: { listRef, contentRef, usingUserBranch, workingResourceBranch },
actions: { startEdit },
} = useUserBranch({
owner,
Expand Down Expand Up @@ -126,12 +125,8 @@ export default function ResourceCard({
})

const {
state: {
item, headers, filters, fontSize, itemIndex, markdownView,
},
actions: {
setFilters, setFontSize, setItemIndex, setMarkdownView,
},
state: { item, headers, filters, fontSize, itemIndex, markdownView },
actions: { setFilters, setFontSize, setItemIndex, setMarkdownView },
} = useCardState({
id,
items,
Expand All @@ -145,7 +140,9 @@ export default function ResourceCard({
})

const sha = getSha({
item, fetchResponse, cardResourceId,
item,
fetchResponse,
cardResourceId,
})
const editFilePath = generateEditFilePath({
item,
Expand All @@ -155,10 +152,7 @@ export default function ResourceCard({
cardResourceId,
})

const {
isEditing,
onSaveEdit,
} = useEdit({
const { isEditing, onSaveEdit } = useEdit({
sha,
owner,
content,
Expand Down Expand Up @@ -186,7 +180,10 @@ export default function ResourceCard({
useEffect(() => {
if (updateTaDetails) {
const {
Quote, OrigQuote, Occurrence, SupportReference = null,
Quote,
OrigQuote,
Occurrence,
SupportReference = null,
} = item || {}
updateTaDetails(SupportReference)
setQuote({
Expand All @@ -200,19 +197,29 @@ export default function ResourceCard({
useEffect(() => {
const error = resourceStatus?.[ERROR_STATE]

if (error) { // if error was found do callback
const message = getResourceErrorMessage(resourceStatus) + ` ${owner}/${languageId}/${projectId}/${workingResourceBranch}`
if (error) {
// if error was found do callback
const message =
getResourceErrorMessage(resourceStatus) +
` ${owner}/${languageId}/${projectId}/${workingResourceBranch}`
const isAccessError = resourceStatus[MANIFEST_NOT_LOADED_ERROR]
onResourceError && onResourceError(message, isAccessError, resourceStatus)
}
}, [resourceStatus?.[ERROR_STATE]])

const message = getResourceMessage(resourceStatus, owner, languageId, resourceId, server, workingResourceBranch)
const message = getResourceMessage(
resourceStatus,
owner,
languageId,
resourceId,
server,
workingResourceBranch
)

async function handleSaveEdit() {
// Save edit, if succesful trigger resource reload and set saved to true.
const saveEdit = async (branch) => {
await onSaveEdit(branch).then((success) => {
const saveEdit = async branch => {
await onSaveEdit(branch).then(success => {
if (success) {
console.info('Reloading resource')
reloadResource()
Expand All @@ -226,8 +233,9 @@ export default function ResourceCard({

// If not using user branch create it then save the edit.
if (!usingUserBranch) {
await startEdit().then((branch) => saveEdit(branch))
} else {// Else just save the edit.
await startEdit().then(branch => saveEdit(branch))
} else {
// Else just save the edit.
await saveEdit()
}
}
Expand Down Expand Up @@ -280,8 +288,15 @@ export default function ResourceCard({
cardResourceId={cardResourceId}
updateTaDetails={updateTaDetails}
showSaveChangesPrompt={showSaveChangesPrompt}
errorMessage={isEditing ? 'Saving Resource...' : message || errorMessage}
markdown={(cardResourceId == 'ta' || cardResourceId == 'tw') && content.length > 0 ? content : markdown}// Adding content value to maintain edit changes even when switching between markdown and html views on tA.
errorMessage={
isEditing ? 'Saving Resource...' : message || errorMessage
}
markdown={
(cardResourceId == 'ta' || cardResourceId == 'tw') &&
content.length > 0
? content
: markdown
} // Adding content value to maintain edit changes even when switching between markdown and html views on tA.
/>
</Card>
)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/build.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { version } from '../../package.json'
import * as packageInfo from '../../package.json'

export function getBuildId() {
const hash = getCommitHash()
const buildId = { version, hash }
const buildId = { version: packageInfo.version, hash }
return buildId
}

Expand Down
Loading