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

resolve file duplicate name on creating new file #7555

Merged
merged 3 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Propose file name while creating a new file
AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved

We've added the possibility while creating a new file or folder to via the 'New' button
AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved
to propose an unused name.
For example: When a folder with the name 'New folder' already exists, the name New folder (1) will be suggested.

https://github.com/owncloud/web/pull/7555
https://github.com/owncloud/web/issues/7539
24 changes: 21 additions & 3 deletions packages/web-app-files/src/components/AppBar/CreateAndUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ import { useUploadHelpers } from '../../composables/upload'
import { SHARE_JAIL_ID } from '../../services/folder'
import { bus } from 'web-pkg/src/instance'
import { buildWebDavSpacesPath } from 'web-client/src/helpers'
import { resolveFileNameDuplicate, extractNameWithoutExtension } from '../../helpers/resource'

export default defineComponent({
components: {
Expand Down Expand Up @@ -354,16 +355,24 @@ export default defineComponent({
openAction = null,
addAppProviderFile = false
) {
const defaultName = isFolder
? this.$gettext('New folder')
: this.$gettext('New file') + (this.areFileExtensionsShown ? `.${ext}` : '')
const checkInputValue = (value) => {
this.setModalInputErrorMessage(
isFolder
? this.checkNewFolderName(value)
: this.checkNewFileName(this.areFileExtensionsShown ? value : `${value}.${ext}`)
)
}
let defaultName = isFolder
? this.$gettext('New folder')
: this.$gettext('New file') + `.${ext}`

if (this.files.some((f) => f.name === defaultName)) {
defaultName = resolveFileNameDuplicate(defaultName, !isFolder ? ext : '', this.files)
AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved
}

if (!this.areFileExtensionsShown) {
defaultName = extractNameWithoutExtension({ name: defaultName, extension: ext } as any)
}

// Sets action to be executed after creation of the file
if (!isFolder) {
Expand Down Expand Up @@ -841,44 +850,53 @@ export default defineComponent({
#create-list {
li {
border: 1px solid transparent;

AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved
button {
gap: 10px;
justify-content: left;
width: 100%;
}
}

.create-list-folder {
border-bottom: 1px solid var(--oc-color-border);
}

.create-list-folder button {
margin-bottom: 8px;
}

.create-list-file:nth-child(2) button {
margin-top: 6px;
}
}

#upload-list,
#new-file-menu-drop {
min-width: 230px;
}

#create-list,
#upload-list,
#new-file-menu-drop {
.oc-icon-m svg {
height: 100% !important;
}
}

#clipboard-btns {
flex-flow: inherit;

:nth-child(1) {
border-right: 0px !important;
white-space: nowrap;
}

:nth-child(2) {
border-left: 0px !important;
}
}

.create-and-upload-actions {
gap: var(--oc-space-small);
@media only screen and (min-width: 1000px) {
Expand Down
1 change: 1 addition & 0 deletions packages/web-runtime/src/services/auth/userManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export class UserManager extends OidcUserManager {
await this.clientService.owncloudSdk.users.getUser(login.id),
await this.clientService.owncloudSdk.users.getUserGroups(login.id)
])
console.log(userGroups)
AlexAndBear marked this conversation as resolved.
Show resolved Hide resolved
this.store.commit('SET_USER', {
id: login.id,
uuid: graphUser?.data?.id || '',
Expand Down