Skip to content

Commit

Permalink
Merge branch 'AGE-914/implement-app-management-view' of https://githu…
Browse files Browse the repository at this point in the history
…b.com/Agenta-AI/agenta into AGE-914/implement-app-management-view
  • Loading branch information
bekossy committed Oct 7, 2024
2 parents c7d09ca + 424f08d commit 9262d7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions agenta-web/src/components/AppSelector/AppSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ResultComponent from "../ResultComponent/ResultComponent"
import {dynamicContext} from "@/lib/helpers/dynamic"
import AppTemplateCard from "./AppTemplateCard"
import Image from "next/image"
import dayjs from "dayjs"

const useStyles = createUseStyles((theme: JSSTheme) => ({
container: ({themeMode}: StyleProps) => ({
Expand Down Expand Up @@ -245,9 +246,16 @@ const AppSelector: React.FC = () => {
}

const filteredApps = useMemo(() => {
return searchTerm
? apps.filter((app) => app.app_name.toLowerCase().includes(searchTerm.toLowerCase()))
: apps
let filtered = apps.sort(
(a, b) => dayjs(b.updated_at).valueOf() - dayjs(a.updated_at).valueOf(),
)

if (searchTerm) {
filtered = apps.filter((app) =>
app.app_name.toLowerCase().includes(searchTerm.toLowerCase()),
)
}
return filtered
}, [apps, searchTerm])

const steps = [
Expand Down
5 changes: 5 additions & 0 deletions agenta-web/src/components/AppSelector/modals/EditAppModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {CheckOutlined} from "@ant-design/icons"
import {Input, Modal, Typography} from "antd"
import React, {useMemo, useState} from "react"
import {createUseStyles} from "react-jss"
import {useUpdateEffect} from "usehooks-ts"

type EditAppModalProps = {
appDetails: ListAppsItem
Expand All @@ -29,6 +30,10 @@ const EditAppModal = ({appDetails, ...props}: EditAppModalProps) => {
const [appNameInput, setAppNameInput] = useState(appDetails.app_name)
const [editAppLoading, setEditAppLoading] = useState(false)

useUpdateEffect(() => {
setAppNameInput(appDetails.app_name)
}, [apps])

const appNameExist = useMemo(
() =>
apps.some(
Expand Down

0 comments on commit 9262d7d

Please sign in to comment.