mirror of https://github.com/harness/drone.git
parent
7336cab958
commit
ff2da8563e
2
Makefile
2
Makefile
|
@ -93,7 +93,7 @@ ar-clean:
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
format: tools # Format go code and error if any changes are made
|
format: tools # Format go code and error if any changes are made
|
||||||
@echo "Formating ..."
|
@echo "Formatting ..."
|
||||||
@goimports -w .
|
@goimports -w .
|
||||||
@gci write --skip-generated --custom-order -s standard -s "prefix(github.com/harness/gitness)" -s default -s blank -s dot .
|
@gci write --skip-generated --custom-order -s standard -s "prefix(github.com/harness/gitness)" -s default -s blank -s dot .
|
||||||
@echo "Formatting complete"
|
@echo "Formatting complete"
|
||||||
|
|
|
@ -28,7 +28,7 @@ See [developer.harness.io](https://developer.harness.io/docs/open-source) to lea
|
||||||
|
|
||||||
Harness Open Source represents a massive investment in the next generation of Drone. Where Drone focused solely on continuous integration, Harness adds source code hosting, developer environments (gitspaces), and artifact registries; providing teams with an end-to-end, open source DevOps platform.
|
Harness Open Source represents a massive investment in the next generation of Drone. Where Drone focused solely on continuous integration, Harness adds source code hosting, developer environments (gitspaces), and artifact registries; providing teams with an end-to-end, open source DevOps platform.
|
||||||
|
|
||||||
The goal is for Harness to eventually be at full parity with Drone in terms of pipeline capabilities, allowing users to seemlessly migrate from Drone to Harness.
|
The goal is for Harness to eventually be at full parity with Drone in terms of pipeline capabilities, allowing users to seamlessly migrate from Drone to Harness.
|
||||||
|
|
||||||
But, we expect this to take some time, which is why we took a snapshot of Drone as a feature branch [drone](https://github.com/harness/harness/tree/drone) ([README](https://github.com/harness/harness/blob/drone/.github/readme.md)) so it can continue development.
|
But, we expect this to take some time, which is why we took a snapshot of Drone as a feature branch [drone](https://github.com/harness/harness/tree/drone) ([README](https://github.com/harness/harness/blob/drone/.github/readme.md)) so it can continue development.
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ func (c *Controller) Create(ctx context.Context, session *auth.Session, in *Crea
|
||||||
return nil, fmt.Errorf("failed to set repo public access (and repo purge: %w): %w", dErr, err)
|
return nil, fmt.Errorf("failed to set repo public access (and repo purge: %w): %w", dErr, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("failed to set repo public access (succesfull cleanup): %w", err)
|
return nil, fmt.Errorf("failed to set repo public access (successful cleanup): %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// backfil GitURL
|
// backfil GitURL
|
||||||
|
|
|
@ -94,7 +94,7 @@ func (c *Controller) Create(
|
||||||
return nil, fmt.Errorf("failed to set space public access (and space purge: %w): %w", dErr, err)
|
return nil, fmt.Errorf("failed to set space public access (and space purge: %w): %w", dErr, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("failed to set space public access (succesfull cleanup): %w", err)
|
return nil, fmt.Errorf("failed to set space public access (successful cleanup): %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetSpaceOutput(ctx, c.publicAccess, space)
|
return GetSpaceOutput(ctx, c.publicAccess, space)
|
||||||
|
|
|
@ -52,7 +52,7 @@ func newTokensCleanupJob(
|
||||||
|
|
||||||
// Handle purges old token that are expired.
|
// Handle purges old token that are expired.
|
||||||
func (j *tokensCleanupJob) Handle(ctx context.Context, _ string, _ job.ProgressReporter) (string, error) {
|
func (j *tokensCleanupJob) Handle(ctx context.Context, _ string, _ job.ProgressReporter) (string, error) {
|
||||||
// Don't remove PAT / SAT as they were explicitly created and are manged by user.
|
// Don't remove PAT / SAT as they were explicitly created and are managed by user.
|
||||||
expiredBefore := time.Now().Add(-tokenRetentionTime)
|
expiredBefore := time.Now().Add(-tokenRetentionTime)
|
||||||
log.Ctx(ctx).Info().Msgf(
|
log.Ctx(ctx).Info().Msgf(
|
||||||
"start purging expired tokens (expired before: %s)",
|
"start purging expired tokens (expired before: %s)",
|
||||||
|
|
|
@ -24,7 +24,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// discardEventError is an error which, if returned by the event handler,
|
// discardEventError is an error which, if returned by the event handler,
|
||||||
// causes the source event to be discarded despite any erros.
|
// causes the source event to be discarded despite any errors.
|
||||||
type discardEventError struct {
|
type discardEventError struct {
|
||||||
inner error
|
inner error
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ func GetReferenceFromBranchName(branchName string) string {
|
||||||
// remove spaces
|
// remove spaces
|
||||||
branchName = strings.TrimSpace(branchName)
|
branchName = strings.TrimSpace(branchName)
|
||||||
// remove `refs/heads/` prefix (shouldn't be there, but if it is remove it to try to avoid complications)
|
// remove `refs/heads/` prefix (shouldn't be there, but if it is remove it to try to avoid complications)
|
||||||
// NOTE: This is used to reduce missconfigurations via api
|
// NOTE: This is used to reduce misconfigurations via api
|
||||||
// TODO: block via CLI, too
|
// TODO: block via CLI, too
|
||||||
branchName = strings.TrimPrefix(branchName, gitReferenceNamePrefixBranch)
|
branchName = strings.TrimPrefix(branchName, gitReferenceNamePrefixBranch)
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ func GetReferenceFromTagName(tagName string) string {
|
||||||
// remove spaces
|
// remove spaces
|
||||||
tagName = strings.TrimSpace(tagName)
|
tagName = strings.TrimSpace(tagName)
|
||||||
// remove `refs/heads/` prefix (shouldn't be there, but if it is remove it to try to avoid complications)
|
// remove `refs/heads/` prefix (shouldn't be there, but if it is remove it to try to avoid complications)
|
||||||
// NOTE: This is used to reduce missconfigurations via api
|
// NOTE: This is used to reduce misconfigurations via api
|
||||||
// TODO: block via CLI, too
|
// TODO: block via CLI, too
|
||||||
tagName = strings.TrimPrefix(tagName, gitReferenceNamePrefixTag)
|
tagName = strings.TrimPrefix(tagName, gitReferenceNamePrefixTag)
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,7 @@ func (s *Service) GetRepositorySize(
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateDefaultBranch updates the default barnch of the repo.
|
// UpdateDefaultBranch updates the default branch of the repo.
|
||||||
func (s *Service) UpdateDefaultBranch(
|
func (s *Service) UpdateDefaultBranch(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
params *UpdateDefaultBranchParams,
|
params *UpdateDefaultBranchParams,
|
||||||
|
|
|
@ -121,7 +121,7 @@ func (a *authorizer) initialize(u *url.URL) error {
|
||||||
a.authorizer = basic.NewAuthorizer(a.username, a.password)
|
a.authorizer = basic.NewAuthorizer(a.username, a.password)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unspported auth scheme: %v", challenges)
|
return fmt.Errorf("unsupported auth scheme: %v", challenges)
|
||||||
}
|
}
|
||||||
|
|
||||||
// isTarget checks whether the request targets the registry.
|
// isTarget checks whether the request targets the registry.
|
||||||
|
|
|
@ -8,7 +8,7 @@ gradle-app.setting
|
||||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
|
|
||||||
# Avoid ignore Gradle wrappper properties
|
# Avoid ignore Gradle wrapper properties
|
||||||
!gradle-wrapper.properties
|
!gradle-wrapper.properties
|
||||||
|
|
||||||
# Cache of project
|
# Cache of project
|
||||||
|
|
|
@ -46,7 +46,7 @@ func (f consumerOptionFunc) apply(config *ConsumerConfig) {
|
||||||
// WithConcurrency sets up the concurrency of the stream consumer.
|
// WithConcurrency sets up the concurrency of the stream consumer.
|
||||||
func WithConcurrency(concurrency int) ConsumerOption {
|
func WithConcurrency(concurrency int) ConsumerOption {
|
||||||
if concurrency < 1 || concurrency > MaxConcurrency {
|
if concurrency < 1 || concurrency > MaxConcurrency {
|
||||||
// missconfiguration - panic to keep options clean
|
// misconfiguration - panic to keep options clean
|
||||||
panic(fmt.Sprintf("provided concurrency %d is invalid - has to be between 1 and %d",
|
panic(fmt.Sprintf("provided concurrency %d is invalid - has to be between 1 and %d",
|
||||||
concurrency, MaxConcurrency))
|
concurrency, MaxConcurrency))
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ func (f handlerOptionFunc) apply(config *HandlerConfig) {
|
||||||
// WithMaxRetries can be used to set the max retry count for a specific handler.
|
// WithMaxRetries can be used to set the max retry count for a specific handler.
|
||||||
func WithMaxRetries(maxRetries int) HandlerOption {
|
func WithMaxRetries(maxRetries int) HandlerOption {
|
||||||
if maxRetries < 0 || maxRetries > MaxMaxRetries {
|
if maxRetries < 0 || maxRetries > MaxMaxRetries {
|
||||||
// missconfiguration - panic to keep options clean
|
// misconfiguration - panic to keep options clean
|
||||||
panic(fmt.Sprintf("provided maxRetries %d is invalid - has to be between 0 and %d", maxRetries, MaxMaxRetries))
|
panic(fmt.Sprintf("provided maxRetries %d is invalid - has to be between 0 and %d", maxRetries, MaxMaxRetries))
|
||||||
}
|
}
|
||||||
return handlerOptionFunc(func(c *HandlerConfig) {
|
return handlerOptionFunc(func(c *HandlerConfig) {
|
||||||
|
@ -91,7 +91,7 @@ func WithMaxRetries(maxRetries int) HandlerOption {
|
||||||
// WithIdleTimeout can be used to set the idle timeout for a specific handler.
|
// WithIdleTimeout can be used to set the idle timeout for a specific handler.
|
||||||
func WithIdleTimeout(timeout time.Duration) HandlerOption {
|
func WithIdleTimeout(timeout time.Duration) HandlerOption {
|
||||||
if timeout < MinIdleTimeout {
|
if timeout < MinIdleTimeout {
|
||||||
// missconfiguration - panic to keep options clean
|
// misconfiguration - panic to keep options clean
|
||||||
panic(fmt.Sprintf("provided timeout %d is invalid - has to be longer than %s", timeout, MinIdleTimeout))
|
panic(fmt.Sprintf("provided timeout %d is invalid - has to be longer than %s", timeout, MinIdleTimeout))
|
||||||
}
|
}
|
||||||
return handlerOptionFunc(func(c *HandlerConfig) {
|
return handlerOptionFunc(func(c *HandlerConfig) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ type ConsumerConfig struct {
|
||||||
// HandlerConfig defines the configuration for a single stream handler containing externally exposed values
|
// HandlerConfig defines the configuration for a single stream handler containing externally exposed values
|
||||||
// that can be configured using the available HandlerOptions.
|
// that can be configured using the available HandlerOptions.
|
||||||
type HandlerConfig struct {
|
type HandlerConfig struct {
|
||||||
// idleTimeout specifies the maximum duration a message stays read but unacknowleged
|
// idleTimeout specifies the maximum duration a message stays read but unacknowledged
|
||||||
// before it can be claimed by others.
|
// before it can be claimed by others.
|
||||||
idleTimeout time.Duration
|
idleTimeout time.Duration
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceAccountParent verifies the remaining fields of a service account
|
// ServiceAccountParent verifies the remaining fields of a service account
|
||||||
// that aren't inhereted from principal.
|
// that aren't inherited from principal.
|
||||||
func ServiceAccountParent(parentType enum.ParentResourceType, parentID int64) error {
|
func ServiceAccountParent(parentType enum.ParentResourceType, parentID int64) error {
|
||||||
if parentType != enum.ParentResourceTypeRepo && parentType != enum.ParentResourceTypeSpace {
|
if parentType != enum.ParentResourceTypeRepo && parentType != enum.ParentResourceTypeSpace {
|
||||||
return ErrServiceAccountParentTypeIsInvalid
|
return ErrServiceAccountParentTypeIsInvalid
|
||||||
|
|
|
@ -58,7 +58,7 @@ type Config struct {
|
||||||
|
|
||||||
// Git defines the external URL via which the GIT API is reachable.
|
// Git defines the external URL via which the GIT API is reachable.
|
||||||
// NOTE: for routing to work properly, the request path & hostname reaching gitness
|
// NOTE: for routing to work properly, the request path & hostname reaching gitness
|
||||||
// have to statisfy at least one of the following two conditions:
|
// have to satisfy at least one of the following two conditions:
|
||||||
// - Path ends with `/git`
|
// - Path ends with `/git`
|
||||||
// - Hostname is different to API hostname
|
// - Hostname is different to API hostname
|
||||||
// (this could be after proxy path / header rewrite).
|
// (this could be after proxy path / header rewrite).
|
||||||
|
|
|
@ -42,7 +42,7 @@ console.log(`Found ${files.length} '.css.d.ts' files`);
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
// for every '.css' there will be a coresponding '.css.d.ts' file and vice versa
|
// for every '.css' there will be a corresponding '.css.d.ts' file and vice versa
|
||||||
const cssFile = file.replace('.d.ts', '');
|
const cssFile = file.replace('.d.ts', '');
|
||||||
|
|
||||||
if (!fs.existsSync(cssFile)) {
|
if (!fs.existsSync(cssFile)) {
|
||||||
|
|
|
@ -18,4 +18,4 @@ import generateTypes from './generateTypes.cjs'
|
||||||
|
|
||||||
await generateTypes()
|
await generateTypes()
|
||||||
|
|
||||||
console.log('✅ Generated type for string files succesfully!')
|
console.log('✅ Generated type for string files successfully!')
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { StringsContext, StringsContextValue } from './StringsContext'
|
||||||
|
|
||||||
export interface StringsContextProviderProps extends Pick<StringsContextValue, 'getString'> {
|
export interface StringsContextProviderProps extends Pick<StringsContextValue, 'getString'> {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
initialStrings?: Record<string, any> // temp prop for backward compatability
|
initialStrings?: Record<string, any> // temp prop for backward compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StringsContextProvider(props: StringsContextProviderProps): React.ReactElement {
|
export function StringsContextProvider(props: StringsContextProviderProps): React.ReactElement {
|
||||||
|
|
|
@ -18,4 +18,4 @@ import generateTypes from './generateTypes.cjs'
|
||||||
|
|
||||||
await generateTypes()
|
await generateTypes()
|
||||||
|
|
||||||
console.log('✅ Generated type for string files succesfully!')
|
console.log('✅ Generated type for string files successfully!')
|
||||||
|
|
|
@ -44,7 +44,7 @@ sessionDuration: Last Started
|
||||||
lastActivated: Last Activated
|
lastActivated: Last Activated
|
||||||
deleteGitspaceTitle: Delete Gitspace '{{name}}'
|
deleteGitspaceTitle: Delete Gitspace '{{name}}'
|
||||||
deleteGitspaceText: 'This action cannot be undone. Are you sure you want to proceed to delete?'
|
deleteGitspaceText: 'This action cannot be undone. Are you sure you want to proceed to delete?'
|
||||||
deleteSuccess: Gitspace deleted succesfully
|
deleteSuccess: Gitspace deleted successfully
|
||||||
repositoryAndBranch: Repository & Branch
|
repositoryAndBranch: Repository & Branch
|
||||||
importInto: Import Repository into Gitness
|
importInto: Import Repository into Gitness
|
||||||
status: Status
|
status: Status
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { StringsContext, StringsContextValue } from './StringsContext'
|
||||||
export interface StringsContextProviderProps extends Pick<StringsContextValue, 'getString'> {
|
export interface StringsContextProviderProps extends Pick<StringsContextValue, 'getString'> {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
initialStrings?: Record<string, any> // temp prop for backward compatability
|
initialStrings?: Record<string, any> // temp prop for backward compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StringsContextProvider(props: StringsContextProviderProps): React.ReactElement {
|
export function StringsContextProvider(props: StringsContextProviderProps): React.ReactElement {
|
||||||
|
|
|
@ -151,7 +151,7 @@ export interface StringsMap {
|
||||||
cancelImportConfirm: string
|
cancelImportConfirm: string
|
||||||
cancelledImport: string
|
cancelledImport: string
|
||||||
changePassword: string
|
changePassword: string
|
||||||
changePasswordSuccesfully: string
|
changePasswordSuccessfully: string
|
||||||
changeRepoVis: string
|
changeRepoVis: string
|
||||||
changeRepoVisContent: string
|
changeRepoVisContent: string
|
||||||
changeRole: string
|
changeRole: string
|
||||||
|
|
|
@ -639,7 +639,7 @@ expired: Expired
|
||||||
expirationDate: Expiration Date
|
expirationDate: Expiration Date
|
||||||
created: Created
|
created: Created
|
||||||
thisRefHas: 'This {isTag|true:tag,branch} has'
|
thisRefHas: 'This {isTag|true:tag,branch} has'
|
||||||
changePasswordSuccesfully: Password changed successfully
|
changePasswordSuccessfully: Password changed successfully
|
||||||
applyChanges: Apply Changes
|
applyChanges: Apply Changes
|
||||||
showMore: View more
|
showMore: View more
|
||||||
showLess: View less
|
showLess: View less
|
||||||
|
|
|
@ -56,7 +56,7 @@ const ChangePassword = () => {
|
||||||
password: values.newPassword
|
password: values.newPassword
|
||||||
})
|
})
|
||||||
|
|
||||||
showSuccess(getString('changePasswordSuccesfully'))
|
showSuccess(getString('changePasswordSuccessfully'))
|
||||||
history.goBack()
|
history.goBack()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showError(getErrorMessage(error))
|
showError(getErrorMessage(error))
|
||||||
|
|
|
@ -29,12 +29,12 @@ import { normalizeGitRef } from 'utils/GitUtils'
|
||||||
/**
|
/**
|
||||||
* This hook abstracts data handling for a pull request. It's used as a
|
* This hook abstracts data handling for a pull request. It's used as a
|
||||||
* centralized data store for all tabs in Pull Request page. The hook
|
* centralized data store for all tabs in Pull Request page. The hook
|
||||||
* fetches neccessary repository metadata, poll/refetch request metadata
|
* fetches necessary repository metadata, poll/refetch request metadata
|
||||||
* for updates, cache data, etc...
|
* for updates, cache data, etc...
|
||||||
*
|
*
|
||||||
* We use Atom to reduce React rendering cycles. Data could be re-fetched,
|
* We use Atom to reduce React rendering cycles. Data could be re-fetched,
|
||||||
* but their reference only updated only if the incoming one is different
|
* but their reference only updated only if the incoming one is different
|
||||||
* from cache. This optimization reduces unneccessary React state updates,
|
* from cache. This optimization reduces unnecessary React state updates,
|
||||||
* hence improves rendering pipeline.
|
* hence improves rendering pipeline.
|
||||||
*
|
*
|
||||||
* The abstraction allows Pull Request tabs to do less data handling and
|
* The abstraction allows Pull Request tabs to do less data handling and
|
||||||
|
|
|
@ -44,7 +44,7 @@ import {
|
||||||
makeDiffRefs
|
makeDiffRefs
|
||||||
} from 'utils/GitUtils'
|
} from 'utils/GitUtils'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
import { filenameToLanguage, FILE_SEPERATOR } from 'utils/Utils'
|
import { filenameToLanguage, FILE_SEPARATOR } from 'utils/Utils'
|
||||||
import { useGetResourceContent } from 'hooks/useGetResourceContent'
|
import { useGetResourceContent } from 'hooks/useGetResourceContent'
|
||||||
import { CommitModalButton } from 'components/CommitModalButton/CommitModalButton'
|
import { CommitModalButton } from 'components/CommitModalButton/CommitModalButton'
|
||||||
import { DiffEditor } from 'components/SourceCodeEditor/MonacoSourceCodeEditor'
|
import { DiffEditor } from 'components/SourceCodeEditor/MonacoSourceCodeEditor'
|
||||||
|
@ -63,7 +63,7 @@ function Editor({ resourceContent, repoMetadata, gitRef, resourcePath, isReposit
|
||||||
const isNew = useMemo(() => !resourceContent || isDir(resourceContent), [resourceContent])
|
const isNew = useMemo(() => !resourceContent || isDir(resourceContent), [resourceContent])
|
||||||
const [fileName, setFileName] = useState(isNew ? '' : resourceContent?.name || '')
|
const [fileName, setFileName] = useState(isNew ? '' : resourceContent?.name || '')
|
||||||
const [parentPath, setParentPath] = useState(
|
const [parentPath, setParentPath] = useState(
|
||||||
isNew ? resourcePath : resourcePath.split(FILE_SEPERATOR).slice(0, -1).join(FILE_SEPERATOR)
|
isNew ? resourcePath : resourcePath.split(FILE_SEPARATOR).slice(0, -1).join(FILE_SEPARATOR)
|
||||||
)
|
)
|
||||||
const { getString } = useStrings()
|
const { getString } = useStrings()
|
||||||
const { routes } = useAppContext()
|
const { routes } = useAppContext()
|
||||||
|
@ -73,7 +73,7 @@ function Editor({ resourceContent, repoMetadata, gitRef, resourcePath, isReposit
|
||||||
)
|
)
|
||||||
const [content, setContent] = useState(originalContent)
|
const [content, setContent] = useState(originalContent)
|
||||||
const fileResourcePath = useMemo(
|
const fileResourcePath = useMemo(
|
||||||
() => [(parentPath || '').trim(), (fileName || '').trim()].filter(p => !!p.trim()).join(FILE_SEPERATOR),
|
() => [(parentPath || '').trim(), (fileName || '').trim()].filter(p => !!p.trim()).join(FILE_SEPARATOR),
|
||||||
[parentPath, fileName]
|
[parentPath, fileName]
|
||||||
)
|
)
|
||||||
const { data: folderContent, refetch: verifyFolder } = useGetResourceContent({
|
const { data: folderContent, refetch: verifyFolder } = useGetResourceContent({
|
||||||
|
@ -90,14 +90,14 @@ function Editor({ resourceContent, repoMetadata, gitRef, resourcePath, isReposit
|
||||||
)
|
)
|
||||||
const [startVerifyFolder, setStartVerifyFolder] = useState(false)
|
const [startVerifyFolder, setStartVerifyFolder] = useState(false)
|
||||||
const rebuildPaths = useCallback(() => {
|
const rebuildPaths = useCallback(() => {
|
||||||
const _tokens = fileName.split(FILE_SEPERATOR).filter(part => !!part.trim())
|
const _tokens = fileName.split(FILE_SEPARATOR).filter(part => !!part.trim())
|
||||||
const _fileName = ((_tokens.pop() as string) || '').trim()
|
const _fileName = ((_tokens.pop() as string) || '').trim()
|
||||||
const _parentPath = parentPath
|
const _parentPath = parentPath
|
||||||
.split(FILE_SEPERATOR)
|
.split(FILE_SEPARATOR)
|
||||||
.concat(_tokens)
|
.concat(_tokens)
|
||||||
.map(p => p.trim())
|
.map(p => p.trim())
|
||||||
.filter(part => !!part.trim())
|
.filter(part => !!part.trim())
|
||||||
.join(FILE_SEPERATOR)
|
.join(FILE_SEPARATOR)
|
||||||
|
|
||||||
if (_fileName) {
|
if (_fileName) {
|
||||||
const normalizedFilename = _fileName.trim()
|
const normalizedFilename = _fileName.trim()
|
||||||
|
@ -203,7 +203,7 @@ function Editor({ resourceContent, repoMetadata, gitRef, resourcePath, isReposit
|
||||||
}}
|
}}
|
||||||
onBlur={rebuildPaths}
|
onBlur={rebuildPaths}
|
||||||
onFocus={({ target }) => {
|
onFocus={({ target }) => {
|
||||||
const value = (parentPath ? parentPath + FILE_SEPERATOR : '') + fileName
|
const value = (parentPath ? parentPath + FILE_SEPARATOR : '') + fileName
|
||||||
setFileName(value)
|
setFileName(value)
|
||||||
setParentPath('')
|
setParentPath('')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -64,7 +64,7 @@ export const DEFAULT_DATE_FORMAT = 'MM/DD/YYYY hh:mm a'
|
||||||
export const DEFAULT_BRANCH_NAME = 'main'
|
export const DEFAULT_BRANCH_NAME = 'main'
|
||||||
export const REGEX_VALID_REPO_NAME = /^[a-zA-Z_][0-9a-zA-Z-_.$]*$/
|
export const REGEX_VALID_REPO_NAME = /^[a-zA-Z_][0-9a-zA-Z-_.$]*$/
|
||||||
export const SUGGESTED_BRANCH_NAMES = [DEFAULT_BRANCH_NAME, 'master']
|
export const SUGGESTED_BRANCH_NAMES = [DEFAULT_BRANCH_NAME, 'master']
|
||||||
export const FILE_SEPERATOR = '/'
|
export const FILE_SEPARATOR = '/'
|
||||||
export const INITIAL_ZOOM_LEVEL = 1
|
export const INITIAL_ZOOM_LEVEL = 1
|
||||||
export const ZOOM_INC_DEC_LEVEL = 0.1
|
export const ZOOM_INC_DEC_LEVEL = 0.1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue