Skip to content

Commit

Permalink
Merge branch 'feature/contextual-upload-modal' into 'devel'
Browse files Browse the repository at this point in the history
Feature/contextual upload modal

Closes #1105

See merge request sds-dev/sd-connect/swift-browser-ui!147
  • Loading branch information
Hang Le committed Aug 16, 2023
2 parents b4dc23b + 4ffa00a commit 31b7c70
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 154 deletions.
4 changes: 4 additions & 0 deletions .github/config/.finnishwords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ alaviiva
alikansio
alikansion
alikansiot
alkanut
alla
aloitettiin
aloitettu
Expand Down Expand Up @@ -275,6 +276,7 @@ minuutin
minuutteja
mitätöi
muiden
muissa
muita
mukaan
muokata
Expand All @@ -288,6 +290,7 @@ muutamia
muutettiin
muuttaa
muuttaaksesi
myöhemmin
myös
määrä
määrästä
Expand Down Expand Up @@ -393,6 +396,7 @@ poudan
profiili
projekteihin
projekteille
projekteissa
projekteja
projekti
projektia
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (GL #1083) Disabled `create folder` when inside containers to avoid user confusion that they can create subfolders
- (GL #1069) Forbid special characters in container names
- (GL #1074) Updated `/api/{project}` endpoint to check for `last_modified` values before returning the container list
- (GL #1105) Upload modal restricted to uploading to current container, or creating a new one in main container view

### Fixed

Expand Down
16 changes: 14 additions & 2 deletions swift_browser_ui_frontend/src/common/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ let default_translations = {
complete: "Uploading completed",
cancelled: "Uploading cancelled",
uploadedItems: "Uploaded items will be displayed soon",
addFiles: "Please add files to upload.",
error: "Upload couldn't start. Please try again later.",
},
close: "Close",
copy: " Copy",
Expand Down Expand Up @@ -278,7 +280,8 @@ let default_translations = {
},
encrypt: {
uploadFiles: "Upload files",
upload_step1: "Create a new folder or use existing ones.",
uploadDestination: "Destination folder: ",
upload_step1: "Create a new folder",
upload_step2: "Files to be uploaded",
multipleReceivers: "Additional encryption keys (public keys only)",
pubkey: "Paste public key",
Expand All @@ -298,6 +301,9 @@ let default_translations = {
},
uploadedFiles:
"Uploaded files will be shared with all project members in ",
uploadedToShared:
"and all members in other projects which " +
"have access to this shared folder.",
advancedOptions: "Advanced encryption options",
enReady:
"Encryption engine is ready. Refresh the " +
Expand Down Expand Up @@ -582,6 +588,8 @@ let default_translations = {
complete: "Lähetys on valmis",
cancelled: "Lähetys peruutettu",
uploadedItems: "Lähetetyt tiedostot näytetään pian",
addFiles: "Lisää ladattavat tiedostot.",
error: "Lataus ei alkanut. Yritä myöhemmin uudelleen.",
},
close: "Sulje",
copy: " Kopioi",
Expand Down Expand Up @@ -653,7 +661,8 @@ let default_translations = {
},
encrypt: {
uploadFiles: "Lataa tiedostoja",
upload_step1: "Luo uusi kansio tai käytä olemassa olevia.",
uploadDestination: "Kohdekansio: ",
upload_step1: "Luo uusi kansio",
upload_step2: "Ladattavat tiedostot",
multipleReceivers: "Lisää salausavaimia (vain julkiset avaimet)",
addkey: "Lisää avain",
Expand All @@ -673,6 +682,9 @@ let default_translations = {
},
uploadedFiles:
"Lähetetyt tiedostot jaetaan kaikille jäsenille projektissa ",
uploadedToShared:
"ja myös kaikille jäsenille muissa projekteissa, " +
"joilla on pääsy tähän jaettuun kansioon.",
advancedOptions: "Edistyneitä salausvaihtoehtoja",
enReady:
"Salausohjelma on valmiina. Päivitä " +
Expand Down
55 changes: 44 additions & 11 deletions swift_browser_ui_frontend/src/components/BrowserSecondaryNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<c-button
outlined
data-testid="create-folder"
:disabled="inContainer"
:disabled="container"
@click="toggleCreateFolderModal(false)"
@keyup.enter="toggleCreateFolderModal(true)"
>
Expand All @@ -92,7 +92,7 @@
</div>
<div class="nav-item">
<c-button
:disabled="isUploading"
:disabled="isUploading || !canUpload"
data-testid="upload-file"
@click="toggleUploadModal(false)"
@keyup.enter="toggleUploadModal(true)"
Expand All @@ -105,7 +105,10 @@
</template>

<script>
import { toggleCreateFolderModal } from "@/common/globalFunctions";
import {
toggleCreateFolderModal,
getAccessDetails,
} from "@/common/globalFunctions";
import { setPrevActiveElement } from "@/common/keyboardNavigation";
import { mdiInformationOutline } from "@mdi/js";
Expand All @@ -116,6 +119,7 @@ export default {
return {
copy: false,
path: mdiInformationOutline,
canUpload: false,
};
},
computed: {
Expand All @@ -134,8 +138,22 @@ export default {
isUploading() {
return this.$store.state.isUploading;
},
inContainer() {
return this.$route.params.container !== undefined;
owner() {
return this.$route.params.owner;
},
container() {
return this.$route.params.container;
},
client() {
return this.$store.state.client;
},
},
watch: {
container() {
this.checkIfCanReadWrite();
},
client() {
this.checkIfCanReadWrite();
},
},
methods: {
Expand Down Expand Up @@ -171,12 +189,27 @@ export default {
this.$store.commit("setFilesAdded", true);
this.$store.commit("toggleUploadModal", true);
if (keypress) setPrevActiveElement();
setTimeout(() => {
const uploadFolderInput = document
.querySelector("#upload-folder-input")
.shadowRoot.querySelector("input");
uploadFolderInput.focus();
}, 300);
if (!this.container) {
setTimeout(() => {
const uploadFolderInput = document
.querySelector("#upload-folder-input input");
uploadFolderInput.focus();
}, 300);
}
},
checkIfCanReadWrite: async function () {
//disable upload if user doesn't have rw perms
//in shared folder
if (!this.owner) this.canUpload = true;
else {
const share = await getAccessDetails(
this.active.id,
this.container,
this.owner,
);
if (!share.access) this.canUpload = false;
else this.canUpload = share.access.length === 2;
}
},
copyProjectId: function () {
const toastMessage = {
Expand Down
Loading

0 comments on commit 31b7c70

Please sign in to comment.