@ossy/distribution 1.10.2 → 3.0.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/distribution",
3
3
  "description": "Analytics module — workspace analytics for website traffic",
4
- "version": "1.10.2",
4
+ "version": "3.0.1",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "module": "./src/index.js",
@@ -27,5 +27,5 @@
27
27
  "@ossy/sdk-react": "*",
28
28
  "react": "*"
29
29
  },
30
- "gitHead": "2b8745d57fee8b6c08787e2755b4df489291a5cd"
30
+ "gitHead": "4a70ec216448680d2fddc57b2a8a0077489720ae"
31
31
  }
package/src/Definition.js CHANGED
@@ -3,5 +3,5 @@ export const Definition = {
3
3
  title: 'Distribution',
4
4
  description: 'Distribution channels and external publishing integrations.',
5
5
  icon: 'share',
6
- statuses: ['beta'],
6
+ status: ['beta'],
7
7
  }
@@ -1,9 +1,8 @@
1
1
  import React from 'react'
2
2
  import { useRouter } from '@ossy/router-react'
3
- import { Title, Text, View, Tags, Button, Switch, useLocale } from '@ossy/design-system'
3
+ import { Text, View, Button, Switch, Page, useLocale, Tags } from '@ossy/design-system'
4
4
  import { AsyncStatus } from '@ossy/sdk-react'
5
5
  import { Definition } from '@ossy/distribution'
6
- import { moduleStatusTags } from './moduleStatus.js'
7
6
 
8
7
  export const metadata = {
9
8
  id: 'distribution/home',
@@ -26,31 +25,23 @@ export const DistributionPage = () => {
26
25
  icon: key === 'pinterest' ? 'details-more' : key === 'x' ? 'screen-shot' : 'arrows-expand-up-right',
27
26
  }))
28
27
 
29
- return (
30
- <View gap="m" surface="primary" style={{ padding: 'var(--space-m) var(--space-l)', height: '100%', overflowY: 'auto' }}>
31
-
32
- <View inset="s" gap="s">
33
-
34
- <View layout="row" justifyContent="space-between" alignItems="center">
35
- <View layout='row' gap="s" alignItems="center">
36
- <Title>{t('distribution.home.title')}</Title>
37
- {moduleStatusTags(Definition).length > 0 && (
38
- <Tags tags={moduleStatusTags(Definition)} size="s" />
39
- )}
40
- </View>
41
- <Button variant="cta" disabled={true} prefix="add">
42
- {t('distribution.home.addIntegration')}
43
- </Button>
44
- </View>
45
-
46
- <Text style={{ maxWidth: '400px' }}>
47
- {t('distribution.home.description')}
48
- </Text>
28
+ const statusTags = (Definition.status ?? [])
29
+ .map((s) => ({ beta: 'Beta', 'coming-soon': 'Coming Soon' }[s]))
30
+ .filter(Boolean)
49
31
 
50
- </View>
51
-
52
- <View gap="m" inset="s">
53
- <Title variant="secondary">{t('distribution.home.integrations')}</Title>
32
+ return (
33
+ <Page
34
+ title="distribution.home.title"
35
+ near={statusTags.length > 0 ? <Tags tags={statusTags} size="s" /> : undefined}
36
+ description="distribution.home.description"
37
+ far={(
38
+ <Button variant="cta" disabled prefix="add">
39
+ {t('distribution.home.addIntegration')}
40
+ </Button>
41
+ )}
42
+ >
43
+ <View gap="m">
44
+ <Text variant="heading-secondary" as="h2" text="distribution.home.integrations" />
54
45
  <Switch on={AsyncStatus.Success}>
55
46
 
56
47
  <Switch.Case match={[AsyncStatus.NotInitialized, AsyncStatus.Loading]}>
@@ -91,7 +82,7 @@ export const DistributionPage = () => {
91
82
  </Switch>
92
83
  </View>
93
84
 
94
- </View>
85
+ </Page>
95
86
  )
96
87
  }
97
88
 
@@ -1,95 +0,0 @@
1
- /**
2
- * Module lifecycle & visibility helpers.
3
- *
4
- * - `statuses` is a string[] on each Definition (e.g. `['beta']`, `['beta', 'internal']`).
5
- * - Legacy single `status` is still read for compatibility.
6
- * - Optional workspace gating via `workspaceServiceKey` or `workspaceServiceKeys` + `workspaceServiceRequirement`.
7
- */
8
-
9
- export const MODULE_STATUS = {
10
- beta: 'beta',
11
- comingSoon: 'coming-soon',
12
- stable: 'stable',
13
- /** When present, the module is omitted from the primary sidebar. */
14
- hidden: 'hidden',
15
- }
16
-
17
- const STATUS_TO_TAG_LABEL = {
18
- [MODULE_STATUS.beta]: 'Beta',
19
- [MODULE_STATUS.comingSoon]: 'Coming Soon',
20
- [MODULE_STATUS.stable]: null,
21
- [MODULE_STATUS.hidden]: null,
22
- }
23
-
24
- /** Status values that exclude a module from the sidebar (in addition to workspace gating). */
25
- const SIDEBAR_HIDE_STATUSES = new Set([MODULE_STATUS.hidden])
26
-
27
- /**
28
- * Normalize legacy `definition.status` and `definition.statuses` into one array.
29
- * @param {{ status?: string, statuses?: string[] }} definition
30
- * @returns {string[]}
31
- */
32
- export function moduleStatuses(definition) {
33
- const fromArray = Array.isArray(definition?.statuses) ? definition.statuses : []
34
- const fromLegacy = definition?.status && typeof definition.status === 'string' ? [definition.status] : []
35
- if (fromArray.length) return [...new Set(fromArray)]
36
- if (fromLegacy.length) return [...new Set(fromLegacy)]
37
- return []
38
- }
39
-
40
- /**
41
- * @param {{ status?: string, statuses?: string[] }} definition
42
- * @returns {string[]} labels for `<Tags tags={...} />` (stable/hidden emit none)
43
- */
44
- export function moduleStatusTags(definition) {
45
- const labels = []
46
- for (const s of moduleStatuses(definition)) {
47
- const label = STATUS_TO_TAG_LABEL[s]
48
- if (label) labels.push(label)
49
- }
50
- return [...new Set(labels)]
51
- }
52
-
53
- /**
54
- * @param {{ status?: string, statuses?: string[] }} definition
55
- * @returns {boolean}
56
- */
57
- export function isHiddenFromSidebar(definition) {
58
- if (!definition) return true
59
- return moduleStatuses(definition).some(s => SIDEBAR_HIDE_STATUSES.has(s))
60
- }
61
-
62
- /**
63
- * @param {Record<string, boolean> | undefined} services workspace.services
64
- * @param {{ workspaceServiceKey?: string, workspaceServiceKeys?: string[], workspaceServiceRequirement?: 'all' | 'any' }} definition
65
- * @returns {boolean}
66
- */
67
- export function workspaceAllowsModule(services, definition) {
68
- if (!definition) return false
69
- const keys = definition.workspaceServiceKeys?.length
70
- ? definition.workspaceServiceKeys
71
- : definition.workspaceServiceKey
72
- ? [definition.workspaceServiceKey]
73
- : null
74
- if (!keys?.length) return true
75
- const mode = definition.workspaceServiceRequirement || 'all'
76
- const map = services || {}
77
- /** Treat missing keys as allowed (legacy workspaces); only explicit `false` from disable turns a service off. */
78
- const flags = keys.map(k => map[k] !== false)
79
- return mode === 'any' ? flags.some(Boolean) : flags.every(Boolean)
80
- }
81
-
82
- /**
83
- * Router ref for a module’s default page: `@<moduleId>/home`
84
- * @param {string} moduleId — matches `Definition.module.id` / folder name
85
- */
86
- export function moduleHomeRef(moduleId) {
87
- return `@${moduleId}/home`
88
- }
89
-
90
- /**
91
- * @param {{ requiresModules?: Array<{ id: string, label: string, href: string }> }} definition
92
- */
93
- export function moduleRequiresModules(definition) {
94
- return definition?.requiresModules ?? []
95
- }