Skip to content

Commit 6288c46

Browse files
authored
Merge pull request #389 from LIT-Protocol/feat/support-deleted-official-apps
feat(dashboard): improved support for deleted apps, support official apps
2 parents 039205b + 28580d2 commit 6288c46

File tree

20 files changed

+763
-106
lines changed

20 files changed

+763
-106
lines changed

packages/apps/app-dashboard/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ VITE_DASHBOARD_URL=http://localhost:5173
2424
VITE_ENV=development
2525

2626
VITE_FEATURED_APP_IDS=
27+
VITE_OFFICIAL_APP_IDS=

packages/apps/app-dashboard/src/components/developer-dashboard/ability/wrappers/ui/AbilityActionButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function AbilityActionButtons({ onOpenMutation }: AbilityActionButtonsPro
4040
<ActionButton
4141
icon={Trash2}
4242
title="Delete Ability"
43-
description="Permanently remove this ability"
43+
description="Remove this ability (this can be undone)."
4444
onClick={() => onOpenMutation('delete-ability')}
4545
variant="danger"
4646
borderColor="rgb(254 202 202 / 0.5)"

packages/apps/app-dashboard/src/components/developer-dashboard/app/wrappers/ui/AppPublishedButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export function AppPublishedButtons({
156156
<ActionButton
157157
icon={Trash2}
158158
title="Delete App"
159-
description="Permanently remove this app"
159+
description="Remove this app (this can be undone)."
160160
onClick={() => onOpenMutation('delete-app')}
161161
variant="danger"
162162
borderColor="rgb(254 202 202 / 0.5)"

packages/apps/app-dashboard/src/components/developer-dashboard/app/wrappers/ui/AppUnpublishedButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function AppUnpublishedButtons({ onOpenMutation }: AppUnpublishedButtonsP
2929
<ActionButton
3030
icon={Trash2}
3131
title="Delete App"
32-
description="Permanently remove this app"
32+
description="Remove this app (this can be undone)."
3333
onClick={() => onOpenMutation('delete-app')}
3434
variant="danger"
3535
borderColor="rgb(254 202 202 / 0.5)"

packages/apps/app-dashboard/src/components/developer-dashboard/app/wrappers/ui/AppVersionUnpublishedButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function AppVersionUnpublishedButtons({
6262
<ActionButton
6363
icon={Trash2}
6464
title="Delete Version"
65-
description="Permanently remove this version"
65+
description="Remove this version (this can be undone)."
6666
onClick={() => onOpenMutation('delete-version')}
6767
variant="danger"
6868
borderColor="rgb(254 202 202 / 0.3)"

packages/apps/app-dashboard/src/components/developer-dashboard/policy/wrappers/ui/PolicyActionButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function PolicyActionButtons({ onOpenMutation }: PolicyActionButtonsProps
4040
<ActionButton
4141
icon={Trash2}
4242
title="Delete Policy"
43-
description="Permanently remove this policy"
43+
description="Remove this policy (this can be undone)."
4444
onClick={() => onOpenMutation('delete-policy')}
4545
variant="danger"
4646
borderColor="rgb(254 202 202 / 0.5)"

packages/apps/app-dashboard/src/components/explorer/ui/AppFilter.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function AppFilter({
1111
}: {
1212
searchQuery: string;
1313
setSearchQuery: (searchQuery: string) => void;
14-
statusFilter: 'all' | 'prod' | 'test';
14+
statusFilter: 'official' | 'all' | 'prod' | 'test';
1515
setStatusFilter: (statusFilter: string) => void;
1616
sortBy: 'name' | 'updated' | 'version';
1717
setSortBy: (sortBy: string) => void;
@@ -48,10 +48,10 @@ export function AppFilter({
4848
style={fonts.heading}
4949
>
5050
<option
51-
value="all"
51+
value="official"
5252
className="bg-white dark:bg-gray-900 text-gray-900 dark:text-white"
5353
>
54-
All Status
54+
Official
5555
</option>
5656
<option
5757
value="prod"
@@ -65,6 +65,12 @@ export function AppFilter({
6565
>
6666
Beta
6767
</option>
68+
<option
69+
value="all"
70+
className="bg-white dark:bg-gray-900 text-gray-900 dark:text-white"
71+
>
72+
All Apps
73+
</option>
6874
</select>
6975
</div>
7076

packages/apps/app-dashboard/src/components/explorer/ui/FeaturedApps.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { App } from '@/types/developer-dashboard/appTypes';
1+
import { useCallback } from 'react';
22
import { useNavigate } from 'react-router-dom';
3+
import { App } from '@/types/developer-dashboard/appTypes';
34
import { Logo } from '@/components/shared/ui/Logo';
45
import { theme, fonts } from '@/components/user-dashboard/connect/ui/theme';
5-
import { useCallback } from 'react';
6+
import { env } from '@/config/env';
7+
8+
const { VITE_FEATURED_APP_IDS } = env;
69

710
interface FeaturedAppCardProps {
811
app: App;
@@ -92,15 +95,14 @@ export function FeaturedApps({ apps, onNavigate }: FeaturedAppsProps) {
9295
[navigate, onNavigate],
9396
);
9497

95-
const featuredAppIdsString = import.meta.env.VITE_FEATURED_APP_IDS;
96-
const featuredAppIds = featuredAppIdsString
97-
? featuredAppIdsString.split(',').map((id: string) => id.trim())
98+
const featuredAppIds = VITE_FEATURED_APP_IDS
99+
? VITE_FEATURED_APP_IDS.split(',').map((id: string) => Number(id.trim()))
98100
: [];
99101

100102
// Filter apps to only include featured ones, in the order specified
101103
const featuredApps = featuredAppIds
102-
.map((appId: string) => {
103-
const found = apps.find((app: App) => String(app.appId) === String(appId));
104+
.map((appId: number) => {
105+
const found = apps.find((app: App) => app.appId === appId);
104106
return found;
105107
})
106108
.filter((app: App | undefined): app is App => app !== undefined);

packages/apps/app-dashboard/src/components/explorer/views/AppExploreView.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { AppFilter } from '../ui/AppFilter';
77
import { ExplorerNav } from '../ui/ExplorerNav';
88
import { FeaturedApps } from '../ui/FeaturedApps';
99
import { theme, fonts } from '@/components/user-dashboard/connect/ui/theme';
10+
import { env } from '@/config/env';
11+
12+
const { VITE_OFFICIAL_APP_IDS } = env;
1013

1114
interface ExploreViewProps {
1215
apps: App[];
@@ -16,13 +19,19 @@ export function AppExploreView({ apps }: ExploreViewProps) {
1619
const location = useLocation();
1720
const navigate = useNavigate();
1821
const [searchQuery, setSearchQuery] = useState('');
19-
const [statusFilter, setStatusFilter] = useState<'all' | 'prod' | 'test'>('prod');
22+
const [statusFilter, setStatusFilter] = useState<'official' | 'all' | 'prod' | 'test'>(
23+
'official',
24+
);
2025
const [sortBy, setSortBy] = useState<'name' | 'updated' | 'version'>('name');
2126
const [currentPage, setCurrentPage] = useState(1);
2227
const [showContent, setShowContent] = useState(false);
2328
const [isTransitioning, setIsTransitioning] = useState(false);
2429
const appsPerPage = 9;
2530

31+
const officialAppIds = VITE_OFFICIAL_APP_IDS
32+
? VITE_OFFICIAL_APP_IDS.split(',').map((id: string) => Number(id.trim()))
33+
: [];
34+
2635
useEffect(() => {
2736
const fromTransition = location.state?.fromTransition;
2837
if (fromTransition) {
@@ -37,7 +46,16 @@ export function AppExploreView({ apps }: ExploreViewProps) {
3746
const matchesSearch =
3847
app.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
3948
app.description?.toLowerCase().includes(searchQuery.toLowerCase());
40-
const matchesStatus = statusFilter === 'all' || app.deploymentStatus === statusFilter;
49+
50+
let matchesStatus = false;
51+
if (statusFilter === 'official') {
52+
matchesStatus = officialAppIds.includes(app.appId);
53+
} else if (statusFilter === 'all') {
54+
matchesStatus = true;
55+
} else {
56+
matchesStatus = app.deploymentStatus === statusFilter;
57+
}
58+
4159
return matchesSearch && matchesStatus;
4260
})
4361
.sort((a, b) => {

packages/apps/app-dashboard/src/components/user-dashboard/connect/ConnectPageWraper.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { AppVersionNotInRegistryConnect } from './AppVersionNotInRegistry';
77
import { AuthConnectScreen } from './AuthConnectScreen';
88
import { BadRedirectUriError } from './BadRedirectUriError';
99
import { ConnectPage } from './ConnectPage';
10+
import { DeletedAppConnect } from './DeletedAppConnect';
1011
import { DisabledVersionConnect } from './DisabledVersionConnect';
1112
import { EditPermissionsCard } from './EditPermissionsCard';
1213
import { GeneralErrorScreen } from './GeneralErrorScreen';
@@ -128,6 +129,16 @@ export function ConnectPageWrapper() {
128129
<BadRedirectUriError redirectUri={redirectUri} authorizedUris={data.app?.redirectUris} />
129130
);
130131
}
132+
// Check if app is deleted
133+
else if (data.app?.isDeleted) {
134+
content = (
135+
<DeletedAppConnect
136+
appData={data.app}
137+
hasPermission={isPermitted}
138+
readAuthInfo={{ authInfo, sessionSigs, isProcessing, error }}
139+
/>
140+
);
141+
}
131142
// Check for unpublished app version (check this early, before auth)
132143
else if (!data.app?.activeVersion) {
133144
// App has no active version set (version 1 not published)

0 commit comments

Comments
 (0)