-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add request education features button and handle upskii-specific services #3087
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d25b67b
chore: enhance TokenVerifier component to support development mode an…
vhpx 96619e2
Merge branch 'main' into feat/add-upskii-permissions
VNOsST 3961c95
db: sb:typegen
VNOsST fd8caea
Fix build errors
VNOsST d596c16
Approval and Requests
VNOsST bdb6e86
Update request-access-button.tsx
VNOsST 1436862
Merge branch 'main' into feat/add-upskii-permissions
VNOsST e8bfea7
Update page.tsx
VNOsST 01d1836
Update page.tsx
VNOsST e4af605
Update row-actions.tsx
VNOsST File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { DEV_MODE } from '@/constants/common'; | ||
import { TokenVerifier } from '@tuturuuu/auth/cross-app/token-verifier'; | ||
|
||
export default function VerifyTokenPage() { | ||
return <TokenVerifier />; | ||
return <TokenVerifier devMode={DEV_MODE} />; | ||
} |
74 changes: 74 additions & 0 deletions
74
apps/db/supabase/migrations/20250609135112_add_platform_services.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
create type "public"."platform_service" as enum ('TUTURUUU', 'REWISE', 'NOVA', 'UPSKII'); | ||
|
||
alter table "public"."users" add column "services" platform_service[]; | ||
|
||
alter table "public"."users" alter column "services" set default '{TUTURUUU}'; | ||
|
||
-- Update existing users to have the default service if they don't have any services | ||
UPDATE public.users | ||
SET services = '{TUTURUUU}'::platform_service[] | ||
WHERE services IS NULL; | ||
|
||
CREATE OR REPLACE FUNCTION public.validate_cross_app_token_with_session( | ||
p_token TEXT, | ||
p_target_app TEXT | ||
) | ||
RETURNS TABLE(user_id UUID, session_data JSONB) AS $$ | ||
DECLARE | ||
v_record RECORD; | ||
v_required_service platform_service; | ||
v_user_services platform_service[]; | ||
BEGIN | ||
-- Find the token and get the user_id, session_data, and origin_app if it's valid | ||
SELECT t.user_id, t.session_data, t.origin_app INTO v_record | ||
FROM public.cross_app_tokens t | ||
WHERE t.token = p_token | ||
AND t.target_app = p_target_app | ||
AND t.expires_at > now() | ||
AND t.used_at IS NULL | ||
AND t.is_revoked = false; | ||
|
||
-- Log the found record for debugging | ||
RAISE NOTICE 'Found token record: user_id=%, session_data=%, origin_app=%', v_record.user_id, v_record.session_data, v_record.origin_app; | ||
|
||
-- If the token is valid, check additional permissions for service access | ||
IF v_record.user_id IS NOT NULL THEN | ||
-- If origin app is web, check that user has the required service for the target app | ||
IF v_record.origin_app = 'web' THEN | ||
-- Map target app to required platform service | ||
CASE p_target_app | ||
WHEN 'platform' THEN v_required_service := 'TUTURUUU'; | ||
WHEN 'rewise' THEN v_required_service := 'REWISE'; | ||
WHEN 'nova' THEN v_required_service := 'NOVA'; | ||
WHEN 'upskii' THEN v_required_service := 'UPSKII'; | ||
ELSE v_required_service := NULL; | ||
END CASE; | ||
|
||
-- Get user's services | ||
SELECT COALESCE(services, '{}'::platform_service[]) INTO v_user_services | ||
FROM public.users | ||
WHERE id = v_record.user_id; | ||
|
||
-- Add the required service if user doesn't have it yet | ||
IF v_required_service IS NOT NULL AND NOT (v_required_service = ANY(v_user_services)) THEN | ||
RAISE NOTICE 'Adding missing service % for user % accessing target app %', v_required_service, v_record.user_id, p_target_app; | ||
-- Add the service to the user's services array | ||
UPDATE public.users | ||
SET services = array_append(services, v_required_service) | ||
WHERE id = v_record.user_id; | ||
END IF; | ||
END IF; | ||
|
||
-- Mark token as used | ||
UPDATE public.cross_app_tokens | ||
SET used_at = now() | ||
WHERE token = p_token; | ||
|
||
-- Return the user_id and session_data | ||
RETURN QUERY SELECT v_record.user_id, v_record.session_data; | ||
ELSE | ||
-- Return NULL if token is invalid | ||
RETURN QUERY SELECT NULL::UUID, NULL::JSONB; | ||
END IF; | ||
END; | ||
$$ LANGUAGE plpgsql SECURITY DEFINER; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { DEV_MODE } from '@/constants/common'; | ||
import { TokenVerifier } from '@tuturuuu/auth/cross-app/token-verifier'; | ||
|
||
export default function VerifyTokenPage() { | ||
return <TokenVerifier />; | ||
return <TokenVerifier devMode={DEV_MODE} />; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { DEV_MODE } from '@/constants/common'; | ||
import { TokenVerifier } from '@tuturuuu/auth/cross-app/token-verifier'; | ||
|
||
export default function VerifyTokenPage() { | ||
return <TokenVerifier />; | ||
return <TokenVerifier devMode={DEV_MODE} />; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { DEV_MODE } from '@/constants/common'; | ||
import { TokenVerifier } from '@tuturuuu/auth/cross-app/token-verifier'; | ||
|
||
export default function VerifyTokenPage() { | ||
return <TokenVerifier />; | ||
return <TokenVerifier devMode={DEV_MODE} />; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { DEV_MODE } from '@/constants/common'; | ||
import { TokenVerifier } from '@tuturuuu/auth/cross-app/token-verifier'; | ||
|
||
export default function VerifyTokenPage() { | ||
return <TokenVerifier />; | ||
return <TokenVerifier devMode={DEV_MODE} />; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
apps/upskii/src/app/[locale]/(dashboard)/[wsId]/(workspace-settings)/approvals/columns.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
'use client'; | ||
|
||
import { WorkspaceApprovalRequest } from './page'; | ||
import { ApprovalRowActions } from './row-actions'; | ||
vhpx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { ColumnDef } from '@tanstack/react-table'; | ||
import { Badge } from '@tuturuuu/ui/badge'; | ||
import { DataTableColumnHeader } from '@tuturuuu/ui/custom/tables/data-table-column-header'; | ||
import { cn } from '@tuturuuu/utils/format'; | ||
import moment from 'moment'; | ||
|
||
export const approvalsColumns = ( | ||
t: any, | ||
namespace: string | undefined | ||
): ColumnDef<WorkspaceApprovalRequest>[] => [ | ||
{ | ||
accessorKey: 'id', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader | ||
t={t} | ||
column={column} | ||
title={t(`${namespace}.id`)} | ||
/> | ||
), | ||
cell: ({ row }) => ( | ||
<div className="line-clamp-1 max-w-32 break-all"> | ||
{row.getValue('id')} | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'workspace_name', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader t={t} column={column} title="Workspace" /> | ||
), | ||
cell: ({ row }) => ( | ||
<div className="line-clamp-1 max-w-48 font-semibold break-words"> | ||
{row.getValue('workspace_name')} | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'creator_name', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader t={t} column={column} title="Creator" /> | ||
), | ||
cell: ({ row }) => { | ||
const creatorName = row.getValue('creator_name') as string; | ||
|
||
return ( | ||
<div className="flex max-w-48 flex-col gap-1"> | ||
<div className="line-clamp-1 font-medium break-words"> | ||
{creatorName} | ||
</div> | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: 'feature_requested', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader t={t} column={column} title="Feature Requested" /> | ||
), | ||
cell: ({ row }) => ( | ||
<div className="line-clamp-1 max-w-32 break-words"> | ||
{row.getValue('feature_requested')} | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'request_message', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader t={t} column={column} title="Message" /> | ||
), | ||
cell: ({ row }) => ( | ||
<div className="line-clamp-2 max-w-64 text-sm break-words text-muted-foreground"> | ||
{row.getValue('request_message')} | ||
</div> | ||
), | ||
}, | ||
{ | ||
accessorKey: 'status', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader t={t} column={column} title="Status" /> | ||
), | ||
cell: ({ row }) => { | ||
const status = row.getValue('status') as string; | ||
|
||
return ( | ||
<Badge | ||
variant={ | ||
status === 'approved' | ||
? 'default' | ||
: status === 'rejected' | ||
? 'destructive' | ||
: 'secondary' | ||
} | ||
className={cn( | ||
'capitalize', | ||
status === 'approved' && | ||
'border-green-200 bg-green-100 text-green-800', | ||
status === 'rejected' && 'border-red-200 bg-red-100 text-red-800', | ||
status === 'pending' && | ||
'border-yellow-200 bg-yellow-100 text-yellow-800' | ||
)} | ||
> | ||
{status} | ||
</Badge> | ||
); | ||
}, | ||
}, | ||
{ | ||
accessorKey: 'created_at', | ||
header: ({ column }) => ( | ||
<DataTableColumnHeader t={t} column={column} title="Requested At" /> | ||
), | ||
cell: ({ row }) => ( | ||
<div className="line-clamp-2 max-w-32 text-sm break-all"> | ||
{row.getValue('created_at') | ||
? moment(row.getValue('created_at')).format('DD/MM/YYYY, HH:mm') | ||
: '-'} | ||
</div> | ||
), | ||
}, | ||
{ | ||
id: 'actions', | ||
header: ({ column }) => <DataTableColumnHeader t={t} column={column} />, | ||
cell: ({ row }) => <ApprovalRowActions row={row} />, | ||
}, | ||
]; | ||
Check warning on line 129 in apps/upskii/src/app/[locale]/(dashboard)/[wsId]/(workspace-settings)/approvals/columns.tsx
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.