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

View rich diffs for Source property changes #748

Merged
merged 35 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dbe4188
Add highlighter to packages
boatbomber Jul 1, 2023
88c55c5
Add highlighter submodule correctly
boatbomber Jul 1, 2023
603749c
Support X scrolling
boatbomber Jul 1, 2023
2dded35
Add initial diff component
boatbomber Jul 1, 2023
66af426
Add trace logs
boatbomber Jul 2, 2023
f592c88
Add special case for showing Source changes
boatbomber Jul 2, 2023
49232c6
Implement diff view in confirming
boatbomber Jul 2, 2023
6938fe3
Improve diff readability by ignoring whitespace changes
boatbomber Jul 2, 2023
4554141
Move code labels to reusable component and reduce wasted diff computes
boatbomber Jul 2, 2023
25ef038
Merge branch 'master' of https://github.com/boatbomber/rojo into stri…
boatbomber Jul 9, 2023
7eb72f3
Include warning support for special cased source and make the button …
boatbomber Jul 10, 2023
0ec8170
Fix tooltips in the diff viewer widget
boatbomber Jul 10, 2023
80321c7
Merge branch 'master' of https://github.com/boatbomber/rojo into stri…
boatbomber Jul 14, 2023
ce6b698
Remove old visibility stuff
boatbomber Jul 14, 2023
f309275
Merge branch 'master' of https://github.com/boatbomber/rojo into stri…
boatbomber Jul 17, 2023
28abe39
Merge branch 'master' of https://github.com/boatbomber/rojo into stri…
boatbomber Jul 23, 2023
340c0f7
Use latest Highlighter
boatbomber Jul 25, 2023
93c102c
Remove old unused code
boatbomber Jul 25, 2023
d206c9a
Use Highlighter to get background color
boatbomber Jul 25, 2023
a93971c
Don't waste compute on diff cleanup since we aren't really using the …
boatbomber Jul 25, 2023
c8d3ee7
Add diff view to Connected patch view as well
boatbomber Jul 25, 2023
a1869ee
Fix studio not rendering widgets
boatbomber Jul 25, 2023
b1cb2ad
Add clarifying comment
boatbomber Jul 25, 2023
92cc949
Write a stripped down Luau port of DMP to reduce bloat
boatbomber Jul 25, 2023
c1bab28
Remove unhelpful trace
boatbomber Jul 26, 2023
ddf4689
Stylua formatting
boatbomber Jul 26, 2023
8ddc583
Unused var
boatbomber Jul 26, 2023
e7fb8c6
Close diff viewer when patch is replaced
boatbomber Jul 26, 2023
ab818cb
Add to changelog
boatbomber Jul 26, 2023
7095260
Merge branch 'master' into string-diff-viewer
boatbomber Jul 26, 2023
a048a9c
Remove unused old initEnabled prop
boatbomber Jul 26, 2023
443e810
Improve scriptBackground behavior and clarity
boatbomber Jul 26, 2023
dbba28f
Fix imagecolor
boatbomber Jul 26, 2023
208526e
Only update scriptBackground when truly needed
boatbomber Jul 26, 2023
bef3f05
Remove unused var
boatbomber Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "plugin/Packages/TestEZ"]
path = plugin/Packages/TestEZ
url = https://github.com/roblox/testez.git
[submodule "plugin/Packages/Highlighter"]
path = plugin/Packages/Highlighter
url = https://github.com/boatbomber/highlighter.git
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Add `plugin` flag to the `build` command that outputs to the local plugins folder ([#735])
* Added better support for `Font` properties ([#731])
* Add new plugin template to the `init` command ([#738])
* Added rich Source diffs in patch visualizer ([#748])

[#668]: https://github.com/rojo-rbx/rojo/pull/668
[#674]: https://github.com/rojo-rbx/rojo/pull/674
Expand All @@ -40,6 +41,7 @@
[#735]: https://github.com/rojo-rbx/rojo/pull/735
[#731]: https://github.com/rojo-rbx/rojo/pull/731
[#738]: https://github.com/rojo-rbx/rojo/pull/738
[#748]: https://github.com/rojo-rbx/rojo/pull/748

## [7.3.0] - April 22, 2023
* Added `$attributes` to project format. ([#574])
Expand Down
1 change: 1 addition & 0 deletions plugin/Packages/Highlighter
Submodule Highlighter added at 09263e
62 changes: 62 additions & 0 deletions plugin/src/App/Components/CodeLabel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
local Rojo = script:FindFirstAncestor("Rojo")
local Plugin = Rojo.Plugin
boatbomber marked this conversation as resolved.
Show resolved Hide resolved
local Packages = Rojo.Packages

local Roact = require(Packages.Roact)
local Highlighter = require(Packages.Highlighter)
Highlighter.matchStudioSettings()

local e = Roact.createElement

local CodeLabel = Roact.PureComponent:extend("CodeLabel")

function CodeLabel:init()
self.labelRef = Roact.createRef()
self.highlightsRef = Roact.createRef()
end

function CodeLabel:didMount()
Highlighter.highlight({
textObject = self.labelRef:getValue(),
})
self:updateHighlights()
end

function CodeLabel:didUpdate()
self:updateHighlights()
end

function CodeLabel:updateHighlights()
local highlights = self.highlightsRef:getValue()
if not highlights then
return
end

for _, lineLabel in highlights:GetChildren() do
local lineNum = tonumber(string.match(lineLabel.Name, "%d+") or "0")
lineLabel.BackgroundColor3 = self.props.lineBackground
lineLabel.BorderSizePixel = 0
lineLabel.BackgroundTransparency = if self.props.markedLines[lineNum] then 0.25 else 1
end
end

function CodeLabel:render()
return e("TextLabel", {
Size = self.props.size,
Position = self.props.position,
Text = self.props.text,
BackgroundTransparency = 1,
Font = Enum.Font.RobotoMono,
TextSize = 16,
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
TextColor3 = Color3.fromRGB(255, 255, 255),
[Roact.Ref] = self.labelRef,
}, {
SyntaxHighlights = e("Folder", {
[Roact.Ref] = self.highlightsRef,
}),
})
end

return CodeLabel
85 changes: 85 additions & 0 deletions plugin/src/App/Components/PatchVisualizer/ChangeList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ local Packages = Rojo.Packages

local Roact = require(Packages.Roact)

local Assets = require(Plugin.Assets)
local Theme = require(Plugin.App.Theme)
local ScrollingFrame = require(Plugin.App.Components.ScrollingFrame)
local BorderedContainer = require(Plugin.App.Components.BorderedContainer)
local DisplayValue = require(script.Parent.DisplayValue)

local EMPTY_TABLE = {}
Expand Down Expand Up @@ -93,6 +95,89 @@ function ChangeList:render()
local metadata = values[4] or EMPTY_TABLE
local isWarning = metadata.isWarning

-- Special case for .Source updates
-- because we want to display a syntax highlighted diff for better UX
if self.props.showSourceDiff and tostring(values[1]) == "Source" then
rows[row] = e("Frame", {
Size = UDim2.new(1, 0, 0, 30),
BackgroundTransparency = row % 2 ~= 0 and rowTransparency or 1,
BackgroundColor3 = theme.Diff.Row,
BorderSizePixel = 0,
LayoutOrder = row,
}, {
Padding = e("UIPadding", pad),
Layout = e("UIListLayout", {
FillDirection = Enum.FillDirection.Horizontal,
SortOrder = Enum.SortOrder.LayoutOrder,
HorizontalAlignment = Enum.HorizontalAlignment.Left,
VerticalAlignment = Enum.VerticalAlignment.Center,
}),
A = e("TextLabel", {
Text = (if isWarning then "⚠ " else "") .. tostring(values[1]),
BackgroundTransparency = 1,
Font = Enum.Font.GothamMedium,
TextSize = 14,
TextColor3 = if isWarning then theme.Diff.Warning else theme.Settings.Setting.DescriptionColor,
TextXAlignment = Enum.TextXAlignment.Left,
TextTransparency = props.transparency,
TextTruncate = Enum.TextTruncate.AtEnd,
Size = UDim2.new(0.3, 0, 1, 0),
LayoutOrder = 1,
}),
Button = e("TextButton", {
Text = "",
Size = UDim2.new(0.7, 0, 1, -4),
LayoutOrder = 2,
BackgroundTransparency = 1,
[Roact.Event.Activated] = function()
if props.showSourceDiff then
props.showSourceDiff(tostring(values[2]), tostring(values[3]))
end
end,
}, {
e(BorderedContainer, {
size = UDim2.new(1, 0, 1, 0),
transparency = self.props.transparency:map(function(t)
return 0.5 + (0.5 * t)
end),
}, {
Layout = e("UIListLayout", {
FillDirection = Enum.FillDirection.Horizontal,
SortOrder = Enum.SortOrder.LayoutOrder,
HorizontalAlignment = Enum.HorizontalAlignment.Center,
VerticalAlignment = Enum.VerticalAlignment.Center,
Padding = UDim.new(0, 5),
}),
Label = e("TextLabel", {
Text = "View Diff",
BackgroundTransparency = 1,
Font = Enum.Font.GothamMedium,
TextSize = 14,
TextColor3 = theme.Settings.Setting.DescriptionColor,
TextXAlignment = Enum.TextXAlignment.Left,
TextTransparency = props.transparency,
TextTruncate = Enum.TextTruncate.AtEnd,
Size = UDim2.new(0, 65, 1, 0),
LayoutOrder = 1,
}),
Icon = e("ImageLabel", {
Image = Assets.Images.Icons.Expand,
ImageColor3 = theme.Settings.Setting.DescriptionColor,
ImageTransparency = self.props.transparency,

Size = UDim2.new(0, 16, 0, 16),
Position = UDim2.new(0.5, 0, 0.5, 0),
AnchorPoint = Vector2.new(0.5, 0.5),

BackgroundTransparency = 1,
LayoutOrder = 2,
}),
}),
}),
})
continue
end

rows[row] = e("Frame", {
Size = UDim2.new(1, 0, 0, 30),
BackgroundTransparency = row % 2 ~= 0 and rowTransparency or 1,
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/App/Components/PatchVisualizer/DomLabel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function Expansion:render()
ChangeList = e(ChangeList, {
changes = props.changeList,
transparency = props.transparency,
showSourceDiff = props.showSourceDiff,
}),
})
end
Expand Down Expand Up @@ -170,6 +171,7 @@ function DomLabel:render()
indent = indent,
transparency = props.transparency,
changeList = props.changeList,
showSourceDiff = props.showSourceDiff,
})
else nil,
DiffIcon = if props.patchType
Expand Down
1 change: 1 addition & 0 deletions plugin/src/App/Components/PatchVisualizer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function PatchVisualizer:render()
changeList = node.changeList,
depth = depth,
transparency = self.props.transparency,
showSourceDiff = self.props.showSourceDiff,
})
)
end
Expand Down
13 changes: 10 additions & 3 deletions plugin/src/App/Components/ScrollingFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,26 @@ local function ScrollingFrame(props)
BottomImage = Assets.Images.ScrollBar.Bottom,

ElasticBehavior = Enum.ElasticBehavior.Always,
ScrollingDirection = Enum.ScrollingDirection.Y,
ScrollingDirection = props.scrollingDirection or Enum.ScrollingDirection.Y,

Size = props.size,
Position = props.position,
AnchorPoint = props.anchorPoint,
CanvasSize = props.contentSize:map(function(value)
return UDim2.new(0, 0, 0, value.Y)
return UDim2.new(
0,
if (props.scrollingDirection and props.scrollingDirection ~= Enum.ScrollingDirection.Y)
then value.X
else 0,
0,
value.Y
)
end),

BorderSizePixel = 0,
BackgroundTransparency = 1,

[Roact.Change.AbsoluteSize] = props[Roact.Change.AbsoluteSize]
[Roact.Change.AbsoluteSize] = props[Roact.Change.AbsoluteSize],
}, props[Roact.Children])
end)
end
Expand Down
Loading
Loading