-
Notifications
You must be signed in to change notification settings - Fork 104
feat: enable Team Participant controls to be used separately #7194
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
26 commits
Select commit
Hold shift + click to select a range
a90331f
add controls
Eetwalt 995b8d6
fix building
Eetwalt aa884f9
debug logs
Eetwalt 6b9af45
more debugs
Eetwalt 620c6b2
use table
Eetwalt e9e336e
test compact mode
Eetwalt 77b522d
add player info button
Eetwalt 25bbfc6
fix link
Eetwalt eda0a32
external link
Eetwalt cb9b6fd
fix icon and style
Eetwalt 90cb7ee
make player info button optional
Eetwalt 5d5a6d7
syntax
Eetwalt 19e6435
fix empty check
Eetwalt 3c1acc1
fix rendering
Eetwalt a972e4c
clean up
Eetwalt e201807
set scope correctly
Eetwalt cc3ca07
every group own controls if external controls not set
Eetwalt 87be20d
fix control rendering from card groups
Eetwalt 85832da
alternative
Eetwalt 15d218d
get args
Eetwalt a7fb740
move link creation inside conditional its used under
Eetwalt abc76b4
rename prop and boolean early
Eetwalt 5dce637
remove the redundant default
Eetwalt 1e1211a
clean up controls
Eetwalt 89b35ba
constructor instead of fromTemplate
Eetwalt 4ab2304
pass the prop
Eetwalt 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
Some comments aren't visible on the classic Files Changed page.
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
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
102 changes: 102 additions & 0 deletions
102
lua/wikis/commons/Widget/Participants/Team/ParticipantControls.lua
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,102 @@ | ||
| --- | ||
| -- @Liquipedia | ||
| -- page=Module:Widget/Participants/Team/ParticipantControls | ||
| -- | ||
| -- Please see https://github.com/Liquipedia/Lua-Modules to contribute | ||
| -- | ||
|
|
||
| local Lua = require('Module:Lua') | ||
|
|
||
| local Class = Lua.import('Module:Class') | ||
| local Logic = Lua.import('Module:Logic') | ||
| local PageVariableNamespace = Lua.import('Module:PageVariableNamespace') | ||
|
|
||
| local Widget = Lua.import('Module:Widget') | ||
| local AnalyticsWidget = Lua.import('Module:Widget/Analytics') | ||
| local Button = Lua.import('Module:Widget/Basic/Button') | ||
| local HtmlWidgets = Lua.import('Module:Widget/Html/All') | ||
| local Div = HtmlWidgets.Div | ||
| local Icon = Lua.import('Module:Widget/Image/Icon/Fontawesome') | ||
| local Switch = Lua.import('Module:Widget/Switch') | ||
| local WidgetUtil = Lua.import('Module:Widget/Util') | ||
|
|
||
| local teamParticipantsVars = PageVariableNamespace('TeamParticipants') | ||
|
|
||
| ---@class ParticipantsTeamParticipantControlsProps | ||
| ---@field showPlayerInfo boolean | ||
| ---@field externalUsage boolean | ||
|
|
||
| ---@class ParticipantsTeamParticipantControls: Widget | ||
| ---@operator call(ParticipantsTeamParticipantControlsProps): ParticipantsTeamParticipantControls | ||
| ---@field props ParticipantsTeamParticipantControlsProps | ||
| local ParticipantsTeamParticipantControls = Class.new(Widget, function(self, props) | ||
| if Logic.readBool(props.externalUsage) then | ||
| teamParticipantsVars:set('externalControlsRendered', 'true') | ||
| end | ||
| self.props.showPlayerInfo = Logic.readBool(self.props.showPlayerInfo or self.props.showplayerinfo) | ||
| end) | ||
|
|
||
| ParticipantsTeamParticipantControls.defaultProps = { | ||
| showPlayerInfo = false, | ||
| externalUsage = false, | ||
| } | ||
|
|
||
| ---@return Widget? | ||
| function ParticipantsTeamParticipantControls:_buildPlayerInfoButton() | ||
| if not Logic.readBool(self.props.showPlayerInfo) then | ||
| return nil | ||
| end | ||
|
|
||
| local pageName = mw.title.getCurrentTitle().fullText | ||
| local link = tostring(mw.uri.fullUrl('Special:RunQuery/Tournament_player_information', { | ||
| pfRunQueryFormName = 'Tournament player information', | ||
| ['TPI[page]'] = pageName, | ||
| wpRunQuery = 'Run query' | ||
| })) | ||
|
|
||
| return Button{ | ||
| title = 'Click for additional player information', | ||
| variant = 'secondary', | ||
| size = 'sm', | ||
| linktype = 'external', | ||
| link = link, | ||
| children = { Icon{iconName = 'internal_link'}, 'Player Info' } | ||
| } | ||
| end | ||
|
|
||
| ---@return Widget? | ||
| function ParticipantsTeamParticipantControls:render() | ||
| local children = WidgetUtil.collect( | ||
| self:_buildPlayerInfoButton(), | ||
| AnalyticsWidget{ | ||
| analyticsName = 'ParticipantsShowRostersSwitch', | ||
| analyticsProperties = { | ||
| ['track-value-as'] = 'participants show rosters', | ||
| }, | ||
| children = Switch{ | ||
| label = 'Show rosters', | ||
| switchGroup = 'team-cards-show-rosters', | ||
| defaultActive = false, | ||
| collapsibleSelector = '.team-participant-card', | ||
| }, | ||
| }, | ||
| AnalyticsWidget{ | ||
| analyticsName = 'ParticipantsCompactSwitch', | ||
| analyticsProperties = { | ||
| ['track-value-as'] = 'participants compact', | ||
| }, | ||
| children = Switch{ | ||
| label = 'Compact view', | ||
| switchGroup = 'team-cards-compact', | ||
| defaultActive = true, | ||
| }, | ||
| } | ||
| ) | ||
|
|
||
| return Div{ | ||
| classes = { 'team-participant__controls' }, | ||
| children = children | ||
| } | ||
| end | ||
|
|
||
| return ParticipantsTeamParticipantControls |
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
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.