Skip to content

Commit

Permalink
v150 open file/folder
Browse files Browse the repository at this point in the history
  • Loading branch information
eldertek committed Dec 28, 2024
1 parent 52562f6 commit 84b2bd2
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 18 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release Notes

on:
release:
types: [created]

jobs:
update-release-notes:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Extract latest changelog and version
id: extract_changelog
run: |
# Get the latest version section (everything between the first and second '## ')
LATEST=$(sed -n '1,/^## /{/^## /p; /^## /q}' CHANGELOG.md | sed '1d')
# Extract current version number
CURRENT_VERSION=$(echo "$LATEST" | head -n 1 | sed 's/## \([0-9.]*\).*/\1/')
# Find previous version by getting the second version header
PREVIOUS_VERSION=$(sed -n '/^## [0-9]/{n;/^## /s/^## \([0-9.]*\).*/\1/p;q}' CHANGELOG.md)
# Prepare the content for GitHub Actions
echo "latest<<EOF" >> $GITHUB_ENV
echo "$LATEST" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "current_version=$CURRENT_VERSION" >> $GITHUB_ENV
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_ENV
- name: Update Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Combine latest release notes with comparison URL
REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}"
COMPARE_URL="${REPO_URL}/compare/v${previous_version}...v${current_version}"
BODY="# Latest Changes
${LATEST}
# Full Changelog
[Compare v${previous_version}...v${current_version}](${COMPARE_URL})"
# Get release ID
RELEASE_ID=$(gh api \
--method GET \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/tags/${{ github.event.release.tag_name }} \
| jq .id)
# Update release notes
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/$RELEASE_ID \
-f body="$BODY"
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.5.0 - 2024-12-28
### Added
- Open folder/file in new window from duplicate details page
### Fixed
- Fix an issue with user context not being set correctly in command line

## 1.4.1 - 2024-12-27
### Added
- Added a help tooltip to explain how to use the app
Expand Down
2 changes: 1 addition & 1 deletion js/duplicatefinder-main.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions lib/Command/FindDuplicates.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use OCA\DuplicateFinder\AppInfo\Application;
use OCA\DuplicateFinder\Service\FileDuplicateService;
use OCA\DuplicateFinder\Service\FileInfoService;
use OCA\DuplicateFinder\Service\ExcludedFolderService;
use OCA\DuplicateFinder\Service\OriginFolderService;
use OCA\DuplicateFinder\Utils\CMDUtils;
use OCP\Encryption\IManager;
use OCP\Files\NotFoundException;
Expand Down Expand Up @@ -46,6 +48,16 @@ class FindDuplicates extends Command
*/
private $fileDuplicateService;

/**
* @var ExcludedFolderService The excluded folder service instance.
*/
private $excludedFolderService;

/**
* @var OriginFolderService The origin folder service instance.
*/
private $originFolderService;

/**
* @var LoggerInterface The logger instance.
*/
Expand All @@ -64,6 +76,8 @@ class FindDuplicates extends Command
* @param IDBConnection $connection The database connection instance.
* @param FileInfoService $fileInfoService The file info service instance.
* @param FileDuplicateService $fileDuplicateService The file duplicate service instance.
* @param ExcludedFolderService $excludedFolderService The excluded folder service instance.
* @param OriginFolderService $originFolderService The origin folder service instance.
* @param LoggerInterface $logger The logger instance.
*/
public function __construct(
Expand All @@ -72,6 +86,8 @@ public function __construct(
IDBConnection $connection,
FileInfoService $fileInfoService,
FileDuplicateService $fileDuplicateService,
ExcludedFolderService $excludedFolderService,
OriginFolderService $originFolderService,
LoggerInterface $logger
) {
parent::__construct('duplicates:find-all');
Expand All @@ -80,6 +96,8 @@ public function __construct(
$this->connection = $connection;
$this->fileInfoService = $fileInfoService;
$this->fileDuplicateService = $fileDuplicateService;
$this->excludedFolderService = $excludedFolderService;
$this->originFolderService = $originFolderService;
$this->logger = $logger;
}

Expand Down Expand Up @@ -171,6 +189,11 @@ private function findAllDuplicates(array $paths): int
*/
private function findDuplicates(string $user, array $paths): void
{
// Set the user context for required services
$this->fileDuplicateService->setCurrentUserId($user);
$this->excludedFolderService->setUserId($user);
$this->originFolderService->setUserId($user);

$callback = function () {
pcntl_signal_dispatch();
return false; // Continue scanning
Expand Down
10 changes: 10 additions & 0 deletions lib/Service/ExcludedFolderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,14 @@ public function isPathExcluded(string $path): bool {
]);
return $isExcluded;
}

/**
* Set the user ID for the service.
*
* @param string|null $userId The user ID to set
*/
public function setUserId(?string $userId): void {
$this->userId = $userId ?? '';
$this->logger->debug('Set user ID: {userId}', ['userId' => $this->userId]);
}
}
88 changes: 71 additions & 17 deletions src/components/DuplicateFileDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@
<p><strong>{{ t('duplicatefinder', 'File') }} {{ index + 1 }}</strong></p>
<p><strong>{{ t('duplicatefinder', 'Path:') }}</strong> {{ normalizeItemPath(file.path) }}</p>
</div>
<button v-if="!file.isInOriginFolder" @click="deleteFile" class="delete-button">
{{ t('duplicatefinder', 'Delete') }}
</button>
<button v-else class="protected-button" disabled>
{{ t('duplicatefinder', 'Protected') }}
</button>
<div class="action-buttons">
<button @click="openInNewWindow" class="action-button">
{{ t('duplicatefinder', 'Open File') }}
</button>
<button @click="openFolderInNewWindow" class="action-button">
{{ t('duplicatefinder', 'Open Folder') }}
</button>
<button v-if="!file.isInOriginFolder" @click="deleteFile" class="delete-button">
{{ t('duplicatefinder', 'Delete') }}
</button>
<button v-else class="protected-button" disabled>
{{ t('duplicatefinder', 'Protected') }}
</button>
</div>
</div>
</template>
<script>
import { deleteFile } from '@/tools/api';
import { getPreviewImage, normalizeItemPath } from '@/tools/utils';
import { generateUrl } from '@nextcloud/router';
export default {
props: {
Expand All @@ -29,6 +38,24 @@ export default {
methods: {
getPreviewImage,
normalizeItemPath,
openInNewWindow() {
const url = generateUrl('/apps/files/files/' + this.file.nodeId + '?dir={dir}&openfile=true', {
dir: this.getParentPath()
});
window.open(url, '_blank');
},
openFolderInNewWindow() {
const url = generateUrl('/apps/files/files?dir={dir}', {
dir: this.getParentPath()
});
window.open(url, '_blank');
},
getParentPath() {
const path = this.file.path.replace(/^\/[^/]+\/files/, '');
const lastSlashIndex = path.lastIndexOf('/');
const parentPath = path.substring(0, lastSlashIndex);
return parentPath || '/';
},
async deleteFile() {
try {
console.log('DuplicateFileDisplay: Deleting file:', this.file);
Expand Down Expand Up @@ -84,6 +111,26 @@ export default {
background-color: #e43f51;
}
.action-buttons {
display: flex;
gap: 8px;
align-items: center;
}
.action-button {
background-color: var(--color-primary);
color: #fff;
border: none;
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.action-button:hover {
background-color: var(--color-primary-dark);
}
.protected-button {
background-color: #ccc;
color: #666;
Expand All @@ -96,7 +143,7 @@ export default {
/* Desktop styles */
@media (min-width: 801px) {
.delete-button, .protected-button {
.action-buttons {
position: absolute;
right: 10px;
top: 50%;
Expand All @@ -105,21 +152,22 @@ export default {
}
}
/* Mobile stles */
/* Mobile styles */
@media (max-width: 800px) {
.file-info-container {
display: flex;
width: 100%;
align-items: center;
margin-bottom: 10px;
justify-content: space-between;
flex-direction: column;
}
.thumbnail {
margin-right: 20px;
margin-bottom: 0;
flex-shrink: 0;
}
.thumbnail {
margin-right: 20px;
margin-bottom: 0;
flex-shrink: 0;
}
.file-details {
flex-grow: 1;
Expand All @@ -133,13 +181,19 @@ export default {
max-width: 90%;
}
.delete-button, .protected-button {
.action-buttons {
width: 100%;
margin-left: 0;
margin-right: 0;
flex-wrap: wrap;
justify-content: center;
margin-top: 10px;
}
.action-button, .delete-button, .protected-button {
flex: 1;
min-width: 80px;
margin: 5px;
padding: 3px 7px;
font-size: 12px;
margin-top: 10px;
}
}
Expand Down

0 comments on commit 84b2bd2

Please sign in to comment.