Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add search to my apps list #267

Merged
merged 1 commit into from
Oct 16, 2023
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
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