@knime/hub-features 1.12.6 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @knime/hub-features
2
2
 
3
+ ## 1.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d04922e: display version limit info in ManageVersions side drawer
8
+
3
9
  ## 1.12.6
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/hub-features",
3
- "version": "1.12.6",
3
+ "version": "1.13.0",
4
4
  "description": "Vue components & composables for shared hub features",
5
5
  "homepage": "https://knime.github.io/webapps-common/",
6
6
  "license": "GPL 3 and Additional Permissions according to Sec. 7 (SEE the file LICENSE)",
@@ -15,6 +15,7 @@ const props = defineProps<{
15
15
  hasEditCapability: boolean;
16
16
  hasPreviousVersion: boolean;
17
17
  currentStateSavepoint: ItemSavepoint & WithAvatar & WithLabels;
18
+ isVersionLimitExceeded?: boolean;
18
19
  }>();
19
20
 
20
21
  const emit = defineEmits<{
@@ -66,7 +67,7 @@ const onMenuItemClick = (_: Event, item: (typeof menuItems.value)[number]) => {
66
67
  </div>
67
68
  <div class="right">
68
69
  <Button
69
- v-if="hasEditCapability"
70
+ v-if="hasEditCapability && !isVersionLimitExceeded"
70
71
  with-border
71
72
  compact
72
73
  class="create-button"
@@ -8,10 +8,12 @@ import HistoryIcon from "@knime/styles/img/icons/history.svg";
8
8
 
9
9
  import CurrentState from "./CurrentState.vue";
10
10
  import VersionHistory from "./VersionHistory.vue";
11
+ import VersionLimitInfo from "./VersionLimitInfo.vue";
11
12
  import { CURRENT_STATE_VERSION } from "./constants";
12
13
  import type {
13
14
  ItemSavepoint,
14
15
  NamedItemVersion,
16
+ VersionLimit,
15
17
  WithAvatar,
16
18
  WithLabels,
17
19
  } from "./types";
@@ -25,6 +27,8 @@ type ManageVersionsProps = {
25
27
  hasLoadedAllVersions: boolean;
26
28
  hasAdminRights: boolean;
27
29
  hasEditCapability: boolean;
30
+ versionLimit?: VersionLimit;
31
+ upgradeUrl?: string;
28
32
  };
29
33
 
30
34
  defineProps<ManageVersionsProps>();
@@ -67,6 +71,10 @@ const closeLabelPopovers = throttle(() => {
67
71
  :has-previous-version="versionHistory.length > 0"
68
72
  :is-selected="currentVersion === CURRENT_STATE_VERSION"
69
73
  :current-state-savepoint="unversionedSavepoint"
74
+ :is-version-limit-exceeded="
75
+ versionLimit?.limit !== undefined &&
76
+ versionLimit.currentUsage >= versionLimit.limit
77
+ "
70
78
  @select="$emit('select', CURRENT_STATE_VERSION)"
71
79
  @create-version="$emit('create')"
72
80
  @discard="$emit('discardCurrentState')"
@@ -92,6 +100,15 @@ const closeLabelPopovers = throttle(() => {
92
100
  @load-all="$emit('loadAll')"
93
101
  @select="$emit('select', $event ?? CURRENT_STATE_VERSION)"
94
102
  />
103
+ <VersionLimitInfo
104
+ v-if="versionLimit?.limit !== undefined"
105
+ class="version-limit-info"
106
+ :version-limit="{
107
+ limit: versionLimit.limit,
108
+ currentUsage: versionLimit.currentUsage,
109
+ }"
110
+ :upgrade-url
111
+ />
95
112
  </div>
96
113
  </div>
97
114
  </div>
@@ -155,6 +172,10 @@ const closeLabelPopovers = throttle(() => {
155
172
  & .versions {
156
173
  width: 100%;
157
174
  padding: 30px;
175
+
176
+ & .version-limit-info {
177
+ margin-top: 30px;
178
+ }
158
179
  }
159
180
  }
160
181
 
@@ -0,0 +1,32 @@
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+
4
+ import { InlineMessage } from "@knime/components";
5
+
6
+ import type { VersionLimit } from "./types";
7
+
8
+ const { versionLimit, upgradeUrl = undefined } = defineProps<{
9
+ versionLimit: Required<VersionLimit>;
10
+ upgradeUrl?: string;
11
+ }>();
12
+
13
+ const isLimitReached = computed(
14
+ () => versionLimit.currentUsage >= versionLimit.limit,
15
+ );
16
+
17
+ const title = computed(() => {
18
+ if (isLimitReached.value) {
19
+ return `You've reached the maximum of ${versionLimit.limit} versions.`;
20
+ } else {
21
+ return `Using ${versionLimit.currentUsage} of ${versionLimit.limit} versions.`;
22
+ }
23
+ });
24
+ </script>
25
+
26
+ <template>
27
+ <InlineMessage variant="info" :title>
28
+ <template v-if="upgradeUrl"><a :href="upgradeUrl">Upgrade</a></template>
29
+ <template v-else>Upgrade</template>
30
+ to use unlimited versions.
31
+ </InlineMessage>
32
+ </template>
@@ -70,3 +70,8 @@ export type ItemPermission =
70
70
  | "CONFIGURATION"
71
71
  | "MOVE"
72
72
  | "COPY";
73
+
74
+ export type VersionLimit = {
75
+ currentUsage: number;
76
+ limit?: number;
77
+ };
@@ -8,6 +8,7 @@ import type {
8
8
  ItemSavepoint,
9
9
  NamedItemVersion,
10
10
  RepositoryItem,
11
+ VersionLimit,
11
12
  WithAvatar,
12
13
  WithLabels,
13
14
  } from "@knime/hub-features/versions";
@@ -51,6 +52,12 @@ export const useVersionsApi = ({
51
52
  return doHubRequest(`/repository/${itemId}`) as Promise<RepositoryItem>;
52
53
  };
53
54
 
55
+ const fetchVersionLimit = ({ itemId }: { itemId: string }) => {
56
+ return doHubRequest(
57
+ `/repository/limits/${itemId}/item-versions`,
58
+ ) as Promise<VersionLimit>;
59
+ };
60
+
54
61
  const fetchVersions = ({
55
62
  itemId,
56
63
  loadAll,
@@ -214,6 +221,7 @@ export const useVersionsApi = ({
214
221
 
215
222
  return {
216
223
  fetchVersions,
224
+ fetchVersionLimit,
217
225
  fetchResourceLabels,
218
226
  fetchItemSavepoints,
219
227
  fetchPermissions,