Skip to content

Commit

Permalink
fix new tabs on comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Oct 21, 2023
1 parent 4c8ea19 commit 30ac721
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 30 deletions.
7 changes: 6 additions & 1 deletion report-viewer/src/components/ComparisonsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@
<RouterLink
:to="{
name: 'ComparisonView',
params: { firstId: item.firstSubmissionId, secondId: item.secondSubmissionId }
params: {
comparisonFileName: store().getComparisonFileName(
item.firstSubmissionId,
item.secondSubmissionId
)
}
}"
class="flex flex-grow flex-row"
>
Expand Down
9 changes: 2 additions & 7 deletions report-viewer/src/model/factories/ComparisonFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import { MetricType } from '../MetricType'
* Factory class for creating Comparison objects
*/
export class ComparisonFactory extends BaseFactory {
public static async getComparison(id1: string, id2: string): Promise<Comparison> {
const filePath = store().getComparisonFileName(id1, id2)
if (!filePath) {
throw new Error('Comparison file not specified')
}

return await this.extractComparison(JSON.parse(await this.getFile(filePath)))
public static async getComparison(fileName: string): Promise<Comparison> {
return await this.extractComparison(JSON.parse(await this.getFile(fileName)))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion report-viewer/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const router = createRouter({
component: OverviewViewWrapper
},
{
path: '/comparison/:firstId/:secondId',
path: '/comparison/:comparisonFileName',
name: 'ComparisonView',
component: ComparisonViewWrapper,
props: true
Expand Down
16 changes: 3 additions & 13 deletions report-viewer/src/viewWrapper/ComparisonViewWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<template>
<ComparisonView
v-if="comparison && language"
:first-id="firstId"
:second-id="secondId"
:comparison="comparison"
:language="language"
/>
<ComparisonView v-if="comparison && language" :comparison="comparison" :language="language" />
<div
v-else
class="absolute bottom-0 left-0 right-0 top-0 flex flex-col items-center justify-center"
Expand All @@ -24,11 +18,7 @@ import { ComparisonFactory } from '@/model/factories/ComparisonFactory'
import LoadingCircle from '@/components/LoadingCircle.vue'
const props = defineProps({
firstId: {
type: String,
required: true
},
secondId: {
comparisonFileName: {
type: String,
required: true
}
Expand All @@ -39,7 +29,7 @@ const language: Ref<HighlightLanguage | null> = ref(null)
// This eslint rule is disabled to allow the use of await in the setup function. Disabling this rule is safe, because the props are gathered from the url, so changing them would reload the pafe anyway.
// eslint-disable-next-line vue/no-setup-props-reactivity-loss
ComparisonFactory.getComparison(props.firstId, props.secondId).then((comp) => {
ComparisonFactory.getComparison(props.comparisonFileName).then((comp) => {
comparison.value = comp
})
Expand Down
10 changes: 2 additions & 8 deletions report-viewer/src/views/ComparisonView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ import { MetricType } from '@/model/MetricType'
import { Comparison } from '@/model/Comparison'

const props = defineProps({
firstId: {
type: String,
required: true
},
secondId: {
type: String,
required: true
},
comparison: {
type: Object as PropType<Comparison>,
required: true
Expand All @@ -99,6 +91,8 @@ const props = defineProps({
}
})

const firstId = computed(() => props.comparison.firstSubmissionId)
const secondId = computed(() => props.comparison.secondSubmissionId)
const filesOfFirst = computed(() => props.comparison.filesOfFirstSubmission)
const filesOfSecond = computed(() => props.comparison.filesOfSecondSubmission)

Expand Down

0 comments on commit 30ac721

Please sign in to comment.