This repository was archived by the owner on Nov 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathActionBar.js
More file actions
135 lines (121 loc) · 3.82 KB
/
ActionBar.js
File metadata and controls
135 lines (121 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import React, { Component } from "react";
import { Icon, Link as FabricLink } from "office-ui-fabric-react";
import { trackEvent } from "../../helpers";
import { libraryService } from "../../services";
import "./ActionBar.scss";
class ActionBar extends Component {
constructor(props) {
super(props);
this.outboundRepoClick = this.outboundRepoClick.bind(this);
this.outboundDeployClick = this.outboundDeployClick.bind(this);
this.openInVSCodeClick = this.openInVSCodeClick.bind(this);
this.trackUserActionEvent = this.trackUserActionEvent.bind(this);
}
outboundDeployClick() {
this.updateDownloadCount(this.props.id);
this.trackUserActionEvent("/sample/deploy/agree");
}
updateDownloadCount(id) {
libraryService
.updateDownloadCount(id)
.then(() => {
// do nothing
})
.catch(() => {
// do nothing
});
}
getDeployLink(template) {
return (
"https://portal.azure.com/#create/Microsoft.Template/uri/" +
encodeURIComponent(template)
);
}
outboundRepoClick() {
this.trackUserActionEvent("/sample/source");
}
getOpenInVSCodeLink(repository) {
return "vscode://vscode.git/clone?url=" + encodeURIComponent(repository);
}
getOpenInGithubDevLink(repository) {
if(repository){
return repository.replace("github\.com", "github\.dev");
} else {
return repository;
}
}
openInVSCodeClick() {
this.updateDownloadCount(this.props.id);
this.trackUserActionEvent("/sample/openinvscode");
}
openInGithubDevClick() {
this.updateDownloadCount(this.props.id);
this.trackUserActionEvent("/sample/openingithubdev");
}
trackUserActionEvent(eventName) {
let eventData = {
id: this.props.id,
repository: this.props.repository,
template: this.props.template
};
trackEvent(eventName, eventData);
}
render() {
const { repository, template } = this.props;
return (
<div className="action-container">
<div className="action-item">
<FabricLink
href={this.getOpenInVSCodeLink(repository)}
disabled={!repository}
onClick={this.openInVSCodeClick}
>
<div className="action-link-wrapper">
<Icon iconName="Edit" className="fabric-icon-link" />
<span className="action-link-text">Edit in VS Code</span>
</div>
</FabricLink>
</div>
<div className="action-item">
<FabricLink
href={this.getOpenInGithubDevLink(repository)}
disabled={!repository}
onClick={this.openInGithubDevClick}
>
<div className="action-link-wrapper">
<Icon iconName="Edit" className="fabric-icon-link" />
<span className="action-link-text">Edit in GitHub.dev</span>
</div>
</FabricLink>
</div>
<div className="action-item">
<FabricLink
href={this.getDeployLink(template)}
disabled={!template}
target="_blank"
onClick={this.outboundDeployClick}
>
<div className="action-link-wrapper">
<Icon iconName="Deploy" className="fabric-icon-link" />
<span className="action-link-text">Deploy</span>
</div>
</FabricLink>
</div>
<div className="action-item">
<FabricLink
href={repository}
disabled={!repository}
target="_blank"
onClick={this.outboundRepoClick}
>
<div className="action-link-wrapper">
<Icon iconName="GitHub-12px" className="githubicon" />
<span className="action-link-text">Open in Github</span>
</div>
</FabricLink>
</div>
</div>
);
}
}
export default ActionBar;