Skip to content

Commit

Permalink
Remove and change primary storage location modals updated and setting…
Browse files Browse the repository at this point in the history
…s updated in server restart function
  • Loading branch information
LianaHarris360 committed Nov 14, 2022
1 parent bdde663 commit d3913fd
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
@submit="handleSubmit"
@cancel="$emit('cancel')"
>
<p>{{ $tr('newStorageLocationDescription') }}</p>
<p class="description">
{{ $tr('newStorageLocationDescription') }}
</p>
<KTextbox
ref="autoDownloadLimit"
v-model="path"
Expand Down Expand Up @@ -98,3 +100,12 @@
};
</script>


<style lang="scss" scoped>
.description {
margin-top: 0;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@
:title="$tr('changePrimaryLocation')"
:submitText="coreString('continueAction')"
:cancelText="coreString('cancelAction')"
@submit="$emit('submit')"
@submit="handleSubmit"
@cancel="$emit('cancel')"
>
<p>{{ $tr('primaryLocationChangeDescription') }}</p>
<p class="description">
{{ $tr('primaryLocationChangeDescription') }}
</p>
<KRadioButton
v-for="path in storageLocations"
:key="path.index"
v-model="selectedPath"
:value="path.path"
:label="path.path"
/>
</KModal>

</template>
Expand All @@ -20,6 +29,30 @@
export default {
name: 'PrimaryStorageLocationModal',
mixins: [commonCoreStrings],
props: {
storageLocations: {
type: Array,
required: true,
},
primaryPath: {
type: String,
required: true,
},
},
data() {
return {
selectedPath: this.primaryPath,
};
},
methods: {
handleSubmit() {
if (this.selectedPath === this.primaryPath) {
this.$emit('cancel');
return;
}
this.$emit('submit', this.selectedPath);
},
},
$trs: {
changePrimaryLocation: {
message: 'Change primary storage location',
Expand All @@ -33,3 +66,12 @@
};
</script>


<style lang="scss" scoped>
.description {
margin-top: 0;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@
:title="$tr('removeStorageLocation')"
:submitText="coreString('continueAction')"
:cancelText="coreString('cancelAction')"
@submit="$emit('submit')"
@submit="handleSubmit"
@cancel="$emit('cancel')"
>
<p>{{ $tr('removeStorageLocationDescription') }}</p>
<p class="description">
{{ $tr('removeStorageLocationDescription') }}
</p>
<p>{{ $tr('deleteFilesDescription') }}</p>
<KRadioButton
v-for="path in storageLocations"
:key="path.index"
v-model="selectedPath"
:value="path"
:label="path"
/>
</KModal>

</template>
Expand All @@ -17,10 +26,32 @@
<script>
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import { getPathPermissions } from './api';
export default {
name: 'RemoveStorageLocationModal',
mixins: [commonCoreStrings],
props: {
storageLocations: {
type: Array,
required: true,
},
},
data() {
return {
selectedPath: this.storageLocations[0],
};
},
methods: {
handleSubmit() {
getPathPermissions(this.selectedPath).then(permissions => {
const writable = permissions.data.writable;
if (permissions.data.directory) {
this.$emit('submit', this.selectedPath, writable);
}
});
},
},
$trs: {
removeStorageLocation: {
message: 'Remove storage location',
Expand All @@ -40,3 +71,12 @@
};
</script>


<style lang="scss" scoped>
.description {
margin-top: 0;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
@submit="handleSubmit"
@cancel="$emit('cancel')"
>
<p v-if="changedSetting === 'primary'">
{{ $tr('selectedPath', { path: path.name }) }}
<p v-if="changedSetting === 'add'" class="description">
{{ $tr('selectedPath', { path: path.path }) }}
</p>
<p>{{ getMessage() }}</p>
<div v-if="changedSetting === 'primary'">
<p class="description">
{{ getMessage() }}
</p>
<div v-if="changedSetting === 'add' && path.writable === true">
<KCheckbox
:checked="confirmationChecked"
:label="$tr('makePrimary')"
:description="$tr('labelPrimary')"
/>
<p :style="{ color: $themeTokens.textDisabled }">
{{ $tr('labelPrimary') }}
</p>
</div>
</KModal>

Expand Down Expand Up @@ -62,7 +62,7 @@
return message + this.$tr('serverRestartDecription');
},
handleSubmit() {
if (this.changedSetting === 'primary') {
if (this.changedSetting === 'add') {
this.$emit('submit', this.confirmationChecked);
} else {
this.$emit('submit');
Expand Down Expand Up @@ -107,3 +107,12 @@
};
</script>


<style lang="scss" scoped>
.description {
margin-top: 0;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@
/>
</div>

<div v-if="browserLocationMatchesServerURL">
<div v-show="browserLocationMatchesServerURL && (secondaryStorageLocations.length > 0)">
<h2>
{{ $tr('secondaryStorage') }}
</h2>
<p class="info-description">
<p v-show="!multipleReadOnlyPaths" class="info-description">
{{ $tr('secondaryStorageDescription') }}
</p>
<p v-for="path in secondaryStorageLocations" :key="path.index">
Expand Down Expand Up @@ -253,8 +253,10 @@

<PrimaryStorageLocationModal
v-if="showChangePrimaryLocationModal"
:primaryPath="primaryStorageLocation"
:storageLocations="storageLocations.filter(el => el.writable)"
@cancel="showChangePrimaryLocationModal = false"
@submit="handleSubmit"
@submit="changePrimaryLocation"
/>

<AddStorageLocationModal
Expand All @@ -266,8 +268,9 @@

<RemoveStorageLocationModal
v-if="showRemoveStorageLocationModal"
:storageLocations="secondaryStorageLocations"
@cancel="showRemoveStorageLocationModal = false"
@submit="handleSubmit"
@submit="removeStorageLocation"
/>

<ServerRestartModal
Expand Down Expand Up @@ -619,8 +622,15 @@
this.showAddStorageLocationModal = false;
}
},
handleSubmit(e) {
e.preventDefault();
changePrimaryLocation(path) {
const writable = true;
this.restartPath = {
path,
writable,
};
this.restartSetting = 'primary';
this.showRestartModal = true;
this.showChangePrimaryLocationModal = false;
},
addStorageLocation(path, writable) {
this.restartPath = {
Expand All @@ -631,22 +641,43 @@
this.restartSetting = 'add';
this.showRestartModal = true;
this.showAddStorageLocationModal = false;
this.showAddStorageServerRestartModal = true;
},
removeStorageLocation(path, writable) {
this.restartPath = {
path,
writable,
};
handleServerRestart() {
this.restartSetting = 'remove';
this.showRestartModal = true;
this.showRemoveStorageLocationModal = false;
},
handleServerRestart(confirmationChecked) {
this.showRestartModal = false;
if (this.restartSetting === 'add') {
this.storageLocations.push(this.restartPath);
this.secondaryStorageLocations.push(this.restartPath.path);
if (confirmationChecked === true) {
this.primaryStorageLocation = this.restartPath.path;
}
this.handleClickSave();
} else if (this.restartSetting === 'remove') {
this.storageLocations = this.storageLocations.filter(
el => el.path !== this.restartPath.path
);
// TODO: remove location
this.secondaryStorageLocations = this.secondaryStorageLocations.filter(
el => el !== this.restartPath.path
);
this.handleClickSave();
} else if (this.restartSetting === 'primary') {
// TODO: set primary location
this.secondaryStorageLocations.push(this.primaryStorageLocation);
this.secondaryStorageLocations = this.secondaryStorageLocations.filter(
el => el !== this.restartPath.path
);
this.primaryStorageLocation = this.restartPath.path;
this.handleClickSave();
}
},
isWritablePath(path) {
Expand All @@ -656,6 +687,13 @@
}
return '';
},
multipleReadOnlyPaths() {
if (this.storageLocations.filter(el => el.writeable).length === 0) {
return true;
} else {
return false;
}
},
},
$trs: {
browserDefaultLanguage: {
Expand Down

0 comments on commit d3913fd

Please sign in to comment.