-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5709 from owncloud/fix-current-folder-actions-sid…
…ebar Disable actions for the current folder in the right sidebar
- Loading branch information
Showing
9 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// TODO: find a good location for the Resource interface. Needed in other repos as well, so it needs to be deployed to npm. | ||
// TODO: add more fields to the resource interface. Extend into different resource types: FileResource, FolderResource, ShareResource, IncomingShareResource, OutgoingShareResource, ... | ||
export interface Resource { | ||
id: number | string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Resource } from './resource' | ||
|
||
export const isSameResource = (r1: Resource, r2: Resource): boolean => { | ||
if (!r1 || !r2) return false | ||
return r1.id === r2.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/web-app-files/tests/unit/helpers/resource/sameResource.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { isSameResource } from '../../../../src/helpers/resource' | ||
|
||
describe('isSameResource', () => { | ||
test('evaluates to false if one of the resources is nullish', () => { | ||
expect(isSameResource(null, null)).toBe(false) | ||
expect(isSameResource(undefined, undefined)).toBe(false) | ||
expect(isSameResource(null, { id: 1 })).toBe(false) | ||
expect(isSameResource(undefined, { id: 1 })).toBe(false) | ||
expect(isSameResource({ id: 1 }, null)).toBe(false) | ||
expect(isSameResource({ id: 1 }, undefined)).toBe(false) | ||
}) | ||
test('evaluates to false if ids are of different types', () => { | ||
expect(isSameResource({ id: 1 }, { id: '1' })).toBe(false) | ||
}) | ||
test('evaluates to false if ids are different values', () => { | ||
expect(isSameResource({ id: 1 }, { id: 2 })).toBe(false) | ||
expect(isSameResource({ id: '1' }, { id: '2' })).toBe(false) | ||
}) | ||
test('evaluates to true if ids are the same', () => { | ||
expect(isSameResource({ id: 1 }, { id: 1 })).toBe(true) | ||
expect(isSameResource({ id: '1' }, { id: '1' })).toBe(true) | ||
}) | ||
}) |