aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/views/Navigation.vue
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/views/Navigation.vue')
-rw-r--r--apps/files/src/views/Navigation.vue18
1 files changed, 8 insertions, 10 deletions
diff --git a/apps/files/src/views/Navigation.vue b/apps/files/src/views/Navigation.vue
index 3147268f34d..0f3c3647c6e 100644
--- a/apps/files/src/views/Navigation.vue
+++ b/apps/files/src/views/Navigation.vue
@@ -7,7 +7,7 @@
class="files-navigation"
:aria-label="t('files', 'Files')">
<template #search>
- <NcAppNavigationSearch v-model="searchQuery" :label="t('files', 'Filter file names …')" />
+ <FilesNavigationSearch />
</template>
<template #default>
<NcAppNavigationList class="files-navigation__list"
@@ -39,24 +39,24 @@
</template>
<script lang="ts">
-import { getNavigation, type View } from '@nextcloud/files'
+import type { View } from '@nextcloud/files'
import type { ViewConfig } from '../types.ts'
-import { defineComponent } from 'vue'
import { emit, subscribe } from '@nextcloud/event-bus'
-import { translate as t, getCanonicalLocale, getLanguage } from '@nextcloud/l10n'
+import { getNavigation } from '@nextcloud/files'
+import { t, getCanonicalLocale, getLanguage } from '@nextcloud/l10n'
+import { defineComponent } from 'vue'
-import IconCog from 'vue-material-design-icons/Cog.vue'
+import IconCog from 'vue-material-design-icons/CogOutline.vue'
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
import NcAppNavigationItem from '@nextcloud/vue/components/NcAppNavigationItem'
import NcAppNavigationList from '@nextcloud/vue/components/NcAppNavigationList'
-import NcAppNavigationSearch from '@nextcloud/vue/components/NcAppNavigationSearch'
import NavigationQuota from '../components/NavigationQuota.vue'
import SettingsModal from './Settings.vue'
import FilesNavigationItem from '../components/FilesNavigationItem.vue'
+import FilesNavigationSearch from '../components/FilesNavigationSearch.vue'
import { useNavigation } from '../composables/useNavigation'
-import { useFilenameFilter } from '../composables/useFilenameFilter'
import { useFiltersStore } from '../store/filters.ts'
import { useViewConfigStore } from '../store/viewConfig.ts'
import logger from '../logger.ts'
@@ -75,12 +75,12 @@ export default defineComponent({
components: {
IconCog,
FilesNavigationItem,
+ FilesNavigationSearch,
NavigationQuota,
NcAppNavigation,
NcAppNavigationItem,
NcAppNavigationList,
- NcAppNavigationSearch,
SettingsModal,
},
@@ -88,11 +88,9 @@ export default defineComponent({
const filtersStore = useFiltersStore()
const viewConfigStore = useViewConfigStore()
const { currentView, views } = useNavigation()
- const { searchQuery } = useFilenameFilter()
return {
currentView,
- searchQuery,
t,
views,
193' href='#n193'>193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
<?php
/**
 * ownCloud
 *
 * @author Bernhard Posselt
 * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace Test;

class TemplateFunctionsTest extends \Test\TestCase {
	protected function setUp(): void {
		parent::setUp();

		require_once \OC::$SERVERROOT . '/lib/private/legacy/OC_Template.php';
	}

	public function testPJavaScript() {
		$this->expectOutputString('&lt;img onload=&quot;alert(1)&quot; /&gt;');
		p('<img onload="alert(1)" />');
	}

	public function testPJavaScriptWithScriptTags() {
		$this->expectOutputString('&lt;script&gt;alert(&#039;Hacked!&#039;);&lt;/script&gt;');
		p("<script>alert('Hacked!');</script>");
	}

	public function testPNormalString() {
		$string = 'This is a good string without HTML.';
		$this->expectOutputString($string);
		p($string);
	}

	public function testPrintUnescaped() {
		$htmlString = "<script>alert('xss');</script>";
		$this->expectOutputString($htmlString);
		print_unescaped($htmlString);
	}

	public function testPrintUnescapedNormalString() {
		$string = 'This is a good string!';
		$this->expectOutputString($string);
		print_unescaped($string);
	}

	// ---------------------------------------------------------------------------
	// Test relative_modified_date with dates only
	// ---------------------------------------------------------------------------
	public function testRelativeDateToday() {
		$currentTime = 1380703592;
		$elementTime = $currentTime;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('today', $result);

		// 2 hours ago is still today
		$elementTime = $currentTime - 2 * 3600;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('today', $result);
	}

	public function testRelativeDateYesterday() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 24 * 3600;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('yesterday', $result);

		// yesterday - 2 hours is still yesterday
		$elementTime = $currentTime - 26 * 3600;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('yesterday', $result);
	}

	public function testRelativeDate2DaysAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 48 * 3600;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('2 days ago', $result);

		// 2 days ago minus 4 hours is still 2 days ago
		$elementTime = $currentTime - 52 * 3600;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('2 days ago', $result);
	}

	public function testRelativeDateLastMonth() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 31;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('last month', $result);

		$elementTime = $currentTime - 86400 * 35;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('last month', $result);
	}

	public function testRelativeDateMonthsAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 65;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('2 months ago', $result);

		$elementTime = $currentTime - 86400 * 130;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('4 months ago', $result);
	}

	public function testRelativeDateLastYear() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 365;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('last year', $result);

		$elementTime = $currentTime - 86400 * 450;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('last year', $result);
	}

	public function testRelativeDateYearsAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 365.25 * 2;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('2 years ago', $result);

		$elementTime = $currentTime - 86400 * 365.25 * 3;
		$result = (string)relative_modified_date($elementTime, $currentTime, true);

		$this->assertEquals('3 years ago', $result);
	}

	// ---------------------------------------------------------------------------
	// Test relative_modified_date with timestamps only (date + time value)
	// ---------------------------------------------------------------------------

	public function testRelativeTimeSecondsAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 5;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('seconds ago', $result);
	}

	public function testRelativeTimeMinutesAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 190;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('3 minutes ago', $result);
	}

	public function testRelativeTimeHoursAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 7500;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('2 hours ago', $result);
	}

	public function testRelativeTime2DaysAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 48 * 3600;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('2 days ago', $result);

		// 2 days ago minus 4 hours is still 2 days ago
		$elementTime = $currentTime - 52 * 3600;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('2 days ago', $result);
	}

	public function testRelativeTimeLastMonth() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 31;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('last month', $result);

		$elementTime = $currentTime - 86400 * 35;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('last month', $result);
	}

	public function testRelativeTimeMonthsAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 65;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('2 months ago', $result);

		$elementTime = $currentTime - 86400 * 130;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('4 months ago', $result);
	}

	public function testRelativeTimeLastYear() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 365;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('last year', $result);

		$elementTime = $currentTime - 86400 * 450;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('last year', $result);
	}

	public function testRelativeTimeYearsAgo() {
		$currentTime = 1380703592;
		$elementTime = $currentTime - 86400 * 365.25 * 2;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('2 years ago', $result);

		$elementTime = $currentTime - 86400 * 365.25 * 3;
		$result = (string)relative_modified_date($elementTime, $currentTime, false);

		$this->assertEquals('3 years ago', $result);
	}
}