HistoryEntryComponent.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using JetBrains.Annotations;
  2. using Unity.Cloud.Collaborate.Assets;
  3. using Unity.Cloud.Collaborate.UserInterface;
  4. using UnityEditor;
  5. using UnityEngine.UIElements;
  6. using UnityEngine;
  7. namespace Unity.Cloud.Collaborate.Components
  8. {
  9. internal class HistoryEntryComponent : VisualElement
  10. {
  11. public const string UssClassName = "history-entry-component";
  12. public const string ProfileInitialUssClassName = UssClassName + "__profile-initial";
  13. public const string AuthorNameUssClassName = UssClassName + "__author-name";
  14. public const string TimestampUssClassName = UssClassName + "__timestamp";
  15. public const string RevisionIdUssClassName = UssClassName + "__revision-id";
  16. public const string CommitMessageUssClassName = UssClassName + "__commit-message";
  17. public const string ChangedFilesCountUssClassName = UssClassName + "__changed-files-count";
  18. public const string ChangedFilesUssClassName = UssClassName + "__changed-files";
  19. public const string RollbackButtonUssClassName = UssClassName + "__goto-button";
  20. public const string ShowFilesButtonUssClassName = UssClassName + "__files-button";
  21. public const string BuildStatusUssClassName = UssClassName + "__cloud-build-status";
  22. static readonly string k_LayoutPath = $"{CollaborateWindow.LayoutPath}/{nameof(HistoryEntryComponent)}.uxml";
  23. static readonly string k_StylePath = $"{CollaborateWindow.StylePath}/{nameof(HistoryEntryComponent)}.uss";
  24. public readonly Label profileInitial;
  25. public readonly Label authorName;
  26. public readonly Label timestamp;
  27. public readonly Label revisionId;
  28. public readonly Label commitMessage;
  29. public readonly Button gotoButton;
  30. public readonly Button showFilesButton;
  31. public readonly Label cloudStatusText;
  32. public readonly Label changedFilesCount;
  33. public readonly AdapterListView changedFiles;
  34. public HistoryEntryComponent()
  35. {
  36. // Get the layout
  37. AddToClassList(UssClassName);
  38. AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(k_LayoutPath).CloneTree(this);
  39. styleSheets.Add(AssetDatabase.LoadAssetAtPath<StyleSheet>(k_StylePath));
  40. // Initialise fields
  41. profileInitial = this.Q<Label>(className: ProfileInitialUssClassName);
  42. authorName = this.Q<Label>(className: AuthorNameUssClassName);
  43. timestamp = this.Q<Label>(className: TimestampUssClassName);
  44. revisionId = this.Q<Label>(className: RevisionIdUssClassName);
  45. commitMessage = this.Q<Label>(className: CommitMessageUssClassName);
  46. changedFilesCount = this.Q<Label>(className: ChangedFilesCountUssClassName);
  47. changedFiles = this.Q<AdapterListView>(className: ChangedFilesUssClassName);
  48. gotoButton = this.Q<Button>(className: RollbackButtonUssClassName);
  49. showFilesButton = this.Q<Button>(className: ShowFilesButtonUssClassName);
  50. cloudStatusText = this.Q<Label>(className: BuildStatusUssClassName);
  51. changedFiles.SelectionType = SelectionType.None;
  52. gotoButton.text = StringAssets.rollback;
  53. }
  54. [UsedImplicitly]
  55. public new class UxmlFactory : UxmlFactory<HistoryEntryComponent> { }
  56. }
  57. }