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
feat(integration-directory): plugin detailed view #16821
Changes from all commits
cf3f0dc
bc9d72f
2d93121
3616da1
a34f07b
20f794e
56d1831
9f42768
a858b41
8b59556
0ccf3cb
0d8fb70
72e831a
2fa1119
c863170
a06b970
9500f55
4b6f551
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
|
||
import {t} from 'app/locale'; | ||
import Access from 'app/components/acl/access'; | ||
import Button from 'app/components/button'; | ||
import Confirm from 'app/components/confirm'; | ||
import Alert from 'app/components/alert'; | ||
import ProjectBadge from 'app/components/idBadge/projectBadge'; | ||
import withApi from 'app/utils/withApi'; | ||
import {Client} from 'app/api'; | ||
import { | ||
addErrorMessage, | ||
addSuccessMessage, | ||
addLoadingMessage, | ||
} from 'app/actionCreators/indicator'; | ||
import {PluginNoProject, PluginProjectItem, Organization, AvatarProject} from 'app/types'; | ||
|
||
export type Props = { | ||
api: Client; | ||
plugin: PluginNoProject; | ||
projectItem: PluginProjectItem; | ||
organization: Organization; | ||
onResetConfiguration: (projectId: string) => void; | ||
onEnablePlugin: (projectId: string) => void; | ||
className?: string; | ||
}; | ||
|
||
export class InstalledPlugin extends React.Component<Props> { | ||
getConfirmMessage() { | ||
return ( | ||
<React.Fragment> | ||
<Alert type="error" icon="icon-circle-exclamation"> | ||
{t( | ||
'Deleting this installation will disable the integration for this project and remove any configurations.' | ||
)} | ||
</Alert> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
pluginUpdate = async (data: object) => { | ||
const {organization, projectItem, plugin} = this.props; | ||
// no try/catch so the caller will have to have it | ||
await this.props.api.requestPromise( | ||
`/projects/${organization.slug}/${projectItem.projectSlug}/plugins/${plugin.id}/`, | ||
NisanthanNanthakumar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
method: 'POST', | ||
data, | ||
} | ||
); | ||
}; | ||
|
||
handleReset = async () => { | ||
try { | ||
addLoadingMessage(t('Removing...')); | ||
await this.pluginUpdate({reset: true}); | ||
addSuccessMessage(t('Configuration was removed')); | ||
this.props.onResetConfiguration(this.props.projectItem.projectId); | ||
} catch (_err) { | ||
addErrorMessage(t('Unable to remove configuration')); | ||
} | ||
}; | ||
|
||
handleUninstallClick = () => { | ||
//TODO: Analytics | ||
}; | ||
|
||
enablePlugin = async () => { | ||
try { | ||
addLoadingMessage(t('Enabling...')); | ||
await this.pluginUpdate({enabled: true}); | ||
addSuccessMessage(t('Configuration was enabled')); | ||
this.props.onEnablePlugin(this.props.projectItem.projectId); | ||
} catch (_err) { | ||
addErrorMessage(t('Unable to enable configuration')); | ||
} | ||
}; | ||
|
||
get projectForBadge(): AvatarProject { | ||
//this function returns the project as needed for the ProjectBadge component | ||
const {projectItem} = this.props; | ||
return { | ||
slug: projectItem.projectSlug, | ||
platform: projectItem.projectPlatform ? projectItem.projectPlatform : undefined, | ||
}; | ||
} | ||
|
||
render() { | ||
const {className, plugin, organization, projectItem} = this.props; | ||
|
||
return ( | ||
<Container> | ||
<Access access={['org:integrations']}> | ||
{({hasAccess}) => ( | ||
<IntegrationFlex className={className}> | ||
<IntegrationItemBox> | ||
<ProjectBadge project={this.projectForBadge} /> | ||
</IntegrationItemBox> | ||
<div> | ||
{!projectItem.enabled ? ( | ||
<Button size="small" priority="primary" onClick={this.enablePlugin}> | ||
{t('Enable')} | ||
</Button> | ||
) : ( | ||
<StyledButton | ||
borderless | ||
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. Why borderless in this context? 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. @evanpurkhiser It definitely doesn't look good here, that's for sure. We really just copy-pasted these buttons from the existing integrations page where it looks better: Right now, we are waiting for a proper design from Chris. We'll tune up all the styling on this page once we know what it should look like. |
||
icon="icon-settings" | ||
disabled={!hasAccess} | ||
to={`/settings/${organization.slug}/projects/${projectItem.projectSlug}/plugins/${plugin.id}/`} | ||
data-test-id="integration-configure-button" | ||
> | ||
{t('Configure')} | ||
</StyledButton> | ||
)} | ||
</div> | ||
<div> | ||
<Confirm | ||
priority="danger" | ||
onConfirming={this.handleUninstallClick} | ||
disabled={!hasAccess} | ||
confirmText="Delete Installation" | ||
onConfirm={() => this.handleReset()} | ||
message={this.getConfirmMessage()} | ||
> | ||
<StyledButton | ||
disabled={!hasAccess} | ||
borderless | ||
icon="icon-trash" | ||
data-test-id="integration-remove-button" | ||
> | ||
{t('Uninstall')} | ||
</StyledButton> | ||
</Confirm> | ||
</div> | ||
</IntegrationFlex> | ||
)} | ||
</Access> | ||
</Container> | ||
); | ||
} | ||
} | ||
|
||
export default withApi(InstalledPlugin); | ||
|
||
const Container = styled('div')` | ||
margin: 10px; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
color: ${p => p.theme.gray2}; | ||
`; | ||
|
||
const IntegrationFlex = styled('div')` | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
const IntegrationItemBox = styled('div')` | ||
flex: 1; | ||
box-sizing: border-box; | ||
display: flex; | ||
flex-direction: row; | ||
min-width: 0; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ export default class PluginRow extends React.Component<Props> { | |
<ProviderDetails> | ||
<Status enabled={this.isEnabled} /> | ||
<StyledLink | ||
to={`/settings/${slug}/plugins/${plugin.slug}?tab=configurations`} | ||
to={`/settings/${slug}/plugins/${plugin.slug}/?tab=configurations`} | ||
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. had to add the trailing |
||
>{`${plugin.projectList.length} Configurations`}</StyledLink> | ||
</ProviderDetails> | ||
</Container> | ||
|
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.
Needed to add this so we can render the project badge