Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/components/common/SystemCommands.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@
<span
v-bind="attrs"
class="text-wrap"
style="text-transform: capitalize;"
v-on="on"
>{{ service.name }}</span>
>{{ $filters.prettyCase(service.name) }}</span>
</template>
<span style="text-transform: capitalize;">{{ service.active_state }} ({{ service.sub_state }})</span>
<span>{{ $filters.prettyCase(`${service.active_state} (${service.sub_state})`) }}</span>
</v-tooltip>
</v-list-item-title>
</v-list-item-content>
Expand Down
14 changes: 14 additions & 0 deletions src/util/__tests__/string-formatters.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import stringFormatters from '../string-formatters'

describe('prettyCase', () => {
const sf = stringFormatters()

it.each([
['_ hello _ _world_ ', 'Hello World'],
['raspberry pi 3b+', 'Raspberry Pi 3b+'],
['Raspberry Pi 3B+', 'Raspberry Pi 3B+'],
['active (running)', 'Active (Running)'],
])('Expects pretty case of "%s" to be "%s"', (input, expected) => {
expect(sf.prettyCase(input)).toBe(expected)
})
})
7 changes: 3 additions & 4 deletions src/util/string-formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ const stringFormatters = () => {
const instance = {
prettyCase: (value: string) => {
return value
.split(/[ _]/g)
.filter(x => x)
.map(upperFirst)
.join(' ')
.replace(/[_ ]+/g, ' ')
.trim()
.replace(/\w+/g, match => upperFirst(match))
},

getPixelsString: (value: number | string | undefined | null) => {
Expand Down