Skip to content

Commit

Permalink
Simplify creator info and differentiate user/group
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber committed Dec 22, 2024
1 parent 37d893e commit 83a4fce
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 72 deletions.
4 changes: 2 additions & 2 deletions plugin/src/App/StatusPages/Permissions/SourceListing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function SourceListing:render()
Creator = e(
"TextLabel",
{
Text = callerInfoFromSource.Creator,
Text = callerInfoFromSource.Creator.Name,
FontFace = theme.Font.Main,
TextSize = theme.TextSize.Body,
TextColor3 = theme.Settings.Setting.NameColor,
Expand All @@ -118,7 +118,7 @@ function SourceListing:render()
),
BackgroundTransparency = 1,
},
if callerInfoFromSource.HasVerifiedBadge
if callerInfoFromSource.Creator.HasVerifiedBadge
then e(
"ImageLabel",
{
Expand Down
3 changes: 1 addition & 2 deletions plugin/src/App/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,7 @@ function App:render()
end,

onEdit = function(plugin, source, callerInfo, apiMap)
local name = callerInfo.Name
.. if callerInfo.Creator then " by " .. callerInfo.Creator else ""
local name = string.format("%s by %s", callerInfo.Name, callerInfo.Creator.Name)
local apiList = {}
for api in apiMap do
table.insert(apiList, api)
Expand Down
101 changes: 33 additions & 68 deletions plugin/src/HeadlessAPI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ export type CallerInfo = {
Type: "Local" | "Cloud" | "Studio",
Name: string,
Description: string,
Creator: string,
HasVerifiedBadge: boolean?,
Creator: {
Name: string,
Id: number,
HasVerifiedBadge: boolean,
},
}

local API = {}
Expand Down Expand Up @@ -105,43 +108,6 @@ function API.new(app)
return localPlugin
end

local cloudId, cloudInstance = string.match(topLevel, "cloud_(%d-)%.(.-)[^%w_%-]")
if cloudId then
local info = cloudIdProductInfoCache[cloudId]
if info then
return info.Name .. " by " .. info.Creator.Name
else
local success, newInfo =
pcall(MarketplaceService.GetProductInfo, MarketplaceService, tonumber(cloudId), Enum.InfoType.Asset)
if success then
cloudIdProductInfoCache[cloudId] = newInfo
return newInfo.Name .. " by " .. newInfo.Creator.Name
end
end

-- Fallback to the name of the instance uploaded inside this plugin
-- The reason this is not ideal is because creators often upload a folder named "Main" or something
return cloudInstance
end

return "Command Bar"
end

function Rojo:_getCallerInfo(): CallerInfo
local traceback = string.split(debug.traceback(), "\n")
local topLevel = traceback[#traceback - 1]

local localPlugin = string.match(topLevel, "user_(.-)%.")
if localPlugin then
return {
Type = "Local",
Name = localPlugin,
Description = "Locally installed plugin.",
Creator = "Unknown",
HasVerifiedBadge = false,
}
end

local cloudId, cloudInstance = string.match(topLevel, "cloud_(%d-)%.(.-)[^%w_%-]")
if cloudId then
local info = cloudIdProductInfoCache[cloudId]
Expand All @@ -155,31 +121,18 @@ function API.new(app)
end

if info then
return {
Type = "Cloud",
Name = info.Name,
Description = info.Description,
Creator = info.Creator.Name,
HasVerifiedBadge = info.Creator.HasVerifiedBadge,
}
return info.Name
.. " by "
.. (if info.Creator.CreatorType == "User" then "@" else "")
.. info.Creator.Name
else
return {
Type = "Cloud",
Name = cloudInstance,
Description = "Could not retrieve plugin asset info.",
Creator = "Unknown",
HasVerifiedBadge = false,
}
-- Fallback to the name of the instance uploaded inside this plugin
-- The reason this is not ideal is because creators often upload a folder named "Main" or something
return cloudInstance
end
end

return {
Type = "Studio",
Name = "Command Bar",
Description = "Command bar in Roblox Studio.",
Creator = "Unknown",
HasVerifiedBadge = false,
}
return "Command Bar"
end

function Rojo:_getCallerInfoFromSource(source: string): CallerInfo
Expand All @@ -189,8 +142,11 @@ function API.new(app)
Type = "Local",
Name = localPlugin,
Description = "Locally installed plugin.",
Creator = "Unknown",
HasVerifiedBadge = false,
Creator = {
Name = "Unknown",
Id = 0,
HasVerifiedBadge = false,
},
}
end

Expand All @@ -211,16 +167,22 @@ function API.new(app)
Type = "Cloud",
Name = info.Name,
Description = info.Description,
Creator = info.Creator.Name,
HasVerifiedBadge = info.Creator.HasVerifiedBadge,
Creator = {
Name = (if info.Creator.CreatorType == "User" then "@" else "") .. info.Creator.Name,
Id = info.Creator.CreatorTargetId,
HasVerifiedBadge = info.Creator.HasVerifiedBadge,
},
}
else
return {
Type = "Cloud",
Name = source,
Description = "Could not retrieve plugin asset info.",
Creator = "Unknown",
HasVerifiedBadge = false,
Creator = {
Name = "Unknown",
Id = 0,
HasVerifiedBadge = false,
},
}
end
end
Expand All @@ -229,8 +191,11 @@ function API.new(app)
Type = "Studio",
Name = "Command Bar",
Description = "Command bar in Roblox Studio.",
Creator = "Unknown",
HasVerifiedBadge = false,
Creator = {
Name = "N/A",
Id = 0,
HasVerifiedBadge = false,
},
}
end

Expand Down

0 comments on commit 83a4fce

Please sign in to comment.