Skip to content

Commit

Permalink
feat(js,import): remove onClick from label text and add return null f…
Browse files Browse the repository at this point in the history
…or builUri

Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
MyPyDavid committed Jul 12, 2024
1 parent e717725 commit fb20c7e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const ImportSelectCheckbox = ({ element, toggleImport, updateShowField }) => {
</label>
<CodeLink className={codeClass[element.model]} uri={element.uri} onClick={updateShowField} />

<ChangedLabel text={changedLabelText} onClick={updateShowField} show={(element.changed && element.updated)} />
<ChangedLabel text={changedLabelText} show={(element.changed && element.updated)} />

<CreatedLabel text={createdLabelText} onClick={updateShowField} show={element.created} />
<CreatedLabel text={createdLabelText} show={element.created} />
</div>
)}

Expand Down
10 changes: 8 additions & 2 deletions rdmo/management/assets/js/reducers/importsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default function importsReducer(state = initialState, action) {
if (elements[index].model === 'domain.attribute') {
elements[index].path = buildPathForAttribute(elements[index].key, elements[index].parent ? elements[index].parent.uri : null)
}
elements[index].uri = buildUri(elements[index])
const newUri = buildUri(elements[index])
if (!isNil(newUri)) {
elements[index].uri = newUri
}
return {...state, elements}
} else {
return state
Expand Down Expand Up @@ -87,7 +90,10 @@ export default function importsReducer(state = initialState, action) {
element.uri_prefix = action.uriPrefix

// compute a new uri and store it in the elementMap
element.uri = elementsMap[element.uri] = buildUri(element)
const newUri = buildUri(element)
if (!isNil(newUri)) {
element.uri = elementsMap[element.uri] = newUri
}

return element
})
Expand Down
11 changes: 9 additions & 2 deletions rdmo/management/assets/js/utils/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,20 @@ function findDescendants(element, elementType) {
}

const buildUri = (element) => {
let uri = element.uri_prefix + '/' + elementModules[element.model] + '/'
if (isUndefined(element.uri_prefix) || isUndefined(element.model)) {
return null
}

let uri = `${element.uri_prefix}/${elementModules[element.model]}/`

if (!isUndefined(element.uri_path) && !isNil(element.uri_path)) {
uri += element.uri_path
} else if (!isUndefined(element.path) && !isNil(element.path)) {
uri += element.path
} else {
} else if (!isUndefined(element.key) && !isNil(element.key)) {
uri += element.key
} else {
return null
}

return uri
Expand Down

0 comments on commit fb20c7e

Please sign in to comment.