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 smart item Admin toolkit #136

Open
wants to merge 76 commits into
base: main
Choose a base branch
from

Conversation

cyaiox
Copy link
Collaborator

@cyaiox cyaiox commented Jan 31, 2025

Description

This PR introduces a new Admin Toolkit UI system for managing video players, smart items, and other administrative controls in Decentraland scenes.

Key Features

Core UI Components

  • Created new Button component with state management and variant support (primary/secondary/text)
  • Added VideoControl component for managing video players
  • Created SmartItemsControl for managing smart item actions

Video Control Features

  • Video player selection with support for multiple players
  • Play, pause, and restart controls
  • Volume control with visual feedback
  • URL input for video source management
  • "Link All" functionality to control multiple players simultaneously

Smart Items Control Features

  • Smart item selection dropdown
  • Action selection for each smart item
  • Show/Hide entity controls
  • Action restart functionality
  • Default action reset capability

State Management

  • Implemented Map-based state management for UI components
  • Created efficient state handling for video players
  • Added smart item state tracking
  • Proper state synchronization between components

Technical Details

  • Built using @dcl/react-ecs for UI components
  • Typescript-based implementation with proper type safety
  • Efficient state management using Maps
  • Consistent styling using predefined constants
  • Component-based architecture for better maintainability

Testing Instructions

  1. Test video player controls:

    • Select different video players
    • Try play/pause/restart
    • Adjust volume
    • Test URL input and sharing
    • Verify "Link All" functionality
  2. Test smart item controls:

    • Select different smart items
    • Try different actions
    • Test visibility toggling
    • Verify action restart
    • Check default action reset
  3. Test text announcement controls:

    • Write a message
    • Close the message
    • Write a few messages
    • Clear all messages
  4. Test rewards control:

    • Release a new Airdrop item
    • Test interaction with the rewards server

TODO (Future PRs)

High Priority

  1. Moderation Control Panel

    • Implement user moderation features
    • Add ban/unban functionality
    • Add user list management
    • Include moderation logs
  2. UI Style Improvements

    • Enhance panels background with better contrast and transparency
    • Add proper padding and spacing
    • Improve overall visual hierarchy
    • Add better error handling
    • Enhance user feedback
  3. Button Component Enhancement

    • Refine button states visual feedback
    • Add hover animations
    • Improve disabled state visibility
    • Add loading state support
  4. Text announcements Enhancement

    • Improve input writing delay
    • Improve input length limitation

Nice to Have

  • New Dropdown Component
    • Create custom dropdown implementation
    • Add multi-select support
    • Improve scrolling behavior
    • Add search/filter functionality
    • Support keyboard navigation

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows Decentraland's coding standards
  • I have added proper TypeScript types
  • Components are properly documented
  • All UI states are properly handled
  • The code is ready for review

Models and composers for AdminTools and CollectibleDispenser added in: #143

Copy link

github-actions bot commented Feb 6, 2025

Test this pull request

  • The package can be tested by running
    npm i "https://sdk-team-cdn.decentraland.org/@dcl/asset-packs/branch/feat/add-admin-toolkit-smart-item/dcl-asset-packs-2.1.3-13597644643.commit-5b87229.tgz"

Remember, if new assets are added in the PR, they won't be avaliable on the CDN until it gets merged. So this can be used to test changes on the package's JS or the catalog.json, but won't work to test newly added items.

@cyaiox cyaiox force-pushed the feat/add-admin-toolkit-smart-item branch 4 times, most recently from a831f0c to 169b334 Compare February 14, 2025 04:46
@cyaiox cyaiox force-pushed the feat/add-admin-toolkit-smart-item branch 3 times, most recently from 9525335 to 7bfe862 Compare February 25, 2025 13:51
@cyaiox cyaiox force-pushed the feat/add-admin-toolkit-smart-item branch from b61516e to ebbd249 Compare February 27, 2025 13:41
@cyaiox cyaiox marked this pull request as ready for review February 27, 2025 19:16
@cyaiox cyaiox force-pushed the feat/add-admin-toolkit-smart-item branch from 9461020 to d7a1ec9 Compare February 27, 2025 19:16
try {
const response = await signedFetch({
url: url,
...(init ? { init } : {}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use init here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as init could be undefined, this way we avoid errors when attempting to spread it

src/actions.ts Outdated
fetchCampaignsByDispenserKey(dispenserKey).then((campaigns) => {
const campaign = campaigns.find((c: any) => c.campaign_id === campaignId)
if (campaign && campaign.enabled) {
console.log('campaign', { campaign })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pointing out these logs to be sure if we want them

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing them

const sceneOwnersResponse = await fetch(LAND_MANAGER_URL, {
method: 'POST',
body: JSON.stringify({
query: `query getLands\n{\n parcels(where: {x: ${deployment.sceneBasePosition[0]}, y: ${deployment.sceneBasePosition[1]}}) {\n id\n x\n y\n owners {\n id\n address\n }\n }\n}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to format this string so it's readable?

sdkHelpers?: ISDKHelpers,
playersHelper?: IPlayersHelper,
) {
let adminToolkitEntity: Entity | null = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this var is local to this fn, it is possible for someone to create multiple admin toolkit systems. idk if that's a problem we should care or not but just pointing it out

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, fixing it!

@cyaiox cyaiox requested a review from nicoecheza February 28, 2025 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants