Skip to content

Commit f4c644a

Browse files
CountRedClawb41exJayLim2
authored
feat: use mask (*) instead of parameter names while matching rest operations during comparison (#53)
* feat: fetch all operations from version * chore: update dependencies * fix: hardcoded apiType * "chore: update version to 2.10.2-feature-path-param-diff.0" * feat(path-param-diff): Removed redundant fields in types * feat(path param diff): Moved types for different packages changelog into version-changelog.ts as used only here * feat(path param diff): Refactored types for changelog * feat(path param diff): No internal info * fix: replace parallel operations fetching with sequential * feat(path param diff): Adapted for new types (without fixing navigation) * feat(path param diff): Involved both operation keys into navigation URLs * feat(ignore param name): fixed build * feat(ignore param name while matching): Refactored types. Fixed imports * feat(ignore param name while matching): Bump api-processor * fix: small issues * feat: Fixed API version. Bump api-processor * fix: Added missed changes in GroupCompareContent (new contract supported) * fix: Fixed type of changes summary in transformed changelog * fix: Bump api-processor. Fix navigation link to operation(s) from API Changes tab * fix: Crashing on compared operations from compared groups * fix: Build * fix: Fixed list of "unknown" on sidebar. Fixed crashing on expanding tag. Fixed "Please select an operation" on comparison. Extracted "isObject" utility to commons * fix: useOperation stuck in "isLoading" state when was disabled. Some tidying code * fix: Bump api-processor. Fixed stucking in "loading" (useOperation). Used new contract of OperationChanges. Fixed handling operation IDs in different cases. * fix: Fixed provided operation keys on DifferentOperationVersionsComparisonPage * fix: Collision in usages of search param "operation" * fix: Bump ASV and ADV * fix: Bump ASV (merged param and its schema diffs if both available) * fix: Fixed minor bugs not related to the story * fix: Critical issue with crashing app on comparing 2 package versions with added/deleted operation * refactor: Removed type duplications for compared operations * chore: update dependencies --------- Co-authored-by: b41ex <[email protected]> Co-authored-by: Sergei Komarov <[email protected]>
1 parent 579df2a commit f4c644a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+934
-647
lines changed

package-lock.json

Lines changed: 27 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/agents/src/widgets/ChangeViewDialog/ChangesViewWidget.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import type { FC } from 'react'
1818
import { memo } from 'react'
1919
import { OperationChangesSubTableWrapper } from './OperationChangesSubTableWrapper'
20-
import type { OperationChangeData } from '@netcracker/qubership-apihub-ui-shared/entities/version-changelog'
20+
import type { OperationChangeBase } from '@netcracker/qubership-apihub-ui-shared/entities/version-changelog'
2121
import type { Key } from '@netcracker/qubership-apihub-ui-shared/entities/keys'
2222
import type { FetchNextPage } from '@netcracker/qubership-apihub-ui-shared/widgets/ChangesViewWidget/components/ChangesViewTable'
2323
import { ChangesViewTable } from '@netcracker/qubership-apihub-ui-shared/widgets/ChangesViewWidget/components/ChangesViewTable'
@@ -30,7 +30,7 @@ import { isNotEmpty } from '@netcracker/qubership-apihub-ui-shared/utils/arrays'
3030
import type { ApiType } from '@netcracker/qubership-apihub-ui-shared/entities/api-types'
3131

3232
export type ChangesViewWidgetProps = {
33-
changes: ReadonlyArray<OperationChangeData>
33+
changes: ReadonlyArray<OperationChangeBase>
3434
packageKey: Key
3535
versionKey: Key
3636
isLoading: boolean

packages/agents/src/widgets/ChangeViewDialog/OperationChangesSubTableWrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export const OperationChangesSubTableWrapper: FC<OperationChangesSubTableWrapper
3232
packageKind,
3333
},
3434
) => {
35-
const { operationKey } = value.original.change
35+
const { currentOperation, previousOperation } = value.original.change
36+
const operationKey = currentOperation?.operationKey ?? previousOperation!.operationKey
37+
3638
const [changes, isLoading] = useOperationChangelog({
3739
versionKey: versionKey!,
3840
packageKey: packageKey!,

packages/portal/src/routes/NavigationProvider.tsx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export type OperationsDetail = {
113113
versionKey: Key
114114
apiType: ApiType
115115
operationKey?: Key
116+
previousOperationKey?: Key
116117
search?: {
117118
[MODE_SEARCH_PARAM]?: SearchParam
118119
[FILE_VIEW_MODE_PARAM_KEY]?: SearchParam
@@ -122,6 +123,7 @@ export type OperationsDetail = {
122123
[SEARCH_TEXT_PARAM_KEY]?: SearchParam
123124
[EXPAND_NAVIGATION_MENU_SEARCH_PARAM]?: SearchParam
124125
[OPERATIONS_VIEW_MODE_PARAM]?: SearchParam
126+
[OPERATION_SEARCH_PARAM]?: SearchParam
125127
}
126128
}
127129

@@ -159,20 +161,26 @@ export type DocumentPreviewDetail = {
159161
documentKey: Key
160162
} & DocumentsDetail
161163

164+
export type OperationsComparisonSearchParams = {
165+
[OPERATION_SEARCH_PARAM]?: SearchParam
166+
[REF_SEARCH_PARAM]: SearchParam
167+
[PACKAGE_SEARCH_PARAM]?: SearchParam
168+
[VERSION_SEARCH_PARAM]?: SearchParam
169+
[DOCUMENT_SEARCH_PARAM]?: SearchParam
170+
[SEARCH_TEXT_PARAM_KEY]?: SearchParam
171+
[FILTERS_SEARCH_PARAM]?: SearchParam
172+
}
173+
162174
export type OperationsComparisonDetail = {
163175
packageKey: Key
164176
versionKey: Key
165177
apiType: ApiType
166178
operationKey: Key
167-
search: {
168-
[OPERATION_SEARCH_PARAM]?: SearchParam
169-
[REF_SEARCH_PARAM]: SearchParam
170-
[PACKAGE_SEARCH_PARAM]?: SearchParam
171-
[VERSION_SEARCH_PARAM]?: SearchParam
172-
[DOCUMENT_SEARCH_PARAM]?: SearchParam
173-
[SEARCH_TEXT_PARAM_KEY]?: SearchParam
174-
[FILTERS_SEARCH_PARAM]?: SearchParam
175-
}
179+
search: OperationsComparisonSearchParams
180+
}
181+
182+
export type GroupsOperationsComparisonSearchParams = OperationsComparisonSearchParams & {
183+
[GROUP_SEARCH_PARAM]?: SearchParam
176184
}
177185

178186
export type GroupsOperationsComparisonDetail = {
@@ -181,16 +189,7 @@ export type GroupsOperationsComparisonDetail = {
181189
groupKey: Key
182190
apiType: ApiType
183191
operationKey: Key
184-
search: {
185-
[OPERATION_SEARCH_PARAM]?: SearchParam
186-
[REF_SEARCH_PARAM]: SearchParam
187-
[PACKAGE_SEARCH_PARAM]?: SearchParam
188-
[VERSION_SEARCH_PARAM]?: SearchParam
189-
[DOCUMENT_SEARCH_PARAM]?: SearchParam
190-
[GROUP_SEARCH_PARAM]?: SearchParam
191-
[SEARCH_TEXT_PARAM_KEY]?: SearchParam
192-
[FILTERS_SEARCH_PARAM]?: SearchParam
193-
}
192+
search: GroupsOperationsComparisonSearchParams
194193
}
195194

196195
export type FirstGroupOperationDetail = {

packages/portal/src/routes/root/MainPage/MainPageSubpages/PrivatePage/PrivatePagePlaceholder.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Button, Typography } from '@mui/material'
17+
import { Box, Button, Typography } from '@mui/material'
1818
import type { FC } from 'react'
1919
import React, { memo, useCallback } from 'react'
2020
import { MainPageCard } from '../../MainPageCard'
@@ -39,18 +39,18 @@ export const PrivatePagePlaceholder: FC = memo(() => {
3939
invisible={false}
4040
area={CONTENT_PLACEHOLDER_AREA}
4141
message={
42-
<>
42+
<Box display='flex' flexDirection='column' alignItems='center'>
4343
<Typography component="div" variant="h3" color="#8F9EB4" display={'block'}>
4444
Create your own workspace that will be available only to you.
4545
</Typography>
4646
<Button
4747
sx={{ mt: 2 }}
48-
variant={'contained'}
49-
children={'Create Private Workspace'}
48+
variant='contained'
49+
children='Create Private Workspace'
5050
onClick={onCreatePrivatePackage}
5151
data-testid="CreatePrivateWorkspaceButton"
5252
/>
53-
</>
53+
</Box>
5454
}
5555
testId="PrivateWorkspacePlaceholder"
5656
/>

packages/portal/src/routes/root/PortalPage/VersionPage/ComparedOperationsContext.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17+
import type { OperationData, OptionalOperationPair } from '@netcracker/qubership-apihub-ui-shared/entities/operations'
1718
import { createContext, useContext } from 'react'
18-
import type { OperationData } from '@netcracker/qubership-apihub-ui-shared/entities/operations'
1919

20-
type ComparedOperationsPair = {
21-
left: OperationData | undefined
22-
right: OperationData | undefined
23-
isLoading: boolean
24-
}
25-
26-
export const ComparedOperationsContext = createContext<ComparedOperationsPair>({
27-
left: undefined,
28-
right: undefined,
20+
export const ComparedOperationsContext = createContext<OptionalOperationPair<OperationData>>({
21+
previousOperation: undefined,
22+
currentOperation: undefined,
2923
isLoading: true,
3024
})
3125

32-
export function useComparedOperationsPair(): ComparedOperationsPair {
26+
export function useComparedOperationsPair(): OptionalOperationPair<OperationData> {
3327
return useContext(ComparedOperationsContext)
3428
}

packages/portal/src/routes/root/PortalPage/VersionPage/ComparisonOperationChangeSeverityFilters.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export const ComparisonOperationChangeSeverityFilters: FC<ComparisonOperationCha
4242
const { isChangelogAvailable } = props
4343

4444
const {
45-
left: originOperation,
46-
right: changedOperation,
45+
previousOperation: originOperation,
46+
currentOperation: changedOperation,
4747
isLoading: isOperationsLoading,
4848
} = useComparedOperationsPair()
4949

packages/portal/src/routes/root/PortalPage/VersionPage/GroupComparePage/GroupCompareContent.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { useSearchParam } from '@netcracker/qubership-apihub-ui-shared/hooks/sea
4141
import {
4242
FILTERS_SEARCH_PARAM,
4343
GROUP_SEARCH_PARAM,
44+
OPERATION_SEARCH_PARAM,
4445
optionalSearchParams,
4546
PACKAGE_SEARCH_PARAM,
4647
REF_SEARCH_PARAM,
@@ -144,7 +145,7 @@ export const GroupCompareContent: FC<GroupCompareContentProps> = memo(({ groupCh
144145

145146
if (changesLoadingStatus || isEmpty(groupChanges)) {
146147
return (
147-
<LoadingIndicator/>
148+
<LoadingIndicator />
148149
)
149150
}
150151

@@ -173,31 +174,37 @@ export const GroupCompareContent: FC<GroupCompareContentProps> = memo(({ groupCh
173174
filteredGroupChanges.map((change) => {
174175
const {
175176
operationId,
177+
previousOperationId,
176178
changeSummary,
177179
metadata: metadataObject,
180+
previousMetadata: previousMetadataObject,
178181
diffs,
179182
} = change
180183

181184
const metadata = metadataObject as OperationChangesMetadata & Partial<RestChangesMetadata> & Partial<GraphQLChangesMetadata>
185+
const previousMetadata = previousMetadataObject as OperationChangesMetadata & Partial<RestChangesMetadata> & Partial<GraphQLChangesMetadata>
182186

183187
const { action } = diffs?.[0] ?? {}
184188
const operationAction = getActionForOperation(change, REPLACE_ACTION_TYPE)
185189
const severity = getMajorSeverity(changeSummary!)
186190

187-
const isMetaDataPresent = !!(metadata?.title && metadata?.path && metadata?.method)
188-
const previousMetadata = metadata?.previousOperationMetadata
191+
const isMetaDataPresent = !!(
192+
metadata?.title && metadata?.path && metadata?.method ||
193+
previousMetadata?.title && previousMetadata?.path && previousMetadata?.method
194+
)
189195

190196
const comparingSearchParams = optionalSearchParams({
191197
[PACKAGE_SEARCH_PARAM]: { value: changedPackageKey === originPackageKey ? '' : encodeURIComponent(originPackageKey!) },
192198
[VERSION_SEARCH_PARAM]: { value: originVersionKey! },
193199
[REF_SEARCH_PARAM]: { value: refPackageKey },
194200
[GROUP_SEARCH_PARAM]: { value: previousGroup },
195201
[FILTERS_SEARCH_PARAM]: { value: [...CHANGE_SEVERITIES].join() },
202+
[OPERATION_SEARCH_PARAM]: { value: operationId ? previousOperationId : undefined },
196203
})
197204

198205
return (
199206
<Grid
200-
key={`group-compare-content-filtered-group-changes-grid-${operationId}`}
207+
key={`compare-group-${group}-operations-${operationId}-${previousOperationId}`}
201208
component={NavLink}
202209
container
203210
spacing={0}
@@ -215,7 +222,7 @@ export const GroupCompareContent: FC<GroupCompareContentProps> = memo(({ groupCh
215222
encodeURIComponent(changedVersionKey!),
216223
encodeURIComponent(group!),
217224
`${apiType}`,
218-
encodeURIComponent(operationId),
225+
encodeURIComponent(operationId ?? previousOperationId!),
219226
),
220227
search: `${comparingSearchParams}`,
221228
}}
@@ -252,7 +259,7 @@ export const GroupCompareContent: FC<GroupCompareContentProps> = memo(({ groupCh
252259
<Spec
253260
key={operationId}
254261
value={isMetaDataPresent && action !== ADD_ACTION_TYPE && previousMetadata ||
255-
!previousMetadata && action === REMOVE_ACTION_TYPE ? {
262+
!previousMetadata && action === REMOVE_ACTION_TYPE ? {
256263
title: previousMetadata?.title ?? metadata.title,
257264
operationId: operationId,
258265
method: previousMetadata?.method ?? metadata.method,
@@ -271,7 +278,7 @@ export const GroupCompareContent: FC<GroupCompareContentProps> = memo(({ groupCh
271278
<Spec
272279
key={`changed-${operationId}`}
273280
value={isMetaDataPresent && action !== REMOVE_ACTION_TYPE && previousMetadata ||
274-
!previousMetadata && action === ADD_ACTION_TYPE ? {
281+
!previousMetadata && action === ADD_ACTION_TYPE ? {
275282
title: metadata.title,
276283
operationId: operationId,
277284
method: metadata.method,
@@ -306,7 +313,7 @@ const Spec: FC<SpecProps> = memo<SpecProps>(({ value, changes }) => {
306313

307314
const secondary = (
308315
<Box component="span" sx={{ display: 'flex', alignItems: 'center' }} data-testid="OperationPath">
309-
{method && <CustomChip component="span" sx={{ mr: 1 }} value={method} variant={'outlined'}/>}
316+
{method && <CustomChip component="span" sx={{ mr: 1 }} value={method} variant={'outlined'} />}
310317
{path && (
311318
<OverflowTooltip title={path}>
312319
<Typography component="span" noWrap variant="inherit">{path}</Typography>
@@ -335,7 +342,7 @@ const Spec: FC<SpecProps> = memo<SpecProps>(({ value, changes }) => {
335342
/>
336343
</Box>
337344
{changes && (
338-
<Changes value={changes}/>
345+
<Changes value={changes} />
339346
)}
340347
</ListItem>
341348
)

0 commit comments

Comments
 (0)