Exemple #1
0
        protected override bool IsVisible(IPackageVersion version)
        {
            var installed     = version?.package.versions.installed;
            var targetVersion = GetTargetVersion(version);

            return(installed?.HasTag(PackageTag.VersionLocked) == false &&
                   targetVersion?.HasTag(PackageTag.Installable) == true &&
                   installed != targetVersion &&
                   !version.IsRequestedButOverriddenVersion &&
                   !version.HasTag(PackageTag.Local) &&
                   m_PageManager.GetVisualState(version.package)?.isLocked != true);
        }
        protected override bool IsVisible(IPackageVersion version)
        {
            var versionsList  = version?.package?.versions;
            var installed     = versionsList?.installed;
            var targetVersion = versionsList?.GetUpdateTarget(version);

            return(installed?.HasTag(PackageTag.VersionLocked) == false &&
                   targetVersion?.HasTag(PackageTag.Installable) == true &&
                   installed != targetVersion &&
                   !version.IsRequestedButOverriddenVersion &&
                   (version.isDirectDependency || version != installed) &&
                   !version.HasTag(PackageTag.Local) &&
                   m_PageManager.GetVisualState(version.package)?.isLocked != true);
        }
        public void OnFilterTabChanged(PackageFilterTab filterTab)
        {
            // Check if groups have changed only for InProject tab
            if (filterTab == PackageFilterTab.InProject && m_PageManager.IsInitialFetchingDone(PackageFilterTab.InProject))
            {
                var needGroupsReordering = false;
                var currentPackageItems  = packageItems.ToList();
                foreach (var packageItem in currentPackageItems)
                {
                    // Check if group has changed
                    var package   = packageItem.package;
                    var groupName = m_PageManager.GetCurrentPage().GetGroupName(package);
                    if (packageItem.packageGroup.name != groupName)
                    {
                        var oldGroup = GetOrCreateGroup(packageItem.packageGroup.name);
                        var newGroup = GetOrCreateGroup(groupName);

                        var state = m_PageManager.GetVisualState(package);
                        if (state != null)
                        {
                            state.groupName = groupName;
                        }

                        // Move PackageItem from old group to new group
                        oldGroup.RemovePackageItem(packageItem);
                        newGroup.AddPackageItem(packageItem);
                        needGroupsReordering = true;

                        if (!oldGroup.packageItems.Any())
                        {
                            m_ItemsList.Remove(oldGroup);
                        }
                    }
                }

                if (needGroupsReordering)
                {
                    ReorderGroups();
                }
            }
        }
Exemple #4
0
        private void RefreshLockIcons(IEnumerable <IPackageVersion> featureSets, VisualState visualState = null)
        {
            var showLockedIcon = featureSets?.Any() == true;

            if (showLockedIcon)
            {
                visualState = visualState ?? m_PageManager.GetVisualState(m_Package);
                if (visualState?.isLocked == true)
                {
                    lockedIcon.RemoveFromClassList("unlocked");
                    lockedIcon.AddToClassList("locked");
                    lockedIcon.tooltip = L10n.Tr("This package is locked because it's part of a feature set. Click unlock button to be able to make changes");
                }
                else
                {
                    lockedIcon.AddToClassList("unlocked");
                    lockedIcon.RemoveFromClassList("locked");
                    lockedIcon.tooltip = L10n.Tr("This package is unlocked. You can now change its version.");
                }
            }
            UIUtils.SetElementDisplay(lockedIcon, showLockedIcon);
        }
Exemple #5
0
        public override void Refresh(IPackageVersion version)
        {
            m_Version = version;
            if (m_Version?.uniqueId != m_PackageManagerPrefs.packageDisplayedInVersionHistoryTab)
            {
                m_PackageManagerPrefs.ClearExpandedVersionHistoryItems();
                m_PackageManagerPrefs.packageDisplayedInVersionHistoryTab = m_Version?.uniqueId;
            }

            foreach (var historyItem in m_VersionHistoryList.Children().OfType <PackageDetailsVersionHistoryItem>())
            {
                historyItem.StopSpinner();
            }
            m_VersionHistoryList.Clear();

            if (m_Version?.package?.versions == null)
            {
                UIUtils.SetElementDisplay(m_Container, false);
                return;
            }

            var seeAllVersions = m_PageManager.GetVisualState(m_Version.package)?.seeAllVersions ?? false;
            var keyVersions    = m_Version.package.versions.key.ToList();
            var allVersions    = m_Version.package.versions.ToList();

            var versions = seeAllVersions ? allVersions : keyVersions;

            versions.Reverse();

            var seeVersionsToolbar = !seeAllVersions && allVersions.Count > keyVersions.Count && (m_Version.package.Is(PackageType.ScopedRegistry) || m_SettingsProxy.seeAllPackageVersions || m_Version.package.versions.installed?.HasTag(PackageTag.Experimental) == true);

            UIUtils.SetElementDisplay(m_VersionsToolbar, seeVersionsToolbar);

            var latestVersion           = m_Version.package?.versions.latest;
            var primaryVersion          = m_Version.package?.versions.primary;
            var multipleVersionsVisible = versions.Count > 1;

            foreach (var v in versions)
            {
                PackageToolBarRegularButton button;
                if (primaryVersion?.isInstalled ?? false)
                {
                    if (v == primaryVersion)
                    {
                        button = new PackageRemoveButton(m_ApplicationProxy, m_PackageManagerPrefs, m_PackageDatabase, m_PageManager);
                        button.SetGlobalDisableConditions(m_DisableIfCompiling, m_DisableIfInstallOrUninstallInProgress);
                    }
                    else
                    {
                        button = new PackageUpdateButton(m_ApplicationProxy, m_PackageDatabase, m_PageManager, false);
                        button.SetGlobalDisableConditions(m_DisableIfCompiling, m_DisableIfInstallOrUninstallInProgress);
                    }
                }
                else
                {
                    button = new PackageAddButton(m_ApplicationProxy, m_PackageDatabase);
                    button.SetGlobalDisableConditions(m_DisableIfCompiling, m_DisableIfInstallOrUninstallInProgress);
                }

                var isExpanded         = m_PackageManagerPrefs.IsVersionHistoryItemExpanded(v.uniqueId);
                var isLatest           = v == latestVersion;
                var versionHistoryItem = new PackageDetailsVersionHistoryItem(m_ResourceLoader,
                                                                              m_PackageDatabase,
                                                                              m_UpmCache,
                                                                              m_ApplicationProxy,
                                                                              m_IOProxy,
                                                                              v,
                                                                              multipleVersionsVisible,
                                                                              isLatest,
                                                                              isExpanded,
                                                                              button);
                versionHistoryItem.onToggleChanged += expanded => m_PackageManagerPrefs.SetVersionHistoryItemExpanded(versionHistoryItem.version?.uniqueId, expanded);

                m_VersionHistoryList.Add(versionHistoryItem);
            }

            UIUtils.SetElementDisplay(m_Container, true);
        }
 protected override bool IsVisible(IPackageVersion version) => m_PageManager.GetVisualState(version?.package)?.isLocked == true;