Skip to content

Commit

Permalink
feat: add search to my apps list (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidma415 authored Oct 16, 2023
1 parent 306e3b2 commit 68e90f5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/locales/ca_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export const ca_ES: I18nType = {
plus: 'Més',
myApps: 'Les meves aplicacions',
refreshSecret: 'Actualitzar secret',
noSearchResults: translationNeeded(en.myApp.noSearchResults),
searchPlaceholder: translationNeeded(en.myApp.searchPlaceholder),
delete: 'Eliminar',
cancel: 'Cancel·lar',
noApp: 'Sense aplicacions',
Expand Down
2 changes: 2 additions & 0 deletions src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export const de: I18nType = {
plus: 'Plus',
myApps: 'Meine Applikationen',
refreshSecret: 'Secret erneuern',
noSearchResults: translationNeeded(en.myApp.noSearchResults),
searchPlaceholder: translationNeeded(en.myApp.searchPlaceholder),
delete: 'Löschen',
cancel: 'Abbrechen',
noApp: 'Keine Applikationen',
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export const en = {
delete: 'Delete',
cancel: 'Cancel',
noApp: 'No Applications',
searchPlaceholder: 'Search applications',
noSearchResults: 'No Applications Found',
create: 'Create a new app',
getStarted: ' to get started',
deleteDialog: (name: string) => `Are you sure you want to delete ${name}? This action cannot be undone.`
Expand Down
2 changes: 2 additions & 0 deletions src/locales/es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export const es_ES: I18nType = {
plus: 'Plus',
myApps: 'Mis aplicaciones',
refreshSecret: 'Refrescar clave secreta',
noSearchResults: translationNeeded(en.myApp.noSearchResults),
searchPlaceholder: translationNeeded(en.myApp.searchPlaceholder),
delete: 'Eliminar',
cancel: 'Cancelar',
noApp: 'No hay aplicaciones',
Expand Down
2 changes: 2 additions & 0 deletions src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export const fr: I18nType = {
plus: 'Plus',
myApps: 'Mes applications',
refreshSecret: 'Actualiser le secret',
noSearchResults: translationNeeded(en.myApp.noSearchResults),
searchPlaceholder: translationNeeded(en.myApp.searchPlaceholder),
delete: 'Supprimer',
cancel: 'Annuler',
noApp: 'Aucune application',
Expand Down
2 changes: 2 additions & 0 deletions src/locales/i18n-type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ export interface I18nType {
refreshSecret: string;
delete: string;
cancel: string;
searchPlaceholder: string;
noSearchResults: string;
noApp: string;
create: string;
getStarted: string;
Expand Down
21 changes: 19 additions & 2 deletions src/views/MyApps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,20 @@
is-small
class="applications-table"
:pagination-page-sizes="paginationConfig.paginationPageSizes"
:search-input="searchStr"
:initial-fetcher-params="{ pageSize: paginationConfig.initialPageSize }"
@row:click="(_, row) => $router.push({ name: 'show-application', params: { application_id: row.id }})"
>
<template #toolbar="{ state }">
<div class="applications-toolbar">
<KInput
v-if="state.hasData || searchStr"
v-model="searchStr"
:placeholder="helpText.searchPlaceholder"
type="search"
/>
</div>
</template>
<template #name="{ row }">
{{ row.name }}
</template>
Expand Down Expand Up @@ -102,7 +113,7 @@
</template>
<template #empty-state>
<EmptyState
:title="helpText.noApp"
:title="searchStr ? helpText.noSearchResults : helpText.noApp"
>
<template #message>
<p>
Expand Down Expand Up @@ -202,6 +213,7 @@ export default defineComponent({
setup () {
const { notify } = useToaster()
const errorMessage = ref('')
const searchStr = ref('')
const applications = ref([])
const key = ref(0)
const fetcherCacheKey = computed(() => key.value.toString())
Expand Down Expand Up @@ -242,7 +254,11 @@ export default defineComponent({
const fetcher = async (payload: { pageSize: number; page: number }) => {
const { pageSize, page: pageNumber } = payload
const reqPayload = { pageNumber, pageSize }
const reqPayload = {
pageNumber,
pageSize,
...(searchStr.value.length && { filterNameContains: searchStr.value })
}
send('FETCH')
Expand Down Expand Up @@ -353,6 +369,7 @@ export default defineComponent({
token,
onModalClose,
handleRefreshSecret,
searchStr,
fetcherCacheKey,
fetcher,
paginationConfig,
Expand Down

0 comments on commit 68e90f5

Please sign in to comment.