Skip to content

Commit

Permalink
fix: rename "whole document" to "document root" and "whole item" to "…
Browse files Browse the repository at this point in the history
…item root" to prevent confusion
  • Loading branch information
josdejong committed Oct 16, 2023
1 parent 8ff51f0 commit 2699b71
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/modals/JSONEditorModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
$: currentState = last(stack) || rootState
$: absolutePath = stack.flatMap((state) => state.relativePath)
$: pathDescription = !isEmpty(absolutePath) ? stringifyJSONPath(absolutePath) : '(whole document)'
$: pathDescription = !isEmpty(absolutePath) ? stringifyJSONPath(absolutePath) : '(document root)'
// not relevant in this Modal setting, but well
$: parseMemoizeOne = memoizeOne(parser.parse)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modals/SortModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
type="text"
readonly
title="Selected path"
value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(whole document)'}
value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(document root)'}
/>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modals/TransformModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
type="text"
readonly
title="Selected path"
value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(whole document)'}
value={!isEmpty(rootPath) ? stringifyJSONPath(rootPath) : '(document root)'}
/>

<div class="jse-label">
Expand Down
2 changes: 1 addition & 1 deletion src/lib/logic/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ export function updateSelectionInDocumentState(
}

/**
* Create a selection which selects the whole document
* Create a selection which selects the root of the document
*/
// TODO: write unit tests
export function selectAll(): JSONSelection {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/query/javascriptQueryLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function createQuery(json: JSONValue, queryOptions: QueryLanguageOptions): strin
// and use that when building the query to make it more readable.
if (projection.paths.length > 1) {
const paths = projection.paths.map((path) => {
const name = path[path.length - 1] || 'item' // 'item' in case of having selected the whole item
const name = path[path.length - 1] || 'item' // 'item' in case of having selected the item root
const item = `item${createPropertySelector(path)}`
return ` ${JSON.stringify(name)}: ${item}`
})
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/query/jmespathQueryLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function createQuery(json: JSONValue, queryOptions: QueryLanguageOptions): strin

query +=
path.length === 0
? '' // edge case, selecting projection of "whole item"
? '' // edge case, selecting projection of the item root
: '.' + stringifyPathForJmespath(path)
} else if (projection.paths.length > 1) {
query +=
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/query/lodashQueryLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function createQuery(json: JSONValue, queryOptions: QueryLanguageOptions): strin
if (projection.paths.length > 1) {
// Note that we do not use _.pick() here because this function doesn't flatten the results
const paths = projection.paths.map((path) => {
const name = last(path) || 'item' // 'item' in case of having selected the whole item
const name = last(path) || 'item' // 'item' in case of having selected the item root
return ` ${JSON.stringify(name)}: item${createPropertySelector(path)}`
})
queryParts.push(` .map(item => ({\n${paths.join(',\n')}\n }))\n`)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/pathUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('pathUtils', () => {
})

test('pathToOption', () => {
deepStrictEqual(pathToOption([]), { value: [], label: '(whole item)' })
deepStrictEqual(pathToOption([]), { value: [], label: '(item root)' })
deepStrictEqual(pathToOption(['users', '2', 'first name']), {
value: ['users', '2', 'first name'],
label: 'users[2].first name'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/pathUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function parseJSONPath(pathStr: string): JSONPath {
export function pathToOption(path: JSONPath): { value: JSONPath; label: string } {
return {
value: path,
label: isEmpty(path) ? '(whole item)' : stringifyJSONPath(path)
label: isEmpty(path) ? '(item root)' : stringifyJSONPath(path)
}
}

Expand Down

0 comments on commit 2699b71

Please sign in to comment.