Skip to content

Commit

Permalink
support bundle upload button (#2260)
Browse files Browse the repository at this point in the history
* button behind entitlement to send bundle to vendor

* read flag from vendor portal

* update license schema to accept new support bundle upload entitlement

* enabled -> supported for consistency

* button makes call to API to send bundle ID to share with vendors
  • Loading branch information
GraysonNull committed Oct 19, 2021
1 parent ff59aa2 commit 421a92a
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 32 deletions.
2 changes: 2 additions & 0 deletions kotskinds/config/crds/kots.io_licenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ spec:
type: boolean
isGitOpsSupported:
type: boolean
isSupportBundleUploadSupported:
type: boolean
isIdentityServiceSupported:
type: boolean
isSnapshotSupported:
Expand Down
3 changes: 3 additions & 0 deletions kotskinds/schemas/license-kots-v1beta1.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"isGitOpsSupported": {
"type": "boolean"
},
"isSupportBundleUploadSupported": {
"type": "boolean"
},
"isIdentityServiceSupported": {
"type": "boolean"
},
Expand Down
17 changes: 9 additions & 8 deletions pkg/api/handlers/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ type ResponseApp struct {
IsConfigurable bool `json:"isConfigurable"`
UpdateCheckerSpec string `json:"updateCheckerSpec"`

IsGitOpsSupported bool `json:"isGitOpsSupported"`
IsIdentityServiceSupported bool `json:"isIdentityServiceSupported"`
IsAppIdentityServiceSupported bool `json:"isAppIdentityServiceSupported"`
IsGeoaxisSupported bool `json:"isGeoaxisSupported"`
AllowRollback bool `json:"allowRollback"`
AllowSnapshots bool `json:"allowSnapshots"`
LicenseType string `json:"licenseType"`
CurrentVersion *versiontypes.AppVersion `json:"currentVersion"`
IsGitOpsSupported bool `json:"isGitOpsSupported"`
IsIdentityServiceSupported bool `json:"isIdentityServiceSupported"`
IsAppIdentityServiceSupported bool `json:"isAppIdentityServiceSupported"`
IsGeoaxisSupported bool `json:"isGeoaxisSupported"`
IsSupportBundleUploadSupported bool `json:"isSupportBundleUploadSupported"`
AllowRollback bool `json:"allowRollback"`
AllowSnapshots bool `json:"allowSnapshots"`
LicenseType string `json:"licenseType"`
CurrentVersion *versiontypes.AppVersion `json:"currentVersion"`

Downstreams []ResponseDownstream `json:"downstreams"`
}
Expand Down
45 changes: 23 additions & 22 deletions pkg/handlers/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,28 +271,29 @@ func responseAppFromApp(a *apptypes.App) (*types.ResponseApp, error) {
}

responseApp := types.ResponseApp{
ID: a.ID,
Slug: a.Slug,
Name: a.Name,
IsAirgap: a.IsAirgap,
CurrentSequence: a.CurrentSequence,
UpstreamURI: a.UpstreamURI,
IconURI: a.IconURI,
CreatedAt: a.CreatedAt,
UpdatedAt: a.UpdatedAt,
LastUpdateCheckAt: a.LastUpdateCheckAt,
HasPreflight: a.HasPreflight,
IsConfigurable: a.IsConfigurable,
UpdateCheckerSpec: a.UpdateCheckerSpec,
IsGitOpsSupported: license.Spec.IsGitOpsSupported,
IsIdentityServiceSupported: license.Spec.IsIdentityServiceSupported,
IsAppIdentityServiceSupported: isAppIdentityServiceSupported,
IsGeoaxisSupported: license.Spec.IsGeoaxisSupported,
AllowRollback: allowRollback,
AllowSnapshots: allowSnapshots,
LicenseType: license.Spec.LicenseType,
CurrentVersion: currentVersion,
Downstreams: responseDownstreams,
ID: a.ID,
Slug: a.Slug,
Name: a.Name,
IsAirgap: a.IsAirgap,
CurrentSequence: a.CurrentSequence,
UpstreamURI: a.UpstreamURI,
IconURI: a.IconURI,
CreatedAt: a.CreatedAt,
UpdatedAt: a.UpdatedAt,
LastUpdateCheckAt: a.LastUpdateCheckAt,
HasPreflight: a.HasPreflight,
IsConfigurable: a.IsConfigurable,
UpdateCheckerSpec: a.UpdateCheckerSpec,
IsGitOpsSupported: license.Spec.IsGitOpsSupported,
IsIdentityServiceSupported: license.Spec.IsIdentityServiceSupported,
IsAppIdentityServiceSupported: isAppIdentityServiceSupported,
IsGeoaxisSupported: license.Spec.IsGeoaxisSupported,
IsSupportBundleUploadSupported: license.Spec.IsSupportBundleUploadSupported,
AllowRollback: allowRollback,
AllowSnapshots: allowSnapshots,
LicenseType: license.Spec.LicenseType,
CurrentVersion: currentVersion,
Downstreams: responseDownstreams,
}

return &responseApp, nil
Expand Down
2 changes: 2 additions & 0 deletions pkg/template/license_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func (ctx licenseCtx) licenseFieldValue(name string) string {
switch name {
case "isGitOpsSupported":
return strconv.FormatBool(ctx.License.Spec.IsGitOpsSupported)
case "isSupportBundleUploadSupported":
return strconv.FormatBool(ctx.License.Spec.IsSupportBundleUploadSupported)
case "isIdentityServiceSupported":
return strconv.FormatBool(ctx.License.Spec.IsIdentityServiceSupported)
case "isGeoaxisSupported":
Expand Down
6 changes: 6 additions & 0 deletions web/src/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ class Root extends Component {
return !!find(apps, app => app.isGitOpsSupported);
}

isSupportBundleUploadSupported = () => {
const apps = this.state.appsList;
return !!find(apps, app => app.isSupportBundleUploadSupported);
}

isIdentityServiceSupported = () => {
const apps = this.state.appsList;
return !!find(apps, app => app.isIdentityServiceSupported);
Expand Down Expand Up @@ -396,6 +401,7 @@ class Root extends Component {
{...props}
rootDidInitialAppFetch={rootDidInitialWatchFetch}
appsList={appsList}
isSupportBundleUploadSupported={this.isSupportBundleUploadSupported()}
refetchAppsList={this.getAppsList}
onActiveInitSession={this.handleActiveInitSession}
appNameSpace={this.state.appNameSpace}
Expand Down
1 change: 1 addition & 0 deletions web/src/components/apps/AppDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ class AppDetailPage extends Component {
<TroubleshootContainer
app={app}
appName={appName}
isSupportBundleUploadSupported={this.props.isSupportBundleUploadSupported}
/>
} />
<Route exact path="/app/:slug/license" render={() =>
Expand Down
34 changes: 33 additions & 1 deletion web/src/components/troubleshoot/SupportBundleAnalysis.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,38 @@ export class SupportBundleAnalysis extends React.Component {
loading: false,
downloadBundleErrMsg: "",
getSupportBundleErrMsg: "",
sendingBundle: false,
sendingBundleErrMsg: "",
bundleSentToVendor: false,
displayErrorModal: false
};
}

sendBundleToVendor = async () => {
this.setState({ sendingBundle: true, sendingBundleErrMsg: "" });
fetch(`${window.env.API_ENDPOINT}/troubleshoot/app/${this.props.match.params.slug}/supportbundle/${this.props.match.params.bundleSlug}/share`, {
method: "POST",
headers: {
"Authorization": Utilities.getToken(),
}
})
.then(async (result) => {
if (!result.ok) {
this.setState({ sendingBundle: false, sendingBundleErrMsg: `Unable to send bundle to vendor: Status ${result.status}, please try again.` });
return;
}

this.setState({ sendingBundle: false, bundleSentToVendor: true, sendingBundleErrMsg: "" });
setTimeout(() => {
this.setState({ bundleSentToVendor: false });
}, 3000);
})
.catch(err => {
console.log(err);
this.setState({ sendingBundle: false, sendingBundleErrMsg: err ? `Unable to send bundle to vendor: ${err.message}` : "Something went wrong, please try again." });
})
}

downloadBundle = async (bundle) => {
this.setState({ downloadingBundle: true, downloadBundleErrMsg: "" });
fetch(`${window.env.API_ENDPOINT}/troubleshoot/supportbundle/${bundle.id}/download`, {
Expand Down Expand Up @@ -161,9 +189,13 @@ export class SupportBundleAnalysis extends React.Component {
<div className="flex flex-auto alignItems--center justifyContent--flexEnd">
{this.state.downloadBundleErrMsg &&
<p className="u-textColor--error u-fontSize--normal u-fontWeight--medium u-lineHeight--normal u-marginRight--10">{this.state.downloadBundleErrMsg}</p>}
{this.props.isSupportBundleUploadSupported &&
this.state.sendingBundle ? <Loader className="u-marginRight--10" size="30" /> : this.state.bundleSentToVendor ? <p className="u-fontSize--small u-fontWeight--medium u-textColor--success u-lineHeight--normal u-marginRight--10">Bundle sent to vendor</p> :
<button className="btn primary lightBlue u-marginRight--10" onClick={this.sendBundleToVendor}>Send bundle to vendor</button>
}
{this.state.downloadingBundle ?
<Loader size="30" /> :
<button className="btn primary lightBlue" onClick={() => this.downloadBundle(bundle)}> Download bundle </button>
<button className={`btn ${this.props.isSupportBundleUploadSupported ? "secondary blue" : "primary lightBlue"}`} onClick={() => this.downloadBundle(bundle)}> Download bundle </button>
}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/troubleshoot/TroubleshootContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TroubleshootContainer extends Component {
<GenerateSupportBundle watch={app} />
} />
<Route path="/app/:slug/troubleshoot/analyze/:bundleSlug" render={() =>
<SupportBundleAnalysis watch={app} />
<SupportBundleAnalysis watch={app} isSupportBundleUploadSupported={this.props.isSupportBundleUploadSupported} />
} />
<Route exact path="/app/:slug/troubleshoot/redactors" render={(props) =>
<Redactors {...props} appSlug={app.slug} appName={appName} />}
Expand Down

0 comments on commit 421a92a

Please sign in to comment.