-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(app-platform): Sort Integrations #12697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,11 +132,9 @@ class OrganizationIntegrations extends AsyncComponent { | |
|
||
// Rendering | ||
|
||
renderBody() { | ||
const {reloading, applications, appInstalls} = this.state; | ||
const providers = this.providers | ||
.sort((a, b) => b.isInstalled - a.isInstalled) | ||
.map(provider => ( | ||
renderProvider(provider) { | ||
return ( | ||
<IntegrationRow key={`row-${provider.key}`}> | ||
<ProviderRow | ||
key={provider.key} | ||
provider={provider} | ||
|
@@ -148,7 +146,55 @@ class OrganizationIntegrations extends AsyncComponent { | |
onReinstall={this.onInstall} | ||
enabledPlugins={this.enabledPlugins} | ||
/> | ||
)); | ||
</IntegrationRow> | ||
); | ||
} | ||
|
||
renderSentryApps(apps, key) { | ||
const {appInstalls} = this.state; | ||
|
||
return ( | ||
<IntegrationRow key={`row-${key}`}> | ||
<SentryAppInstallations | ||
key={key} | ||
orgId={this.props.params.orgId} | ||
installs={appInstalls} | ||
applications={apps} | ||
/> | ||
</IntegrationRow> | ||
); | ||
} | ||
|
||
renderBody() { | ||
const {reloading, applications, appInstalls} = this.state; | ||
|
||
const installedProviders = this.providers | ||
.filter(p => p.isInstalled) | ||
.map(p => [p.name, this.renderProvider(p)]); | ||
|
||
const uninstalledProviders = this.providers | ||
.filter(p => !p.isInstalled) | ||
.map(p => [p.name, this.renderProvider(p)]); | ||
|
||
const installedSentryApps = (applications || []) | ||
.filter(a => appInstalls.find(i => i.app.slug === a.slug)) | ||
.map(a => [a.name, this.renderSentryApps([a], a.slug)]); | ||
|
||
const uninstalledSentryApps = (applications || []) | ||
.filter(a => !appInstalls.find(i => i.app.slug === a.slug)) | ||
.map(a => [a.name, this.renderSentryApps([a], a.slug)]); | ||
|
||
// Combine the list of Providers and Sentry Apps that have installations. | ||
const installed = installedProviders | ||
.concat(installedSentryApps) | ||
.sort((a, b) => a[0].localeCompare(b[0])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo, destructuring adds some more code but can be a bit more clear about what you're retrieving from the array:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, more "punctuation", but definitely clearer 👍 |
||
.map(i => i[1]); | ||
|
||
// Combine the list of Providers and Sentry Apps that have no installations. | ||
const uninstalled = uninstalledProviders | ||
.concat(uninstalledSentryApps) | ||
.sort((a, b) => a[0].localeCompare(b[0])) | ||
.map(i => i[1]); | ||
|
||
return ( | ||
<React.Fragment> | ||
|
@@ -169,21 +215,17 @@ class OrganizationIntegrations extends AsyncComponent { | |
{reloading && <StyledLoadingIndicator mini />} | ||
</PanelHeader> | ||
<PanelBody> | ||
{providers} | ||
{applications && ( | ||
<SentryAppInstallations | ||
orgId={this.props.params.orgId} | ||
installs={appInstalls} | ||
applications={applications} | ||
/> | ||
)} | ||
{installed} | ||
{uninstalled} | ||
</PanelBody> | ||
</Panel> | ||
</React.Fragment> | ||
); | ||
} | ||
} | ||
|
||
const IntegrationRow = styled.div``; | ||
markstory marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const StyledLoadingIndicator = styled(LoadingIndicator)` | ||
position: absolute; | ||
right: 7px; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's kind of a lot of duplicated and/or very similar code, we could use
lodash.partition
to cut back some code. Downside of this is that readers will need to look up whatpartition
does. (Current code is fine too though).