diff --git a/packages/bbui/src/Icon/Icon.svelte b/packages/bbui/src/Icon/Icon.svelte
index 275c339bf4..c7261ea74d 100644
--- a/packages/bbui/src/Icon/Icon.svelte
+++ b/packages/bbui/src/Icon/Icon.svelte
@@ -1,58 +1,53 @@
-
-
-
-
-
- {#if $apps.length > 0}
+ {#if $appsStore.apps.length > 0}
{/if}
diff --git a/packages/builder/src/pages/builder/portal/apps/create.svelte b/packages/builder/src/pages/builder/portal/apps/create.svelte
index 1f2c579071..1248c41cf8 100644
--- a/packages/builder/src/pages/builder/portal/apps/create.svelte
+++ b/packages/builder/src/pages/builder/portal/apps/create.svelte
@@ -5,7 +5,7 @@
import CreateAppModal from "components/start/CreateAppModal.svelte"
import TemplateDisplay from "components/common/TemplateDisplay.svelte"
import AppLimitModal from "components/portal/licensing/AppLimitModal.svelte"
- import { apps, templates, licensing } from "stores/portal"
+ import { appsStore, templates, licensing } from "stores/portal"
import { Breadcrumbs, Breadcrumb, Header } from "components/portal/page"
let template
@@ -35,7 +35,7 @@
}
-{#if !$apps.length}
+{#if !$appsStore.apps.length}
{:else}
diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte
index a1aa242a36..c087e3cc86 100644
--- a/packages/builder/src/pages/builder/portal/apps/index.svelte
+++ b/packages/builder/src/pages/builder/portal/apps/index.svelte
@@ -19,10 +19,16 @@
import { automationStore, initialise } from "stores/builder"
import { API } from "api"
import { onMount } from "svelte"
- import { apps, auth, admin, licensing, environment } from "stores/portal"
+ import {
+ appsStore,
+ auth,
+ admin,
+ licensing,
+ environment,
+ enriched as enrichedApps,
+ } from "stores/portal"
import { goto } from "@roxi/routify"
import AppRow from "components/start/AppRow.svelte"
- import { AppStatus } from "constants"
import Logo from "assets/bb-space-man.svg"
let sortBy = "name"
@@ -33,56 +39,27 @@
let searchTerm = ""
let creatingFromTemplate = false
let automationErrors
- let accessFilterList = null
$: welcomeHeader = `Welcome ${$auth?.user?.firstName || "back"}`
- $: enrichedApps = enrichApps($apps, $auth.user, sortBy)
- $: filteredApps = enrichedApps.filter(
- app =>
- (searchTerm
- ? app?.name?.toLowerCase().includes(searchTerm.toLowerCase())
- : true) &&
- (accessFilterList !== null
- ? accessFilterList?.includes(
- `${app?.type}_${app?.tenantId}_${app?.appId}`
- )
- : true)
- )
- $: automationErrors = getAutomationErrors(enrichedApps)
+ $: filteredApps = filterApps($enrichedApps, searchTerm)
+ $: automationErrors = getAutomationErrors(filteredApps || [])
$: isOwner = $auth.accountPortalAccess && $admin.cloud
+ const filterApps = (apps, searchTerm) => {
+ return apps?.filter(app => {
+ const query = searchTerm?.trim()?.replace(/\s/g, "")
+ if (query) {
+ return app?.name?.toLowerCase().includes(query.toLowerCase())
+ } else {
+ return true
+ }
+ })
+ }
+
const usersLimitLockAction = $licensing?.errUserLimit
? () => accountLockedModal.show()
: null
- const enrichApps = (apps, user, sortBy) => {
- const enrichedApps = apps.map(app => ({
- ...app,
- deployed: app.status === AppStatus.DEPLOYED,
- lockedYou: app.lockedBy && app.lockedBy.email === user?.email,
- lockedOther: app.lockedBy && app.lockedBy.email !== user?.email,
- }))
-
- if (sortBy === "status") {
- return enrichedApps.sort((a, b) => {
- if (a.status === b.status) {
- return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1
- }
- return a.status === AppStatus.DEPLOYED ? -1 : 1
- })
- } else if (sortBy === "updated") {
- return enrichedApps.sort((a, b) => {
- const aUpdated = a.updatedAt || "9999"
- const bUpdated = b.updatedAt || "9999"
- return aUpdated < bUpdated ? 1 : -1
- })
- } else {
- return enrichedApps.sort((a, b) => {
- return a.name?.toLowerCase() < b.name?.toLowerCase() ? -1 : 1
- })
- }
- }
-
const getAutomationErrors = apps => {
const automationErrors = {}
for (let app of apps) {
@@ -117,7 +94,7 @@
const initiateAppCreation = async () => {
if ($licensing?.usageMetrics?.apps >= 100) {
appLimitModal.show()
- } else if ($apps?.length) {
+ } else if ($appsStore.apps?.length) {
$goto("/builder/portal/apps/create")
} else {
template = null
@@ -136,7 +113,7 @@
const templateKey = template.key.split("/")[1]
let appName = templateKey.replace(/-/g, " ")
- const appsWithSameName = $apps.filter(app =>
+ const appsWithSameName = $appsStore.apps.filter(app =>
app.name?.startsWith(appName)
)
appName = `${appName} ${appsWithSameName.length + 1}`
@@ -217,7 +194,7 @@
: "View error"}
on:dismiss={async () => {
await automationStore.actions.clearLogErrors({ appId })
- await apps.load()
+ await appsStore.load()
}}
message={automationErrorMessage(appId)}
/>
@@ -233,7 +210,7 @@
- {#if enrichedApps.length}
+ {#if $appsStore.apps.length}