Skip to content

Commit

Permalink
refactor: update vue-i18n usage to Composition API
Browse files Browse the repository at this point in the history
  • Loading branch information
strahe committed Feb 9, 2025
1 parent 2359eaa commit 207178f
Show file tree
Hide file tree
Showing 26 changed files with 121 additions and 97 deletions.
2 changes: 1 addition & 1 deletion ui/src/components/shared/BaseBreadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const breadcrumbs = computed(() => {
class="text-lightText text-h6 text-decoration-none"
to="/"
>
{{ $t('nav.Home') }}
{{ t('nav.Home') }}
</router-link>
<div class="d-flex align-center px-2">
/
Expand Down
46 changes: 7 additions & 39 deletions ui/src/views/configurations/ConfigRemoveDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { useMutation } from '@vue/apollo-composable'
import { GetConfigs, RemoveConfig } from '@/gql/config'
import { IconAlertOctagon, IconTrash } from '@tabler/icons-vue'
import { useUIStore } from '@/stores/ui'
const uiStore = useUIStore()
import { useI18n } from 'vue-i18n'
const props = defineProps({
title: {
Expand All @@ -25,6 +24,8 @@ const props = defineProps({
default: undefined,
},
})
const uiStore = useUIStore()
const { t } = useI18n()
const dialog = ref(false)
Expand Down Expand Up @@ -99,15 +100,15 @@ onError(e => {
/>
</template>
<template #title>
{{ $t('msgs.sureRemoveConfig', 1) }}
{{ t('msgs.sureRemoveConfig', 1) }}
</template>
</v-list-item>

<v-divider />

<v-card-text class="text-medium-emphasis pa-6">
<div class="text-h6 mb-6">
{{ $t('msgs.actionCantUndo') }}
{{ t('msgs.actionCantUndo') }}
</div>
<div class="my-4">
Configuration: <v-chip
Expand All @@ -121,51 +122,18 @@ onError(e => {
<v-card-actions>
<v-spacer />
<v-btn @click="dialog = false">
{{ $t('actions.Cancel') }}
{{ t('actions.Cancel') }}
</v-btn>
<v-btn
color="error"
:loading="loading"
variant="flat"
@click="removeConfig"
>
{{ $t('actions.Remove') }}
{{ t('actions.Remove') }}
</v-btn>
</v-card-actions>
</v-card>
</template>
</v-dialog>

<!-- <v-btn color="error">-->
<!-- <template #prepend>-->
<!-- <IconTrash />-->
<!-- </template>-->
<!-- Remove-->
<!-- <v-dialog v-model="dialog" activator="parent" max-width="600">-->
<!-- <v-card-->
<!-- subtitle="Are you sure you want to remove this configuration?"-->
<!-- title="Remove Configuration"-->
<!-- >-->
<!-- <v-card-text>-->
<!-- <v-chip color="error" label>{{ props.title }}</v-chip>-->
<!-- <v-alert-->
<!-- v-if="error"-->
<!-- class="mt-4"-->
<!-- color="error"-->
<!-- :text="error.message"-->
<!-- />-->
<!-- </v-card-text>-->
<!-- <v-card-actions>-->
<!-- <v-btn-->
<!-- color="error"-->
<!-- :loading="loading"-->
<!-- text="true"-->
<!-- variant="outlined"-->
<!-- @click="removeConfig({ title: props.title })"-->
<!-- > Confirm </v-btn>-->
<!-- </v-card-actions>-->
<!-- </v-card>-->
<!-- </v-dialog>-->
<!-- </v-btn>-->
</template>

7 changes: 5 additions & 2 deletions ui/src/views/configurations/UsedByListDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { PropType, ref } from 'vue'
import { MachineDetail } from '@/typed-graph'
import { IconSearch } from '@tabler/icons-vue'
import { useI18n } from 'vue-i18n'
const props = defineProps({
title: {
Expand All @@ -14,6 +15,8 @@ const props = defineProps({
},
})
const { t, d } = useI18n()
const searchValue = ref('')
const dialog = ref(false)
const headers = [
Expand All @@ -39,7 +42,7 @@ const headers = [
@click="dialog = true"
>
{{ props.usedBy.length }}
</v-btn> {{ $t('fields.Node', props.usedBy.length) }}
</v-btn> {{ t('fields.Node', props.usedBy.length) }}
</template>
<template #default="{ }">
<v-data-table-virtual
Expand All @@ -64,7 +67,7 @@ const headers = [
</v-text-field>
</template>
<template #item.startupTime="{ value }">
{{ $d(value, 'short') }}
{{ d(value, 'short') }}
</template>
</v-data-table-virtual>
</template>
Expand Down
4 changes: 3 additions & 1 deletion ui/src/views/deals/PendingDeals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { computed, ComputedRef, ref } from 'vue'
import { OpenSectorPiece } from '@/typed-graph'
import { DealSealNow, GetPendingDeals } from '@/gql/deal'
import { IconReload, IconSearch } from '@tabler/icons-vue'
import { useI18n } from 'vue-i18n'
import { useUIStore } from '@/stores/ui'
import { formatBytes } from '@/utils/helpers/formatBytes'
const uiStore = useUIStore()
const { d } = useI18n()
const { result, loading, refetch } = useQuery(GetPendingDeals, null, () => ({
fetchPolicy: 'cache-first',
Expand Down Expand Up @@ -121,7 +123,7 @@ const fillProgress = computed(() => (spID: number, sectorNumber: number): number
sticky
>
<template #item.createdAt="{ item }">
{{ $d(item.createdAt, 'short') }}
{{ d(item.createdAt, 'short') }}
</template>
<template #group-header="{ item, index, columns, toggleGroup, isGroupOpen }">
<div
Expand Down
7 changes: 5 additions & 2 deletions ui/src/views/machines/MachineList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { useQuery } from '@vue/apollo-composable'
import { GetMachines } from '@/gql/machine'
import { Machine } from '@/typed-graph'
import { formatBytes } from '@/utils/helpers/formatBytes'
import { useI18n } from 'vue-i18n'
const { d } = useI18n()
const { result, loading, refetch } = useQuery(GetMachines, null, () => ({
fetchPolicy: 'cache-first',
Expand Down Expand Up @@ -154,12 +157,12 @@ const headers = [
</template>
<template #item.lastContact="{ value }">
<div :title="value">
{{ $d(value, 'short') }}
{{ d(value, 'short') }}
</div>
</template>
<template #item.detail.startupTime="{ value }">
<div :title="value">
{{ $d(value, 'short') }}
{{ d(value, 'short') }}
</div>
</template>
<template #item.ram="{ value }">
Expand Down
7 changes: 5 additions & 2 deletions ui/src/views/machines/MachineSummaryCharts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { GetMachinesSummary } from '@/gql/machine'
import { MachineSummary } from '@/typed-graph'
import { formatBytes } from '@/utils/helpers/formatBytes'
import { IconBrandSpeedtest, IconCpu, IconServer } from '@tabler/icons-vue'
import { useI18n } from 'vue-i18n'
const { t, d } = useI18n()
const { result } = useQuery(GetMachinesSummary, null, () => ({
fetchPolicy: 'cache-first',
Expand Down Expand Up @@ -35,13 +38,13 @@ const cards = computed(() => [
<div class="d-flex align-items-center justify-space-between">
<div>
<h5 class="text-h5">
{{ $t('fields.'+card.text) }}
{{ t('fields.'+card.text) }}
</h5>
<h3 class="text-h3 my-2">
{{ card.value }}
</h3>
<h6 class="text-caption font-weight-medium mb-0">
{{ $d(new Date(), "short") }}
{{ d(new Date(), "short") }}
</h6>
</div>
<span class="d-flex align-center">
Expand Down
6 changes: 3 additions & 3 deletions ui/src/views/machines/MachineTasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { GetMachineTasks } from '@/gql/machine'
import { IconReload } from '@tabler/icons-vue'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const { t, d } = useI18n()
const props = defineProps({
id: {
Expand Down Expand Up @@ -66,10 +66,10 @@ const headers = [
</v-chip>
</template>
<template #item.updateTime="{ value }">
{{ $d(value, 'short') }}
{{ d(value, 'short') }}
</template>
<template #item.postedTime="{ value }">
{{ $d(value, 'short') }}
{{ d(value, 'short') }}
</template>
<template #item.previousTask="{ value }">
<!-- todo: add router link to previous task details-->
Expand Down
5 changes: 4 additions & 1 deletion ui/src/views/messages/widgets/MessageSendsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { computed, ComputedRef, ref } from "vue"
import { MessageSend } from "@/typed-graph"
import { IconInfoCircle, IconReload } from "@tabler/icons-vue"
import { useTableSettingsStore } from "@/stores/table"
import { useI18n } from "vue-i18n"
const props = defineProps({
account: {
Expand All @@ -21,6 +22,8 @@ const props = defineProps({
},
})
const { d } = useI18n()
const tableSettings = useTableSettingsStore()
const localAccount = ref(props.account)
Expand Down Expand Up @@ -121,7 +124,7 @@ const headers = [
<TruncatedChip :text="value" />
</template>
<template #item.sendTime="{ value }">
{{ value ? $d(value, 'short') : '' }}
{{ value ? d(value, 'short') : '' }}
</template>
<template #item.signedCid="{ value }">
<TruncatedChip :text="value" />
Expand Down
5 changes: 4 additions & 1 deletion ui/src/views/mining/overview/TabCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IconCaretDown, IconCaretUp, IconCaretUpDown } from "@tabler/icons-vue"
import { useQuery } from "@vue/apollo-composable"
import { GetMiningCountSummaryWithPrevious } from "@/gql/mining"
import TabCardChart from "@/views/mining/overview/TabCardChart.vue"
import { useI18n } from 'vue-i18n'
const props = defineProps({
start: {
Expand All @@ -20,6 +21,8 @@ const props = defineProps({
},
})
const { d } = useI18n()
const items = ref(['Today', 'Last 7 days', 'Last 30 days'])
const selected = ref('Today')
Expand Down Expand Up @@ -101,7 +104,7 @@ const cards = computed(() => {
{{ card.value }}
</h5>
<span class="text-lightText text-caption pt-2">
{{ $d(props.start, 'toShortDay') }} - {{ $d(props.end, 'toShortDay') }}
{{ d(props.start, 'toShortDay') }} - {{ d(props.end, 'toShortDay') }}
</span>
</div>
<div class="d-flex align-center">
Expand Down
6 changes: 4 additions & 2 deletions ui/src/views/mining/wins/MiningTaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { GetMiningWins } from '@/gql/mining'
import { useQuery } from '@vue/apollo-composable'
import { IconInfoCircle } from '@tabler/icons-vue'
import { useTableSettingsStore } from "@/stores/table"
import { useI18n } from 'vue-i18n'
const props = defineProps({
start: {
Expand All @@ -25,6 +26,7 @@ const props = defineProps({
},
})
const { d } = useI18n()
const tableSettings = useTableSettingsStore()
const page = ref(1)
Expand Down Expand Up @@ -142,10 +144,10 @@ const headers = [
<TruncatedChip :text="value" />
</template>
<template #item.minedAt="{value}">
{{ $d(value, 'long') }}
{{ d(value, 'long') }}
</template>
<template #item.submittedAt="{value}">
{{ $d(value, 'long') }}
{{ d(value, 'long') }}
</template>
<template #item.minedHeader="{value}">
<v-dialog>
Expand Down
4 changes: 3 additions & 1 deletion ui/src/views/porep/SectorList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import SectorRemoveDialog from '@/views/sectors/SectorRemoveDialog.vue'
import { RestartAllFailedSector } from '@/gql/sector'
import { useUIStore } from '@/stores/ui'
import SectorRestart from '@/views/sectors/SectorRestart.vue'
import { useI18n } from 'vue-i18n'
const uiStore = useUIStore()
const { d } = useI18n()
const { result, loading, refetch } = useQuery(GetSectorsPoreps, null, () => ({
fetchPolicy: 'network-only',
Expand Down Expand Up @@ -179,7 +181,7 @@ onDone(() => {
</div>
</template>
<template #item.createTime="{value}">
{{ $d(value, 'short') }}
{{ d(value, 'short') }}
</template>
<template #item.actions="{ item }">
<SectorRemoveDialog
Expand Down
14 changes: 8 additions & 6 deletions ui/src/views/sectors/SectorRemoveDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useMutation } from '@vue/apollo-composable'
import { RemoveSector } from '@/gql/sector'
import { IconAlertOctagon, IconTrash } from '@tabler/icons-vue'
import { useUIStore } from '@/stores/ui'
import { useI18n } from 'vue-i18n'
interface Sector {
spId: string,
Expand All @@ -30,6 +31,7 @@ const props = defineProps({
},
})
const { t } = useI18n()
const uiStore = useUIStore()
const success = ref(0)
Expand Down Expand Up @@ -118,15 +120,15 @@ function removeSector () {
/>
</template>
<template #title>
{{ $t('msgs.sureRemoveSector', sectors.length) }}
{{ t('msgs.sureRemoveSector', sectors.length) }}
</template>
</v-list-item>

<v-divider />

<v-card-text class="text-medium-emphasis pa-6">
<div class="text-h6 mb-6">
{{ $t('msgs.actionCantUndo') }}
{{ t('msgs.actionCantUndo') }}
</div>

<template v-if="sectors.length > 1">
Expand Down Expand Up @@ -169,14 +171,14 @@ function removeSector () {
class="my-4 text-overline"
style="color: yellow"
>
({{ $t('msgs.sectorNotFailed', props.sectors.length) }})
({{ t('msgs.sectorNotFailed', props.sectors.length) }})
</div>
</v-col>
<v-col cols="auto">
<v-checkbox v-model="doubleCheck">
<template #label>
{{
$t('msgs.understand')
t('msgs.understand')
}}
</template>
</v-checkbox>
Expand All @@ -186,7 +188,7 @@ function removeSector () {
<v-card-actions>
<v-spacer />
<v-btn @click="dialog = false">
{{ $t('actions.Cancel') }}
{{ t('actions.Cancel') }}
</v-btn>
<v-btn
color="error"
Expand All @@ -195,7 +197,7 @@ function removeSector () {
variant="flat"
@click="removeSector"
>
{{ $t('actions.Remove') }}
{{ t('actions.Remove') }}
</v-btn>
</v-card-actions>
</v-card>
Expand Down
Loading

0 comments on commit 207178f

Please sign in to comment.