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

Introduce uninstalling #67

Merged
merged 5 commits into from May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 11 additions & 14 deletions lib/Controller/MarketController.php
Expand Up @@ -57,7 +57,7 @@ public function categories() {
return $this->marketService->getCategories();
} catch (\Exception $ex) {
return new DataResponse(['message' => $ex->getMessage() ],
Http::STATUS_NO_CONTENT);
Http::STATUS_SERVICE_UNAVAILABLE);
}
}
/**
Expand All @@ -70,61 +70,58 @@ public function index() {
return $this->queryData();
} catch (\Exception $ex) {
return new DataResponse(['message' => $ex->getMessage() ],
Http::STATUS_NO_CONTENT);
Http::STATUS_SERVICE_UNAVAILABLE);
}
}

/**
* @param string $appId
* @return array
* @return array | DataResponse
*/
public function install($appId) {
try {
$this->marketService->installApp($appId);
return [
'error' => false,
'message' => "App $appId installed successfully"
];
} catch(\Exception $ex) {
return ['error' => true,
return new DataResponse([
'message' => $ex->getMessage()
];
], Http::STATUS_BAD_REQUEST);
}
}

/**
* @param string $appId
* @return array
* @return array | DataResponse
*/
public function uninstall($appId) {
try {
$this->marketService->uninstallApp($appId);
return [
'error' => false,
'message' => "App $appId uninstalled successfully"
];
} catch(\Exception $ex) {
return ['error' => true,
return new DataResponse([
'message' => $ex->getMessage()
];
], Http::STATUS_BAD_REQUEST);
}
}

/**
* @param string $appId
* @return array
* @return array | DataResponse
*/
public function update($appId) {
try {
$this->marketService->updateApp($appId);
return [
'error' => false,
'message' => "App $appId updated successfully"
];
} catch(\Exception $ex) {
return ['error' => true,
return new DataResponse([
'message' => $ex->getMessage()
];
], Http::STATUS_BAD_REQUEST);
}
}

Expand Down
7 changes: 6 additions & 1 deletion lib/MarketService.php
Expand Up @@ -241,7 +241,12 @@ public function updateApp($appId) {
* @param string $appId
*/
public function uninstallApp($appId) {
\OC_App::removeApp($appId);
if ($this->appManager->isShipped($appId)) {
throw new AppManagerException('Shipped apps cannot be uninstalled');
}
if (!\OC_App::removeApp($appId)) {
throw new AppManagerException('App could not be uninstalled. Please check the server logs.');
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/App.vue
Expand Up @@ -9,9 +9,12 @@
</template>

<script>
import Navigation from './components/Navigation.vue';
import Navigation from './components/Navigation.vue'

export default {
mounted: function () {
this.$store.dispatch('FETCH_APPLICATIONS')
},
components: {
Navigation
}
Expand Down
83 changes: 50 additions & 33 deletions src/components/Details.vue
Expand Up @@ -51,28 +51,38 @@
t.missingDep

.uk-card-footer
div(v-if="!updateable && !updating")
// Installation
button.uk-button.uk-button-primary.uk-align-right.uk-margin-remove-bottom.uk-margin-small-left.uk-position-relative(:disabled="!installable || loading", @click="install")
span(v-if="installing")
.uk-position-small.uk-position-center-left(uk-spinner, uk-icon="icon: spinner; ratio: 0.8")
| &nbsp;&nbsp;&nbsp;&nbsp; {{ t('installing') }}
span(v-else-if="loading")
.uk-position-small.uk-position-center-left(uk-spinner, uk-icon="icon: spinner; ratio: 0.8")
| &nbsp;&nbsp;&nbsp;&nbsp; {{ t('loading') }}
span(v-else-if="installed")
| {{ t('installed') }}
span(v-else)
| {{ t('install') }}

button.uk-button.uk-button-primary.uk-align-right.uk-margin-remove-bottom.uk-margin-small-left.uk-position-relative(v-if="updateable", @click="update", :disabled="updating")
span(v-if="updating")
div(v-if="loading")
button.uk-button.uk-button-primary.uk-align-right.uk-margin-remove-bottom.uk-margin-small-left.uk-position-relative(disabled)
.uk-position-small.uk-position-center-left(uk-spinner, uk-icon="icon: spinner; ratio: 0.8")
| &nbsp;&nbsp;&nbsp;&nbsp; {{ t('updating') }}
span(v-else)
| {{ t('update') }}

button.uk-button.uk-button-default.uk-align-left.uk-margin-remove-bottom.uk-margin-small-left(v-if="installed && !loading", disabled) {{ t('remove') }}
| &nbsp;&nbsp;&nbsp;&nbsp; {{ t('loading') }}

div(v-else)
// Install
div(v-if="!installed")
button.uk-button.uk-button-primary.uk-align-right.uk-margin-remove-bottom.uk-margin-small-left.uk-position-relative(:disabled="processing && !installable", @click="install")
span(v-if="processing")
.uk-position-small.uk-position-center-left(uk-spinner, uk-icon="icon: spinner; ratio: 0.8")
| &nbsp;&nbsp;&nbsp;&nbsp; {{ t('installing') }}
span(v-else)
| {{ t('install') }}

// Uninstall
div(v-else)
button.uk-button.uk-button-default.uk-align-right.uk-margin-remove-bottom.uk-margin-small-left(:disabled="processing", @click="uninstall")
span(v-if="processing")
.uk-position-small.uk-position-center-left(uk-spinner, uk-icon="icon: spinner; ratio: 0.8")
| &nbsp;&nbsp;&nbsp;&nbsp; {{ t('uninstalling') }}
span(v-else)
| {{ t('uninstall') }}

// Update
div(v-if="updateable")
button.uk-button.uk-button-primary.uk-align-right.uk-margin-remove-bottom.uk-margin-small-left.uk-position-relative(:disabled="processing", @click="update")
span(v-if="processing")
.uk-position-small.uk-position-center-left(uk-spinner, uk-icon="icon: spinner; ratio: 0.8")
| &nbsp;&nbsp;&nbsp;&nbsp; {{ t('updating') }}
span(v-else)
| {{ t('update') }}
</template>

<script>
Expand All @@ -83,9 +93,6 @@
components: {
Rating
},
mounted: function () {
this.$store.dispatch('FETCH_APPLICATIONS')
},
computed: {
loading() {
return this.$store.state.applications.loading
Expand All @@ -101,19 +108,18 @@
}
},
installed() {
return this.application.installed && !this.installing
return this.application.installed && !this.processing
},
installable() {
return this.application.release && this.application.release.canInstall && !this.installed && !this.installing
},
installing() {
return _.contains(this.$store.state.installing, this.application.id)
return this.application.release && this.application.release.canInstall && !this.installed && !this.processing
},
updateable() {
return this.application.installed && this.application.updateInfo !== false
},
updating() {
return _.contains(this.$store.state.updating, this.application.id)

// Any kind of installing, updating or uninstalling process
processing() {
return _.contains(this.$store.state.processing, this.application.id)
}
},
filters: {
Expand All @@ -123,10 +129,21 @@
},
methods: {
install () {
this.$store.dispatch('INSTALL_APPLICATION', this.application.id)
this.$store.dispatch('PROCESS_APPLICATION', [this.application.id, 'install'])
},
uninstall () {

UIkit.modal.confirm(this.t('Are you sure you want to remove <strong>%{appName}</strong> from your system?', {appName : this.application.name }), {
center : true,
escClose : true
}).then(() => {
this.$store.dispatch('PROCESS_APPLICATION', [this.application.id, 'uninstall'])
}, function () {
return null
});
},
update () {
this.$store.dispatch('UPDATE_APPLICATION', this.application.id)
this.$store.dispatch('PROCESS_APPLICATION', [this.application.id, 'update'])
},
t (string, interpolation) {
if (!interpolation) {
Expand Down
5 changes: 1 addition & 4 deletions src/components/List.vue
Expand Up @@ -5,7 +5,7 @@
Tile(v-for="application in applications", :application="application", :key="application.id")

transition(name="fade")
.uk-card.uk-card-default.uk-card-body.uk-position-center(v-if="applications.length === 0 && !loading")
.uk-card.uk-card-default.uk-card-body.uk-position-center(v-if="applications.length === 0 && !loading && !failed")
p.uk-text-center {{ t('No apps in %{category}', { category }) }}
</template>

Expand All @@ -16,9 +16,6 @@
components: {
Tile
},
mounted: function () {
this.$store.dispatch('FETCH_APPLICATIONS')
},
computed: {
loading() {
return this.$store.state.applications.loading
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation.vue
Expand Up @@ -21,7 +21,7 @@

<script>
export default {
mounted: function () {
mounted () {
this.$store.dispatch('FETCH_CATEGORIES')
},
methods: {
Expand Down
13 changes: 5 additions & 8 deletions src/components/UpdateList.vue
Expand Up @@ -24,8 +24,8 @@
span(uk-icon="icon: arrow-right").uk-margin-small-left.uk-margin-small-right
span {{ application.updateInfo }}
td
button.uk-button.uk-button-primary.uk-align-right.uk-margin-remove.uk-position-relative(@click="update(application.id)", :disabled="updating(application.id)")
span(v-if="updating(application.id)")
button.uk-button.uk-button-primary.uk-align-right.uk-margin-remove.uk-position-relative(@click="update(application.id)", :disabled="processing(application.id)")
span(v-if="processing(application.id)")
span.uk-position-small.uk-position-center-left(uk-spinner, uk-icon="icon: spinner; ratio: 0.8")
span.uk-margin-small-left &nbsp;&nbsp; {{ t('updating') }}
span(v-else)
Expand All @@ -46,15 +46,12 @@
components: {
Tile
},
mounted () {
this.$store.dispatch('FETCH_APPLICATIONS')
},
methods: {
update (id) {
this.$store.dispatch('UPDATE_APPLICATION', id)
this.$store.dispatch('PROCESS_APPLICATION', [id, 'update'])
},
updating(id) {
return _.contains(this.$store.state.updating, id)
processing(id) {
return _.contains(this.$store.state.processing, id)
},
t(string) {
return this.$gettext(string);
Expand Down