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

User connected to a cloud server can open the Dashboard #90

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions Source/PlasticSourceControl/Private/PlasticSourceControlMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,20 @@ void FPlasticSourceControlMenu::VisitSupportURLClicked() const
}
}

void FPlasticSourceControlMenu::VisitLockRulesURLClicked(const FString OrganizationName) const
SRombautsU marked this conversation as resolved.
Show resolved Hide resolved
{
// Grab the URL from the uplugin file
const TSharedPtr<IPlugin> Plugin = IPluginManager::Get().FindPlugin(TEXT("PlasticSourceControl"));
SRombautsU marked this conversation as resolved.
Show resolved Hide resolved
if (Plugin.IsValid())
{
const FText organizationLockRulesURL = FText::Format(
FText::FromString("https://dashboard.unity3d.com/devops/organizations/default/plastic-scm/organizations/{0}/lock-rules"),
FText::FromString(OrganizationName)
);
FPlatformProcess::LaunchURL(*organizationLockRulesURL.ToString(), NULL, NULL);
}
}

// Display an ongoing notification during the whole operation
void FPlasticSourceControlMenu::DisplayInProgressNotification(const FText& InOperationInProgressString)
{
Expand Down Expand Up @@ -629,6 +643,33 @@ void FPlasticSourceControlMenu::AddMenuExtension(FToolMenuSection& Menu)
FCanExecuteAction()
)
);

FPlasticSourceControlProvider& Provider = FPlasticSourceControlModule::Get().GetProvider();
const FString& serverUrl = Provider.GetServerUrl();

if (serverUrl.Contains("@cloud"))
SRombautsU marked this conversation as resolved.
Show resolved Hide resolved
{
const FString& organizationName = serverUrl.Left(serverUrl.Find("@cloud"));

Menu.AddMenuEntry(
#if ENGINE_MAJOR_VERSION == 5
"PlasticLockRulesURL",
#endif
LOCTEXT("PlasticLockRulesURL", "Configure Lock Rules"),
LOCTEXT("PlasticLockRulesURLTooltip", "Navigate to lock rules configuration page in the Unity Dashboard."),
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 1
FSlateIcon(FAppStyle::GetAppStyleSetName(), "PropertyWindow.Locked"),
#elif ENGINE_MAJOR_VERSION == 5
FSlateIcon(FEditorStyle::GetStyleSetName(), "PropertyWindow.Locked"),
#elif ENGINE_MAJOR_VERSION == 4
FSlateIcon(FEditorStyle::GetStyleSetName(), "PropertyWindow.Locked"),
SRombautsU marked this conversation as resolved.
Show resolved Hide resolved
#endif
FUIAction(
FExecuteAction::CreateRaw(this, &FPlasticSourceControlMenu::VisitLockRulesURLClicked, organizationName),
FCanExecuteAction()
)
);
}
}

#if ENGINE_MAJOR_VERSION == 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class FPlasticSourceControlMenu
void ShowSourceControlPlasticScmProjectSettings() const;
void VisitDocsURLClicked() const;
void VisitSupportURLClicked() const;
void VisitLockRulesURLClicked(const FString OrganizationName) const;

private:
bool IsSourceControlConnected() const;
Expand Down