Skip to content

Commit

Permalink
Merge pull request #111 from PlasticSCM/1004694-configure-locks-button
Browse files Browse the repository at this point in the history
Add a Configure Rules button to the View Locks window #139
  • Loading branch information
pablobayarri authored Mar 7, 2024
2 parents 7829ac7 + 2134252 commit 8df28c2
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,7 @@ void FPlasticSourceControlMenu::VisitSupportURLClicked() const

void FPlasticSourceControlMenu::VisitLockRulesURLClicked(const FString InOrganizationName) const
{
const FString OrganizationLockRulesURL = FString::Printf(
TEXT("https://dashboard.unity3d.com/devops/organizations/default/plastic-scm/organizations/%s/lock-rules"),
*InOrganizationName
);
FPlatformProcess::LaunchURL(*OrganizationLockRulesURL, NULL, NULL);
PlasticSourceControlUtils::OpenLockRulesInCloudDashboard(InOrganizationName);
}

void FPlasticSourceControlMenu::OpenDeskoptApp() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ FString FindDesktopApplicationPath()
return DesktopAppPath;
}

void OpenLockRulesInCloudDashboard(const FString& InOrganizationName)
{
const FString OrganizationLockRulesURL = FString::Printf(
TEXT("https://dashboard.unity3d.com/devops/organizations/default/plastic-scm/organizations/%s/lock-rules"),
*InOrganizationName
);
FPlatformProcess::LaunchURL(*OrganizationLockRulesURL, NULL, NULL);
}

// Find the root of the workspace, looking from the provided path and upward in its parent directories.
bool GetWorkspacePath(const FString& InPath, FString& OutWorkspaceRoot)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ FString FindPlasticBinaryPath();
*/
FString FindDesktopApplicationPath();

/**
* Open the Unity Cloud Dashboard on the page to show and manage Lock Rules.
*
* @param InOrganizationName Name of the organization to use, from the server URL
*/
void OpenLockRulesInCloudDashboard(const FString& InOrganizationName);

/**
* Find the root of the Plastic workspace, looking from the GameDir and upward in its parent directories
* @param InPathToGameDir The path to the Game Directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ void SPlasticSourceControlLocksWidget::Construct(const FArguments& InArgs)

CurrentBranchName = FPlasticSourceControlModule::Get().GetProvider().GetBranchName();

const FString OrganizationName = FPlasticSourceControlModule::Get().GetProvider().GetCloudOrganization();

SearchTextFilter = MakeShared<TTextFilter<const FPlasticSourceControlLock&>>(TTextFilter<const FPlasticSourceControlLock&>::FItemToStringArray::CreateSP(this, &SPlasticSourceControlLocksWidget::PopulateItemSearchStrings));
SearchTextFilter->OnChanged().AddSP(this, &SPlasticSourceControlLocksWidget::OnRefreshUI);

Expand All @@ -63,25 +65,77 @@ void SPlasticSourceControlLocksWidget::Construct(const FArguments& InArgs)
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
.AutoWidth()
.FillWidth(1.0f)
[
CreateToolBar()
]
+SHorizontalBox::Slot()
.MaxWidth(10.0f)
[
SNew(SSpacer)
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Center)
.AutoWidth()
[
CreateToolBar()
]
+SHorizontalBox::Slot()
.MaxWidth(10.0f)
[
SNew(SSpacer)
]
+SHorizontalBox::Slot()
.VAlign(VAlign_Center)
.MaxWidth(300.0f)
[
SAssignNew(FileSearchBox, SSearchBox)
.HintText(LOCTEXT("SearchLocks", "Search Locks"))
.ToolTipText(LOCTEXT("PlasticLocksSearch_Tooltip", "Filter the list of locks by keyword."))
.OnTextChanged(this, &SPlasticSourceControlLocksWidget::OnSearchTextChanged)
]
]
+SHorizontalBox::Slot()
.HAlign(HAlign_Right)
.VAlign(VAlign_Center)
.MaxWidth(300.0f)
.AutoWidth()
[
SAssignNew(FileSearchBox, SSearchBox)
.HintText(LOCTEXT("SearchLocks", "Search Locks"))
.ToolTipText(LOCTEXT("PlasticLocksSearch_Tooltip", "Filter the list of locks by keyword."))
.OnTextChanged(this, &SPlasticSourceControlLocksWidget::OnSearchTextChanged)
// Button to Configure Lock Rules in the cloud (only enabled for a cloud repository)
SNew(SButton)
.ContentPadding(FMargin(6.0f, 0.0f))
.IsEnabled(!OrganizationName.IsEmpty())
.ToolTipText(OrganizationName.IsEmpty() ?
LOCTEXT("PlasticLockRulesURLTooltipDisabled", "Web link to the Unity Dashboard disabled. Only available for Cloud repositories.") :
LOCTEXT("PlasticLockRulesURLTooltipEnabled", "Navigate to lock rules configuration page in the Unity Dashboard."))
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
.ButtonStyle(FAppStyle::Get(), "SimpleButton")
#else
.ButtonStyle(FEditorStyle::Get(), "SimpleButton")
#endif
.OnClicked(this, &SPlasticSourceControlLocksWidget::OnConfigureLockRulesClicked, OrganizationName)
[
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
.VAlign(VAlign_Center)
.HAlign(HAlign_Center)
[
SNew(SImage)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
.Image(FAppStyle::GetBrush("PropertyWindow.Locked"))
#else
.Image(FEditorStyle::GetBrush("PropertyWindow.Locked"))
#endif
]
+SHorizontalBox::Slot()
.AutoWidth()
.VAlign(VAlign_Center)
.Padding(5.0f, 0.0f, 0.0f, 0.0f)
[
SNew(STextBlock)
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
.TextStyle(&FAppStyle::Get().GetWidgetStyle<FTextBlockStyle>("NormalText"))
#else
.TextStyle(&FEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>("NormalText"))
#endif
.Text(LOCTEXT("ConfigureLockRules", "Configure rules"))
]
]
]
]
]
Expand Down Expand Up @@ -591,6 +645,12 @@ TSharedPtr<SWidget> SPlasticSourceControlLocksWidget::OnOpenContextMenu()
return ToolMenus->GenerateWidget(Menu);
}

FReply SPlasticSourceControlLocksWidget::OnConfigureLockRulesClicked(const FString InOrganizationName)
{
PlasticSourceControlUtils::OpenLockRulesInCloudDashboard(InOrganizationName);
return FReply::Handled();
}

void SPlasticSourceControlLocksWidget::OnReleaseLocksClicked(TArray<FPlasticSourceControlLockRef> InSelectedLocks)
{
ExecuteUnlock(MoveTemp(InSelectedLocks), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class SPlasticSourceControlLocksWidget : public SCompoundWidget

TSharedPtr<SWidget> OnOpenContextMenu();

FReply OnConfigureLockRulesClicked(const FString InOrganizationName);

void OnReleaseLocksClicked(TArray<FPlasticSourceControlLockRef> InSelectedLocks);
void OnRemoveLocksClicked(TArray<FPlasticSourceControlLockRef> InSelectedLocks);
void ExecuteUnlock(TArray<FPlasticSourceControlLockRef>&& InSelectedLocks, const bool bInRemove);
Expand Down

0 comments on commit 8df28c2

Please sign in to comment.