Skip to content

Commit

Permalink
Stylua formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber committed Sep 19, 2023
1 parent 1042b36 commit b8e5fda
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 75 deletions.
5 changes: 4 additions & 1 deletion plugin/src/App/Components/Toggle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ function Toggle:render()
Size = self.containerSize:map(function(value)
local offset = self.props.options ~= nil and 120 or 40
local textBounds = getTextBounds(
self.props.description, 14, Enum.Font.Gotham, 1.2,
self.props.description,
14,
Enum.Font.Gotham,
1.2,
Vector2.new(value.X - offset, math.huge)
)
return UDim2.new(1, -offset, 0, textBounds.Y)
Expand Down
12 changes: 10 additions & 2 deletions plugin/src/App/ConflictAPIPopup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ function ConflictAPIPopup:render()
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0, 0),
AutomaticSize = Enum.AutomaticSize.Y,
Text = string.format("Existing: Version %s, Protocol %d", Version.display(self.props.existingAPI.Version), self.props.existingAPI.ProtocolVersion),
Text = string.format(
"Existing: Version %s, Protocol %d",
Version.display(self.props.existingAPI.Version),
self.props.existingAPI.ProtocolVersion
),
Font = Enum.Font.Gotham,
TextSize = 15,
TextColor3 = theme.Setting.DescriptionColor,
Expand All @@ -71,7 +75,11 @@ function ConflictAPIPopup:render()
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0, 0),
AutomaticSize = Enum.AutomaticSize.Y,
Text = string.format("Incoming: Version %s, Protocol %d", Version.display(Config.version), Config.protocolVersion),
Text = string.format(
"Incoming: Version %s, Protocol %d",
Version.display(Config.version),
Config.protocolVersion
),
Font = Enum.Font.Gotham,
TextSize = 15,
TextColor3 = theme.Setting.DescriptionColor,
Expand Down
50 changes: 25 additions & 25 deletions plugin/src/App/Notifications.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,11 @@ function Notification:render()

local paddingX, paddingY, logoSize = 24, 20, 32
local sourceY = if self.props.source then logoSize + 5 else 0
local sourceX = if self.props.source then TextService:GetTextSize(
self.props.source,
15,
Enum.Font.GothamMedium,
Vector2.new(350, 15)
).X + logoSize + 5 else 0
local sourceX = if self.props.source
then TextService:GetTextSize(self.props.source, 15, Enum.Font.GothamMedium, Vector2.new(350, 15)).X + logoSize + 5
else 0
local actionsY = if self.props.actions then 35 else 0
local contentX =
math.max(textBounds.X, buttonsX, sourceX)
+ (if self.props.thirdParty then 0 else logoSize + 3)
+ 2
local contentX = math.max(textBounds.X, buttonsX, sourceX) + (if self.props.thirdParty then 0 else logoSize + 3) + 2

local size = self.binding:map(function(value)
return UDim2.fromOffset(
Expand Down Expand Up @@ -163,25 +157,29 @@ function Notification:render()
}, {
Logo = e("ImageLabel", {
ImageTransparency = transparency,
Image = if self.props.thirdParty then Assets.Images.ThirdPartyPlugin else Assets.Images.PluginButton,
Image = if self.props.thirdParty
then Assets.Images.ThirdPartyPlugin
else Assets.Images.PluginButton,
BackgroundTransparency = 1,
Size = UDim2.new(0, logoSize, 0, logoSize),
Position = UDim2.new(0, 0, 0, 0),
AnchorPoint = Vector2.new(0, 0),
}),
Source = if self.props.source then e("TextLabel", {
Text = self.props.source,
Font = Enum.Font.GothamMedium,
TextSize = 15,
TextColor3 = theme.Notification.InfoColor,
TextTransparency = transparency,
TextXAlignment = Enum.TextXAlignment.Left,
TextTruncate = Enum.TextTruncate.AtEnd,

Size = UDim2.new(1, -logoSize - 5, 0, logoSize),
Position = UDim2.fromOffset(logoSize + 5, 0),
BackgroundTransparency = 1,
}) else nil,
Source = if self.props.source
then e("TextLabel", {
Text = self.props.source,
Font = Enum.Font.GothamMedium,
TextSize = 15,
TextColor3 = theme.Notification.InfoColor,
TextTransparency = transparency,
TextXAlignment = Enum.TextXAlignment.Left,
TextTruncate = Enum.TextTruncate.AtEnd,

Size = UDim2.new(1, -logoSize - 5, 0, logoSize),
Position = UDim2.fromOffset(logoSize + 5, 0),
BackgroundTransparency = 1,
})
else nil,
Message = e("TextLabel", {
Text = self.props.text,
Font = Enum.Font.GothamMedium,
Expand All @@ -192,7 +190,9 @@ function Notification:render()
TextWrapped = true,

Size = UDim2.new(0, textBounds.X, 0, textBounds.Y),
Position = if self.props.thirdParty then UDim2.fromOffset(0, logoSize + 5) else UDim2.fromOffset(logoSize + 3, 0),
Position = if self.props.thirdParty
then UDim2.fromOffset(0, logoSize + 5)
else UDim2.fromOffset(logoSize + 3, 0),
BackgroundTransparency = 1,
}),
Actions = if self.props.actions
Expand Down
7 changes: 5 additions & 2 deletions plugin/src/App/PermissionPopup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ function PermissionPopup:render()
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0, 0),
AutomaticSize = Enum.AutomaticSize.Y,
Text = string.format("A third-party plugin, %s, is asking to use the following parts of the Rojo API. Please grant/deny access.", self.props.name or "[Unknown]"),
Text = string.format(
"A third-party plugin, %s, is asking to use the following parts of the Rojo API. Please grant/deny access.",
self.props.name or "[Unknown]"
),
Font = Enum.Font.GothamMedium,
TextSize = 17,
TextColor3 = theme.Setting.NameColor,
Expand All @@ -97,7 +100,7 @@ function PermissionPopup:render()

ScrollingFrame = e(ScrollingFrame, {
size = self.infoSize:map(function(infoSize)
return UDim2.new(1, 0, 1, -infoSize.Y-44)
return UDim2.new(1, 0, 1, -infoSize.Y - 44)
end),
layoutOrder = 2,
contentSize = self.contentSize,
Expand Down
7 changes: 5 additions & 2 deletions plugin/src/App/StatusPages/Permissions/Listing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ function Listing:render()

Size = self.containerSize:map(function(value)
local textBounds = getTextBounds(
self.props.description, 14, Enum.Font.Gotham, 1.2,
self.props.description,
14,
Enum.Font.Gotham,
1.2,
Vector2.new(value.X - 40, math.huge)
)
return UDim2.new(1, - 40, 0, textBounds.Y)
return UDim2.new(1, -40, 0, textBounds.Y)
end),

LayoutOrder = 2,
Expand Down
11 changes: 8 additions & 3 deletions plugin/src/App/StatusPages/Permissions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local function Navbar(props)
onClick = props.onBack,
}, {
Tip = e(Tooltip.Trigger, {
text = "Back"
text = "Back",
}),
}),

Expand All @@ -55,7 +55,7 @@ local function Navbar(props)
Size = UDim2.new(1, 0, 1, 0),

BackgroundTransparency = 1,
})
}),
})
end)
end
Expand Down Expand Up @@ -118,7 +118,12 @@ function PermissionsPage:render()
),

onClick = function()
self.props.onEdit(self.props.headlessAPI._sourceToPlugin[source], source, meta, self.props.headlessAPI._permissions[source] or {})
self.props.onEdit(
self.props.headlessAPI._sourceToPlugin[source],
source,
meta,
self.props.headlessAPI._permissions[source] or {}
)
end,
})
end
Expand Down
44 changes: 28 additions & 16 deletions plugin/src/App/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,14 @@ function App:addNotification(
end
end

function App:addThirdPartyNotification(source: string, text: string, timeout: number?, actions: { [string]: {text: string, style: string, layoutOrder: number, onClick: (any) -> ()} }?)
function App:addThirdPartyNotification(
source: string,
text: string,
timeout: number?,
actions: {
[string]: { text: string, style: string, layoutOrder: number, onClick: (any) -> () },
}?
)
if not Settings:get("showNotifications") then
return
end
Expand Down Expand Up @@ -409,18 +416,29 @@ function App:releaseSyncLock()
Log.trace("Could not release sync lock because it is owned by {}", lock.Value)
end

function App:requestPermission(plugin: Plugin, source: string, name: string, apis: {string}, initialState: {[string]: boolean?}): {[string]: boolean}
function App:requestPermission(
plugin: Plugin,
source: string,
name: string,
apis: { string },
initialState: { [string]: boolean? }
): { [string]: boolean }
local responseEvent = Instance.new("BindableEvent")

Log.info("The third-party plugin '{}' is requesting permission to use the API!", name)

local unloadProtection = if plugin then plugin.Unloading:Connect(function()
Log.warn("Cancelling API permission request for '{}' because the third-party plugin has been removed.", name)
responseEvent:Fire(initialState)
end) else nil
local unloadProtection = if plugin
then plugin.Unloading:Connect(function()
Log.warn(
"Cancelling API permission request for '{}' because the third-party plugin has been removed.",
name
)
responseEvent:Fire(initialState)
end)
else nil

self:setState(function(state)
state.popups[source .. " Permissions"] = {
state.popups[source .. " Permissions"] = {
name = name,
content = e(PermissionPopup, {
responseEvent = responseEvent,
Expand All @@ -445,7 +463,7 @@ function App:requestPermission(plugin: Plugin, source: string, name: string, api
end

self:setState(function(state)
state.popups[source .. " Permissions"] = nil
state.popups[source .. " Permissions"] = nil
return state
end)

Expand Down Expand Up @@ -716,7 +734,7 @@ function App:render()

local popups = {}
for id, popup in self.state.popups do
popups["Rojo_"..id] = e(StudioPluginGui, {
popups["Rojo_" .. id] = e(StudioPluginGui, {
id = id,
title = popup.name,
active = true,
Expand Down Expand Up @@ -854,13 +872,7 @@ function App:render()
for api in apiMap do
table.insert(apiList, api)
end
local response = self:requestPermission(
plugin,
source,
name,
apiList,
apiMap
)
local response = self:requestPermission(plugin, source, name, apiList, apiMap)
self.headlessAPI:_setPermissions(source, name, response)
end,
}),
Expand Down
Loading

0 comments on commit b8e5fda

Please sign in to comment.