-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement space create- and rename-actions * Add delete action * Add unit tests Co-authored-by: Jan <jackermann@owncloud.com> Co-authored-by: Pascal Wengerter <pwengerter@owncloud.com>
- Loading branch information
1 parent
1e7b1a1
commit 024ff8c
Showing
9 changed files
with
533 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Enhancement: Add spaces actions | ||
|
||
We added the following actions to the spaces overview: | ||
|
||
* Create a new space | ||
* Rename a space | ||
* Delete a space | ||
|
||
https://github.com/owncloud/web/pull/6254 | ||
https://github.com/owncloud/web/issues/6255 |
62 changes: 62 additions & 0 deletions
62
packages/web-app-files/src/mixins/spaces/actions/delete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { mapActions } from 'vuex' | ||
|
||
export default { | ||
computed: { | ||
$_delete_items() { | ||
return [ | ||
{ | ||
name: 'delete', | ||
icon: 'delete-bin-5', | ||
label: () => { | ||
return this.$gettext('Delete') | ||
}, | ||
handler: this.$_delete_showModal, | ||
isEnabled: () => true, | ||
componentType: 'oc-button', | ||
class: 'oc-files-actions-delete-trigger' | ||
} | ||
] | ||
} | ||
}, | ||
methods: { | ||
...mapActions([ | ||
'createModal', | ||
'hideModal', | ||
'setModalInputErrorMessage', | ||
'showMessage', | ||
'toggleModalConfirmButton' | ||
]), | ||
|
||
$_delete_showModal(space) { | ||
const modal = { | ||
variation: 'danger', | ||
title: this.$gettext('Delete space') + ' ' + space.name, | ||
cancelText: this.$gettext('Cancel'), | ||
confirmText: this.$gettext('Delete'), | ||
icon: 'alarm-warning', | ||
message: this.$gettext('Are you sure you want to delete this space?'), | ||
hasInput: false, | ||
onCancel: this.hideModal, | ||
onConfirm: () => this.$_delete_deleteSpace(space.id) | ||
} | ||
|
||
this.createModal(modal) | ||
}, | ||
|
||
$_delete_deleteSpace(id) { | ||
return this.graph.drives | ||
.deleteDrive(id) | ||
.then(() => { | ||
this.hideModal() | ||
this.loadSpacesTask.perform(this) | ||
}) | ||
.catch((error) => { | ||
this.showMessage({ | ||
title: this.$gettext('Deleting space failed…'), | ||
desc: error, | ||
status: 'danger' | ||
}) | ||
}) | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
packages/web-app-files/src/mixins/spaces/actions/rename.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { mapActions } from 'vuex' | ||
|
||
export default { | ||
computed: { | ||
$_rename_items() { | ||
return [ | ||
{ | ||
name: 'rename', | ||
icon: 'edit', | ||
label: () => { | ||
return this.$gettext('Rename') | ||
}, | ||
handler: this.$_rename_showModal, | ||
isEnabled: () => true, | ||
componentType: 'oc-button', | ||
class: 'oc-files-actions-rename-trigger' | ||
} | ||
] | ||
} | ||
}, | ||
methods: { | ||
...mapActions([ | ||
'createModal', | ||
'hideModal', | ||
'setModalInputErrorMessage', | ||
'showMessage', | ||
'toggleModalConfirmButton' | ||
]), | ||
|
||
$_rename_showModal(space) { | ||
const modal = { | ||
variation: 'passive', | ||
title: this.$gettext('Rename space') + ' ' + space.name, | ||
cancelText: this.$gettext('Cancel'), | ||
confirmText: this.$gettext('Rename'), | ||
hasInput: true, | ||
inputLabel: this.$gettext('Space name'), | ||
inputValue: space.name, | ||
onCancel: this.hideModal, | ||
onConfirm: (name) => this.$_rename_renameSpace(space.id, name), | ||
onInput: this.$_rename_checkName | ||
} | ||
|
||
this.createModal(modal) | ||
}, | ||
|
||
$_rename_checkName(name) { | ||
if (name.trim() === '') { | ||
this.setModalInputErrorMessage(this.$gettext('Space name cannot be empty')) | ||
} | ||
}, | ||
|
||
$_rename_renameSpace(id, name) { | ||
return this.graph.drives | ||
.updateDrive(id, { name }, {}) | ||
.then(() => { | ||
this.hideModal() | ||
this.loadSpacesTask.perform(this) | ||
}) | ||
.catch((error) => { | ||
this.showMessage({ | ||
title: this.$gettext('Renaming space failed…'), | ||
desc: error, | ||
status: 'danger' | ||
}) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.