@hyvor/design 2.0.8-beta.1 → 2.0.8-beta.3

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.
@@ -1,22 +1,13 @@
1
1
  <script lang="ts">
2
- import { getCloudContext, type ResolvedLicense } from '../../CloudContext/cloudContextState.svelte.js';
2
+ import { getCloudContext } from '../../CloudContext/cloudContextState.svelte.js';
3
3
  import Tag from '../../../components/Tag/Tag.svelte';
4
- import type { TagSize } from '../../../components/Tag/tag.types.js';
5
4
  import Tooltip from '../../../components/Tooltip/Tooltip.svelte';
6
5
  import IconBuilding from '@hyvor/icons/IconBuilding';
7
6
  import type { Component } from 'svelte';
8
7
 
9
- interface Props {
10
- name: string; // product name like Hyvor Talk
11
- customLicense?: ResolvedLicense;
12
- size?: TagSize;
13
- tooltip?: boolean;
14
- href?: string | null;
15
- }
16
-
17
- let { name, customLicense, size = 'medium', tooltip: showTooltip = true, href = "/console/billing" }: Props = $props();
8
+ let { name } = $props();
18
9
 
19
- const license = $derived(customLicense || getCloudContext().license);
10
+ const { license } = $derived(getCloudContext());
20
11
 
21
12
  function daysDiff(unix: number) {
22
13
  const date = new Date(unix * 1000);
@@ -81,7 +72,7 @@
81
72
  const s = trialDays === 1 ? '' : 's';
82
73
 
83
74
  return {
84
- name: `Trial (${trialDays}d)`,
75
+ name: `Trial License (${trialDays}d)`,
85
76
  tooltip: `You organization is currently using a trial license for ${name}. It will expire in ${trialDays} day${s}.`,
86
77
  tagColor: 'orange'
87
78
  };
@@ -100,12 +91,12 @@
100
91
  </script>
101
92
 
102
93
  {#if config}
103
- <a class="wrap" href={href}>
104
- <Tooltip position="bottom" disabled={showTooltip === false}>
94
+ <a class="wrap" href="/console/billing">
95
+ <Tooltip position="bottom">
105
96
  {#snippet tooltip()}
106
97
  {config.tooltip}
107
98
  {/snippet}
108
- <Tag color={config.tagColor} {size}>
99
+ <Tag color={config.tagColor}>
109
100
  {#snippet start()}
110
101
  {#if config.tagIcon}
111
102
  <config.tagIcon size={10} />
@@ -1,13 +1,6 @@
1
- import { type ResolvedLicense } from '../../CloudContext/cloudContextState.svelte.js';
2
- import type { TagSize } from '../../../components/Tag/tag.types.js';
3
1
  import type { Component } from 'svelte';
4
- interface Props {
5
- name: string;
6
- customLicense?: ResolvedLicense;
7
- size?: TagSize;
8
- tooltip?: boolean;
9
- href?: string | null;
10
- }
11
- declare const BarLicense: Component<Props, {}, "">;
2
+ declare const BarLicense: Component<{
3
+ name: any;
4
+ }, {}, "">;
12
5
  type BarLicense = ReturnType<typeof BarLicense>;
13
6
  export default BarLicense;
@@ -16,7 +16,7 @@
16
16
  }
17
17
  let { selectedUserId = $bindable(undefined) }: Props = $props();
18
18
 
19
- const { instance, organization } = getCloudContext();
19
+ const { instance, organization, deployment } = getCloudContext();
20
20
 
21
21
  let search = $state('');
22
22
  let role = $derived(organization?.role);
@@ -138,16 +138,18 @@
138
138
  </div>
139
139
  {/if}
140
140
  </div>
141
- <div class="invite-note">
142
- Looking for a user outside your organization?
143
- {#if role === 'admin' || role === 'manager'}
144
- <a href={instance + '/account/org/members?invite'} target="_blank" class="hds-link">
145
- Invite them
146
- </a>
147
- {:else}
148
- Ask an admin to invite them
149
- {/if} to your organization first.
150
- </div>
141
+ {#if deployment === 'cloud'}
142
+ <div class="invite-note">
143
+ Looking for a user outside your organization?
144
+ {#if role === 'admin' || role === 'manager'}
145
+ <a href={instance + '/account/org/members?invite'} target="_blank" class="hds-link">
146
+ Invite them
147
+ </a>
148
+ {:else}
149
+ Ask an admin to invite them
150
+ {/if} to your organization first.
151
+ </div>
152
+ {/if}
151
153
  {/if}
152
154
 
153
155
  <style>
@@ -1,11 +1,18 @@
1
1
  import { getCloudContext } from '../CloudContext/cloudContextState.svelte.js';
2
2
  export async function searchMembers(search) {
3
- const { instance, organization } = getCloudContext();
3
+ const { instance, organization, deployment } = getCloudContext();
4
4
  const query = new URLSearchParams({
5
5
  organization_id: organization?.id.toString() || '',
6
6
  search
7
7
  });
8
- const response = await fetch(instance + '/api/v2/cloud/members/search?' + query.toString(), {
8
+ let url;
9
+ if (deployment === 'cloud') {
10
+ url = instance + '/api/v2/cloud/members/search?' + query.toString();
11
+ }
12
+ else {
13
+ url = '/api/oidc/search?' + query.toString();
14
+ }
15
+ const response = await fetch(url, {
9
16
  method: 'GET',
10
17
  credentials: 'include'
11
18
  });
@@ -15,7 +15,11 @@ export async function getMyOrganizations() {
15
15
  // { id: 3, name: 'Org 3', member_role: 'billing' },
16
16
  // { id: 4, name: 'Org 4', member_role: 'manager' }
17
17
  // ];
18
- const { instance } = getCloudContext();
18
+ const { instance, deployment, organization } = getCloudContext();
19
+ if (deployment !== 'cloud') {
20
+ loadedOrganizations = organization ? [organization] : [];
21
+ return loadedOrganizations;
22
+ }
19
23
  const response = await fetch(instance + '/api/v2/cloud/organizations/my', {
20
24
  credentials: 'include'
21
25
  });
@@ -24,7 +28,10 @@ export async function getMyOrganizations() {
24
28
  return data;
25
29
  }
26
30
  export async function switchOrganization(orgId) {
27
- const { instance } = getCloudContext();
31
+ const { instance, deployment, organization } = getCloudContext();
32
+ if (deployment !== 'cloud') {
33
+ return organization;
34
+ }
28
35
  const response = await fetch(instance + '/api/v2/cloud/organizations/switch', {
29
36
  method: 'POST',
30
37
  credentials: 'include',
@@ -2,7 +2,6 @@ export { default as CloudContext } from './CloudContext/CloudContext.svelte';
2
2
  export { getCloudContext, setCloudContext, type CloudContext as CloudContextType, type CloudContextUser, type CloudContextOrganization, type OrganizationRole, type OrganizationMember, type ResolvedLicense } from './CloudContext/cloudContextState.svelte.js';
3
3
  export { default as HyvorBar } from './HyvorBar/HyvorBar.svelte';
4
4
  export { bar as hyvorBar } from './HyvorBar/bar.js';
5
- export { default as BarLicense } from './HyvorBar/BarNotice/BarLicense.svelte';
6
5
  export { default as ResourceCreator } from './ResourceCreator/ResourceCreator.svelte';
7
6
  export { default as OrganizationMemberSearch } from './OrganizationMembers/OrganizationMembersSearch.svelte';
8
7
  export { default as OrganizationCreator } from './OrganizationCreator/OrganizationCreator.svelte';
@@ -2,7 +2,6 @@ export { default as CloudContext } from './CloudContext/CloudContext.svelte';
2
2
  export { getCloudContext, setCloudContext } from './CloudContext/cloudContextState.svelte.js';
3
3
  export { default as HyvorBar } from './HyvorBar/HyvorBar.svelte';
4
4
  export { bar as hyvorBar } from './HyvorBar/bar.js';
5
- export { default as BarLicense } from './HyvorBar/BarNotice/BarLicense.svelte';
6
5
  export { default as ResourceCreator } from './ResourceCreator/ResourceCreator.svelte';
7
6
  export { default as OrganizationMemberSearch } from './OrganizationMembers/OrganizationMembersSearch.svelte';
8
7
  export { default as OrganizationCreator } from './OrganizationCreator/OrganizationCreator.svelte';
@@ -1,12 +1,11 @@
1
1
  <script lang="ts">
2
2
  import { createBubbler } from 'svelte/legacy';
3
- import type { TagSize } from './tag.types.js';
4
3
 
5
4
  const bubble = createBubbler();
6
5
 
7
6
  interface Props {
8
7
  as?: 'button' | 'a' | 'span';
9
- size?: TagSize;
8
+ size?: 'x-small' | 'small' | 'medium' | 'large';
10
9
  color?:
11
10
  | 'default' // default tag (categories)
12
11
  | 'accent'
@@ -1,7 +1,6 @@
1
- import type { TagSize } from './tag.types.js';
2
1
  interface Props {
3
2
  as?: 'button' | 'a' | 'span';
4
- size?: TagSize;
3
+ size?: 'x-small' | 'small' | 'medium' | 'large';
5
4
  color?: 'default' | 'accent' | 'green' | 'red' | 'blue' | 'orange';
6
5
  interactive?: boolean;
7
6
  outline?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyvor/design",
3
- "version": "2.0.8-beta.1",
3
+ "version": "2.0.8-beta.3",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "repository": {
@@ -1 +0,0 @@
1
- export type TagSize = 'x-small' | 'small' | 'medium' | 'large';
@@ -1 +0,0 @@
1
- export {};