Skip to content

Commit

Permalink
fix: delete project (#3393)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Feb 8, 2024
1 parent 5f13624 commit be544e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions frontend/common/providers/OrganisationProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const OrganisationProvider = class extends Component {
users: OrganisationStore.getUsers(),
}
ES6Component(this)
if (props.onRemoveProject) {
this.listenTo(OrganisationStore, 'removed', props.onRemoveProject)
}

this.listenTo(OrganisationStore, 'change', () => {
this.setState({
groups: UserGroupStore.getGroups(),
Expand Down
6 changes: 5 additions & 1 deletion frontend/web/components/ProjectManageWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ const ProjectManageWidget: FC<SegmentsPageType> = ({
}, [handleCreateProjectClick, router.route.location])

return (
<OrganisationProvider>
<OrganisationProvider
onRemoveProject={() => {
toast('Your project has been removed')
}}
>
{({
isLoading,
projects,
Expand Down
8 changes: 1 addition & 7 deletions frontend/web/components/pages/ProjectSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ const ProjectSettingsPage = class extends Component {
AppActions.getProject(this.props.match.params.projectId)
}
}

onRemove = () => {
toast('Your project has been removed')
this.context.router.history.replace('/projects')
}

confirmRemove = (project, cb) => {
openModal(
'Delete Project',
Expand Down Expand Up @@ -163,7 +157,6 @@ const ProjectSettingsPage = class extends Component {
<div className='app-container container'>
<ProjectProvider
id={this.props.match.params.projectId}
onRemove={this.onRemove}
onSave={this.onSave}
>
{({ deleteProject, editProject, isLoading, isSaving, project }) => {
Expand Down Expand Up @@ -430,6 +423,7 @@ const ProjectSettingsPage = class extends Component {
<Button
onClick={() =>
this.confirmRemove(project, () => {
this.context.router.history.replace('/projects')
deleteProject(this.props.match.params.projectId)
})
}
Expand Down

0 comments on commit be544e2

Please sign in to comment.