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

Allow editing extensions and creating customs ones through the UI #1256

Merged
merged 9 commits into from
Dec 7, 2022

Conversation

Williangalvani
Copy link
Member

No description provided.

@Williangalvani Williangalvani marked this pull request as ready for review December 5, 2022 21:04
import { VForm } from '@/types/vuetify'
import back_axios from '@/utils/api'

import { InstalledExtensionData } from '../../types/kraken'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use @ and not relative reference

this.new_extension = null
},
validate_identifier(input: string): (true | string) {
const re = /[A-Za-z]+[A-Za-z0-9]*\.[A-Za-z]+[A-Za-z0-9]*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[A-Za-z]+[A-Za-z0-9]* is weird, why not [A-Za-z][A-Za-z0-9]* ? The plus characters does not make sense to me.
Can you add an example if what this is validating ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, in hindsight the + is meaningless. it is there so that the identifiers do not start with numbers

return 'This field must container two words separated by a period. Numbers are allowed if not the first character'
},
validate_dockerhub(input: string): (true | string) {
const re = /[A-Za-z]+[A-Za-z0-9]*\/[A-Za-z]+[A-Za-z0-9]*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add example for valid strings ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take the pluses out. this is based on dockerhub`s description:

A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.

+ 'Numbers are allowed if not the first character. e.g example/docker1'
},
validate_name(input: string): (true | string) {
const re = /[A-Za-z]+[A-Za-z0-9 ]/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 3 three regex appears to be an abstraction over two string groups, if that is the case, we should split the regex in two groups and merge it for better readability of the proposal of each regex group.

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

It's failing to fetch for extensions

validate_identifier(input: string): (true | string) {
// Identifiers should be two words separated by a period
// They can contain lower and uppercase characters, but cannot begin with a number
const re = /^[A-Za-z][A-Za-z0-9]*\.[A-Za-z]+[A-Za-z0-9]*/
Copy link
Member

@patrickelectric patrickelectric Dec 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make it simpler by:

const name_validator = '[A-Za-z][A-Za-z0-9]+'
const regex = RegExp('^${name_validor}\.${name_validator}')

validate_name(input: string): (true | string) {
// Lowercase, uppercase characters, and spaces
const re = /[A-Za-z0-9 ]/
if (re.test(input)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A string that only contains spaces should not be valid, like: " "

},
validate_name(input: string): (true | string) {
// Lowercase, uppercase characters, and spaces
const re = /[A-Za-z0-9 ]/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex only validate the first character, ' {}{}{}{}' is valid since the first character is a space.

@Williangalvani
Copy link
Member Author

I updated the validation.

Your issue was that kraken was having issues with the updated settings format. I made it a big sturdier, but it will likely remove your currently installed extensions, now. I could go further, but beta features shouldn't need to deal with settings format changes anyway.

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it shows that there are no extensions installed, but I have zero tier on my rasp.

image

return 'This field must not be empty'
}
if (input.length > 128) {
return 'This field must at most 128 characters long'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks a bit weird, maybe: This field must be no more than 128 characters long or This field should be not longer than 128 characters

JSON.parse(input)
return true
} catch {
return 'This field must be a valid Json'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: Invalid json format or This field is not a valid json format

@Williangalvani
Copy link
Member Author

I changed the texts and made sure that if there are any running extensions, the dockers are stopped as well as it is uninstalled

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There a some TODOs but we can fix that later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants