Skip to content
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

Allow to restore assets after being deleted ( datasets, organizations and reuses ). #1901

Merged

Conversation

Projects
None yet
2 participants
@micael-grilo
Copy link
Contributor

micael-grilo commented Sep 28, 2018

Context:
When I delete an asset ( dataset, organization, reuse), I want to be able to restore it.

Resume:
Assets can be accidentally deleted, and there's no way to easily restore them, neither through API or through Admin area. This PR adds:

  • Ability to restore a asset through API:
    -- Sending a POST with the deleted field Empty ("deleted:"null") will restore the asset.

  • Change Admin Area to accommodate this new feature.
    -- In admin area you can now easily restore an asset that was deleted.
    image

@noirbizarre noirbizarre added this to the 1.6.0 milestone Sep 28, 2018

@noirbizarre
Copy link
Member

noirbizarre left a comment

Interesting feature and way to implement it.
Just fix the review comments and remove or split out the badge part.
Thanks 👌
NB: Don't forget to provide a CHANGELOG entry and to rebase your branch on the current master

},
methods: {
confirm() {
var restore_dataset = this.dataset;

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

Use const instead of var because we are trying to use ES6 as much as possible

},
methods: {
confirm() {
var restore_organization = this.organization;

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

Same here

},
methods: {
confirm() {
var restore_reuse = this.reuse;

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

Same here

@@ -203,6 +213,12 @@ export default {
{dataset: this.dataset}
);
},
confirm_restore() {
var m = this.$root.$modal(

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

No need to store the reference m, it's not used later.

@@ -258,6 +274,8 @@ export default {
class: 'danger',
label: this._('Deleted')
}];
} else {
this.badges = [];

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

I don't think this is related to this pull-request. Remove it or submit another one for this case

This comment has been minimized.

Copy link
@micael-grilo

micael-grilo Sep 29, 2018

Author Contributor

image
The purpose of this line is to clear the "Deleted" red badge.

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Oct 1, 2018

Member

OK I understand 👍
But on some datasets/reuses/organization, there is more than one badge (more than only the deleted badge), you may need to do some filtering to only remove the deleted badge

@@ -189,6 +205,8 @@ export default {
class: 'danger',
label: this._('Deleted')
}];
} else {
this.badges = [];

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

Same, not related

API.organizations.update_organization(
{org: this.organization.id, payload: restore_organization},
(response) => {
this.organization.fetch();

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

To avoid an extra request, you can directly use the response payload to update the organization: this.organization.on_fetched(reponse)

restore_dataset.deleted = null;
API.datasets.update_dataset({dataset: this.dataset.id, payload: restore_dataset},
(response) => {
this.dataset.fetch();

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

To avoid an extra request, you can directly use the response payload to update the dataset: this.dataset.on_fetched(reponse)

restore_reuse.deleted = null;
API.reuses.update_reuse({reuse: this.reuse.id, payload: restore_reuse},
(response) => {
this.reuse.fetch();

This comment has been minimized.

Copy link
@noirbizarre

noirbizarre Sep 28, 2018

Member

To avoid an extra request, you can directly use the response payload to update the reuse: this.reuse.on_fetched(reponse)

@noirbizarre noirbizarre modified the milestones: 1.6.0, 1.6.1 Oct 4, 2018

noirbizarre added some commits Oct 4, 2018

@noirbizarre noirbizarre merged commit 60a2e33 into opendatateam:master Oct 4, 2018

3 checks passed

ci/circleci: assets Your tests passed on CircleCI!
Details
ci/circleci: dist Your tests passed on CircleCI!
Details
ci/circleci: python Your tests passed on CircleCI!
Details

@micael-grilo micael-grilo deleted the amagovpt:feature/allow_assets_restore branch Oct 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.