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

Sort assets by modified date #11820

Merged
merged 26 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8cbf38d
Sort assets by modified date
MrFlashAccount Dec 10, 2024
47c5365
Add error state to Editable span
MrFlashAccount Dec 11, 2024
2eaac13
Check for uniqness and display error accordingly
MrFlashAccount Dec 11, 2024
ab17135
Fix tiny issues
MrFlashAccount Dec 11, 2024
cd30c89
Fix `used by another dev behavior`
MrFlashAccount Dec 12, 2024
b0f14c0
Merge branch 'develop' into wip/sergeigarin/fix-concurrent-access
MrFlashAccount Dec 12, 2024
6711ed5
Merge branch 'develop' into wip/sergeigarin/fix-concurrent-access
MrFlashAccount Dec 12, 2024
7329bf7
FIxes
MrFlashAccount Dec 13, 2024
ee1c382
Remove unused import
MrFlashAccount Dec 13, 2024
96fb603
FIxes x2
MrFlashAccount Dec 13, 2024
c77b38e
Add border
MrFlashAccount Dec 13, 2024
d8a6bee
Improve animations
MrFlashAccount Dec 13, 2024
cf38bf5
Fix animation
MrFlashAccount Dec 14, 2024
2e0c153
Fix overflow
MrFlashAccount Dec 14, 2024
1cca433
Fix eslint
MrFlashAccount Dec 14, 2024
d8528d4
Fix lint
MrFlashAccount Dec 15, 2024
9e1599f
Fix lint issues
MrFlashAccount Dec 16, 2024
20a0142
Fix docs for underaly element
MrFlashAccount Dec 16, 2024
ceb7a94
Merge branch 'develop' into wip/sergeigarin/fix-concurrent-access
MrFlashAccount Dec 19, 2024
2591fc5
Try fix opened projects
MrFlashAccount Dec 19, 2024
a0333b0
Fix tests
MrFlashAccount Dec 19, 2024
e7840ca
Promote broken values instead of ignoring them (#11777)
JaroslavTulach Dec 19, 2024
4653eca
Missed one :( (#11918)
jdunkerley Dec 19, 2024
b50ae41
remove console logs
MrFlashAccount Dec 19, 2024
59f5dd2
Merge branch 'develop' into wip/sergeigarin/fix-concurrent-access
MrFlashAccount Dec 22, 2024
58b753f
Merge branch 'develop' into wip/sergeigarin/fix-concurrent-access
MrFlashAccount Dec 22, 2024
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
38 changes: 23 additions & 15 deletions app/common/src/services/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,7 @@ export function createSpecialLoadingAsset(directoryId: DirectoryId): SpecialLoad
return {
type: AssetType.specialLoading,
title: '',
id: LoadingAssetId(
createPlaceholderId(`${AssetType.specialLoading}-${uniqueString.uniqueString()}`),
),
id: LoadingAssetId(createPlaceholderId(`${AssetType.specialLoading}-${directoryId}`)),
modifiedAt: dateTime.toRfc3339(new Date()),
parentId: directoryId,
permissions: [],
Expand All @@ -998,7 +996,7 @@ export function createSpecialEmptyAsset(directoryId: DirectoryId): SpecialEmptyA
return {
type: AssetType.specialEmpty,
title: '',
id: EmptyAssetId(`${AssetType.specialEmpty}-${uniqueString.uniqueString()}`),
id: EmptyAssetId(`${AssetType.specialEmpty}-${directoryId}`),
modifiedAt: dateTime.toRfc3339(new Date()),
parentId: directoryId,
permissions: [],
Expand All @@ -1024,7 +1022,7 @@ export function createSpecialErrorAsset(directoryId: DirectoryId): SpecialErrorA
return {
type: AssetType.specialError,
title: '',
id: ErrorAssetId(`${AssetType.specialError}-${uniqueString.uniqueString()}`),
id: ErrorAssetId(`${AssetType.specialError}-${directoryId}`),
modifiedAt: dateTime.toRfc3339(new Date()),
parentId: directoryId,
permissions: [],
Expand Down Expand Up @@ -1514,18 +1512,28 @@ export function isNewTitleValid(
item: AnyAsset,
newTitle: string,
siblings?: readonly AnyAsset[] | null,
) {
return newTitle !== '' && newTitle !== item.title && isNewTitleUnique(item, newTitle, siblings)
}

/**
* Check whether a new title is unique among the siblings.
*/
export function isNewTitleUnique(
item: AnyAsset,
newTitle: string,
siblings?: readonly AnyAsset[] | null,
) {
siblings ??= []
return (
newTitle !== '' &&
newTitle !== item.title &&
siblings.every(sibling => {
const isSelf = sibling.id === item.id
const hasSameType = sibling.type === item.type
const hasSameTitle = sibling.title === newTitle
return !(!isSelf && hasSameType && hasSameTitle)
})
)

return siblings.every(sibling => {
if (sibling.id === item.id) {
return true
}

const hasSameTitle = sibling.title.toLowerCase() === newTitle.toLowerCase()
return !hasSameTitle
})
}

/** Network error class. */
Expand Down
3 changes: 3 additions & 0 deletions app/common/src/text/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
"otherUserIsUsingProjectError": "Someone else is using this project",
"localBackendNotDetectedError": "Could not detect the local backend",

"invalidInput": "Invalid input",
"nameShouldBeUnique": "Name must be unique",
"nameShouldNotContainInvalidCharacters": "Name should not contain invalid characters",
"invalidEmailValidationError": "Please enter a valid email address",

"projectHasNoSourceFilesPhrase": "project has no source files",
Expand Down
52 changes: 52 additions & 0 deletions app/common/src/text/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @file Functions related to displaying text. */

import { unsafeKeys } from '../utilities/data/object'
import ENGLISH from './english.json' with { type: 'json' }

// =============
Expand Down Expand Up @@ -159,3 +160,54 @@ export interface Replacements
export const TEXTS: Readonly<Record<Language, Texts>> = {
[Language.english]: ENGLISH,
}
/**
* A function that gets localized text for a given key, with optional replacements.
* @param key - The key of the text to get.
* @param replacements - The replacements to insert into the text.
* If the text contains placeholders like `$0`, `$1`, etc.,
* they will be replaced with the corresponding replacement.
*/
export type GetText = <K extends TextId>(
dictionary: Texts,
key: K,
...replacements: Replacements[K]
) => string

/**
* Resolves the language texts based on the user's preferred language.
*/
export function resolveUserLanguage() {
const locale = navigator.language
const language =
unsafeKeys(LANGUAGE_TO_LOCALE).find(language => locale === LANGUAGE_TO_LOCALE[language]) ??
Language.english

return language
}

/**
* Gets the dictionary for a given language.
* @param language - The language to get the dictionary for.
* @returns The dictionary for the given language.
*/
export function getDictionary(language: Language) {
return TEXTS[language]
}

/**
* Gets the text for a given key, with optional replacements.
* @param dictionary - The dictionary to get the text from.
* @param key - The key of the text to get.
* @param replacements - The replacements to insert into the text.
* If the text contains placeholders like `$0`, `$1`, etc.,
* they will be replaced with the corresponding replacement.
*/
export const getText: GetText = (dictionary, key, ...replacements) => {
const template = dictionary[key]

return replacements.length === 0 ?
template
: template.replace(/[$]([$]|\d+)/g, (_match, placeholder: string) =>
placeholder === '$' ? '$' : String(replacements[Number(placeholder)] ?? `$${placeholder}`),
)
}
8 changes: 8 additions & 0 deletions app/gui/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ declare global {
readonly projectManagementApi?: ProjectManagementApi
readonly fileBrowserApi?: FileBrowserApi
readonly versionInfo?: VersionInfo

toggleDevtools: () => void
/**
* If set to `true`, animations will be disabled.
Expand All @@ -183,6 +184,13 @@ declare global {
* ATM only affects the framer-motion animations.
*/
readonly DISABLE_ANIMATIONS?: boolean
readonly featureFlags: FeatureFlags
readonly setFeatureFlags: (flags: Partial<FeatureFlags>) => void
/**
* Feature flags that override the default or stored feature flags.
* This is used by integration tests to set feature flags.
*/
readonly overrideFeatureFlags: Partial<FeatureFlags>
}

namespace NodeJS {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ function locateAssetRows(page: Page) {

/** Find assets table placeholder rows. */
function locateNonAssetRows(page: Page) {
return locateAssetsTable(page).locator('tbody tr:not([data-testid="asset-row"])')
return locateAssetsTable(page).locator(
'tbody tr:not([data-testid="asset-row"]):not([data-testid="dummy-row"])',
)
}

/** Find a "new secret" icon. */
Expand Down
Loading
Loading