Skip to content

Commit 7d0034c

Browse files
authored
EQMS-1635 Add generic action for copying link (#9668)
Signed-off-by: Alexander Onnikov <[email protected]>
1 parent 8fc81ac commit 7d0034c

File tree

26 files changed

+97
-48
lines changed

26 files changed

+97
-48
lines changed

models/card/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@hcengineering/time": "^0.6.0",
4343
"@hcengineering/card": "^0.6.0",
4444
"@hcengineering/model-attachment": "^0.6.0",
45+
"@hcengineering/model-guest": "^0.6.0",
4546
"@hcengineering/model-presentation": "^0.6.0",
4647
"@hcengineering/model-preference": "^0.6.0",
4748
"@hcengineering/workbench": "^0.6.16",

models/card/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
} from '@hcengineering/model'
5858
import attachment from '@hcengineering/model-attachment'
5959
import { TAttachedDoc, TClass, TDoc, TMixin, TSpace } from '@hcengineering/model-core'
60+
import { createPublicLinkAction } from '@hcengineering/model-guest'
6061
import presentation from '@hcengineering/model-presentation'
6162
import setting from '@hcengineering/model-setting'
6263
import view, { createAction, type Viewlet } from '@hcengineering/model-view'
@@ -875,6 +876,8 @@ export function createModel (builder: Builder): void {
875876
match: card.function.CardCustomLinkMatch,
876877
encode: card.function.CardCustomLinkEncode
877878
})
879+
880+
createPublicLinkAction(builder, card.class.Card, card.action.PublicLink)
878881
}
879882

880883
function defineTabs (builder: Builder): void {

models/card/src/plugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export default mergeIds(cardId, card, {
3434
action: {
3535
DeleteMasterTag: '' as Ref<Action>,
3636
SetParent: '' as Ref<Action<Doc, any>>,
37-
UnsetParent: '' as Ref<Action<Doc, any>>
37+
UnsetParent: '' as Ref<Action<Doc, any>>,
38+
PublicLink: '' as Ref<Action<Doc, any>>
3839
},
3940
category: {
4041
Card: '' as Ref<ActionCategory>,

models/chunter/src/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ function defineMessageActions (builder: Builder): void {
9797
mode: ['context', 'browser'],
9898
application: chunter.app.Chunter,
9999
group: 'copy'
100-
}
100+
},
101+
override: [view.action.CopyLink]
101102
},
102103
chunter.action.CopyChatMessageLink
103104
)

models/document/src/index.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -369,27 +369,6 @@ function defineDocument (builder: Builder): void {
369369
document.action.CreateChildDocument
370370
)
371371

372-
createAction(
373-
builder,
374-
{
375-
action: view.actionImpl.CopyTextToClipboard,
376-
actionProps: {
377-
textProvider: document.function.GetDocumentLink
378-
},
379-
label: document.string.CopyDocumentUrl,
380-
icon: view.icon.CopyLink,
381-
input: 'focus',
382-
category: document.category.Document,
383-
target: document.class.Document,
384-
context: {
385-
mode: ['context', 'browser'],
386-
application: document.app.Documents,
387-
group: 'copy'
388-
}
389-
},
390-
document.action.CopyDocumentLink
391-
)
392-
393372
createAction(
394373
builder,
395374
{

models/recruit/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,8 @@ export function createModel (builder: Builder): void {
12861286
mode: ['context', 'browser'],
12871287
application: recruit.app.Recruit,
12881288
group: 'copy'
1289-
}
1289+
},
1290+
override: [view.action.CopyLink]
12901291
},
12911292
recruit.action.CopyApplicationLink
12921293
)
@@ -1306,7 +1307,8 @@ export function createModel (builder: Builder): void {
13061307
mode: ['context', 'browser'],
13071308
application: recruit.app.Recruit,
13081309
group: 'copy'
1309-
}
1310+
},
1311+
override: [view.action.CopyLink]
13101312
},
13111313
recruit.action.CopyCandidateLink
13121314
)

models/tracker/src/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ export function createActions (builder: Builder, issuesId: string, componentsId:
633633
mode: ['context', 'browser'],
634634
application: tracker.app.Tracker,
635635
group: 'copy'
636-
}
636+
},
637+
override: [view.action.CopyLink]
637638
},
638639
tracker.action.CopyIssueLink
639640
)

models/view/src/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,24 @@ export function createModel (builder: Builder): void {
746746
view.action.Delete
747747
)
748748

749+
createAction(
750+
builder,
751+
{
752+
action: view.actionImpl.CopyTextToClipboard,
753+
actionProps: {
754+
textProvider: view.function.GetLink
755+
},
756+
label: view.string.CopyLink,
757+
icon: view.icon.CopyLink,
758+
category: view.category.General,
759+
input: 'any',
760+
target: core.class.Doc,
761+
context: { mode: ['context', 'browser'] },
762+
visibilityTester: view.function.CanCopyLink
763+
},
764+
view.action.CopyLink
765+
)
766+
749767
createAction(
750768
builder,
751769
{

models/view/src/plugin.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ export default mergeIds(viewId, view, {
120120
Navigation: '' as IntlString,
121121
Editor: '' as IntlString,
122122
MarkdownFormatting: '' as IntlString,
123-
HideArchived: '' as IntlString
123+
HideArchived: '' as IntlString,
124+
CopyLink: '' as IntlString
124125
},
125126
function: {
126127
FilterArrayAllResult: '' as FilterFunction,
@@ -153,7 +154,9 @@ export default mergeIds(viewId, view, {
153154
CanLeaveSpace: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
154155
IsClipboardAvailable: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>,
155156
BlobImageMetadata: '' as Resource<(file: FileOrBlob, blob: Ref<Blob>) => Promise<BlobMetadata | undefined>>,
156-
BlobVideoMetadata: '' as Resource<(file: FileOrBlob, blob: Ref<Blob>) => Promise<BlobMetadata | undefined>>
157+
BlobVideoMetadata: '' as Resource<(file: FileOrBlob, blob: Ref<Blob>) => Promise<BlobMetadata | undefined>>,
158+
GetLink: '' as Resource<(doc?: Doc | Doc[]) => Promise<string>>,
159+
CanCopyLink: '' as Resource<(doc?: Doc | Doc[]) => Promise<boolean>>
157160
},
158161
pipeline: {
159162
PresentationMiddleware: '' as Ref<PresentationMiddlewareFactory>,

plugins/document-resources/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import {
5151
documentTitleProvider,
5252
getDocumentLink,
5353
getDocumentLinkId,
54-
getDocumentUrl,
5554
parseDocumentId,
5655
resolveLocation
5756
} from './utils'
@@ -192,7 +191,6 @@ export default async (): Promise<Resources> => ({
192191
UnlockContent: unlockContent
193192
},
194193
function: {
195-
GetDocumentLink: getDocumentUrl,
196194
GetObjectLinkFragment: getDocumentLink,
197195
DocumentTitleProvider: documentTitleProvider,
198196
CanLockDocument: canLockDocument,

0 commit comments

Comments
 (0)