Skip to content

Flag for editing values in Required Profiles #1137

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

Merged
merged 21 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5b4079b
Add editableValues to Template Profiles
AlinaGoaga Jul 20, 2022
5955022
Add editableValues to Template Profiles - updated
AlinaGoaga Jul 20, 2022
2cec4ae
Merge branch 'main' of github.com:weaveworks/weave-gitops-enterprise …
AlinaGoaga Jul 22, 2022
a1fd874
Update ProfileListItem to look for editable values
AlinaGoaga Jul 22, 2022
d00ee3e
Update flag
AlinaGoaga Jul 22, 2022
0afa472
Merge branch 'main' into WG1086-editable-values-flag
AlinaGoaga Jul 22, 2022
3123698
Update ui-cra/src/components/Clusters/Create/Form/Partials/ProfileLis…
AlinaGoaga Jul 26, 2022
9860bd7
Check that user edited values are in fact editable
AlinaGoaga Jul 26, 2022
4705ab7
Merge branch 'WG1086-editable-values-flag' of github.com:weaveworks/w…
AlinaGoaga Jul 26, 2022
5aad121
Check that user edited values are in fact editable - 2
AlinaGoaga Jul 27, 2022
16861fe
Adds a test case for editable
foot Jul 27, 2022
7911634
Add test for GenerateProfileFiles
AlinaGoaga Jul 27, 2022
e11a946
Merge branch 'main' into WG1086-editable-values-flag
AlinaGoaga Jul 28, 2022
740638e
Regenate files
AlinaGoaga Jul 28, 2022
dee670e
Update tests
AlinaGoaga Jul 28, 2022
ba773f0
Refactor handling of editable flag
AlinaGoaga Jul 29, 2022
1ec0f41
Merge branch 'main' into WG1086-editable-values-flag
AlinaGoaga Jul 29, 2022
9e56104
Refactor handling of editable flag -
AlinaGoaga Jul 29, 2022
83e2249
Merge branch 'main' into WG1086-editable-values-flag
AlinaGoaga Jul 29, 2022
7798565
Regen file
AlinaGoaga Jul 29, 2022
8089f72
Fix typo
AlinaGoaga Jul 29, 2022
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
1 change: 1 addition & 0 deletions cmd/clusters-service/api/cluster_services.proto
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ message Parameter {
message TemplateProfile {
string name = 1;
string version = 2;
bool editable = 3;
}

message TemplateObject {
Expand Down
3 changes: 3 additions & 0 deletions cmd/clusters-service/api/cluster_services.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,9 @@
},
"version": {
"type": "string"
},
"editable": {
"type": "boolean"
}
}
}
Expand Down
672 changes: 341 additions & 331 deletions cmd/clusters-service/pkg/protos/cluster_services.pb.go

Large diffs are not rendered by default.

180 changes: 108 additions & 72 deletions cmd/clusters-service/pkg/protos/cluster_services.pb.gw.go

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions cmd/clusters-service/pkg/server/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,13 +821,14 @@ func TestRenderTemplate_ValidateVariables(t *testing.T) {

func TestGetProfilesFromTemplate(t *testing.T) {
annotations := map[string]string{
"capi.weave.works/profile-0": "{\"name\": \"profile-a\", \"version\": \"v0.0.1\" }",
"capi.weave.works/profile-0": "{\"name\": \"profile-a\", \"version\": \"v0.0.1\", \"editable\": true }",
}

expected := []*capiv1_protos.TemplateProfile{
{
Name: "profile-a",
Version: "v0.0.1",
Name: "profile-a",
Version: "v0.0.1",
Editable: true,
},
}

Expand Down
1 change: 1 addition & 0 deletions ui-cra/src/cluster-services/cluster_services.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export type Parameter = {
export type TemplateProfile = {
name?: string
version?: string
editable?: boolean
}

export type TemplateObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ const ProfilesListItem: FC<{
id="edit-yaml"
startIcon={<Icon type={IconType.SaveAltIcon} size="base" />}
onClick={handleUpdateProfiles}
disabled={profile.required}
disabled={
profile.required &&
(!profile.editable || profile.editable === undefined)
}
>
SAVE CHANGES
</Button>
Expand Down
4 changes: 3 additions & 1 deletion ui-cra/src/contexts/Profiles/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ const ProfilesProvider: FC = ({ children }) => {
const defaultProfiles: UpdatedProfile[] = [];
for (const [key, value] of annotations) {
if (key.includes('capi.weave.works/profile')) {
const { name, version, values } = JSON.parse(value);
const { name, version, values, editable } = JSON.parse(value);
if (values !== undefined) {
defaultProfiles.push({
name,
editable,
values: [{ version, yaml: values, selected: false }],
required: true,
layer: getProfileLayer(name),
});
} else {
defaultProfiles.push({
name,
editable,
values: [
{
version,
Expand Down
1 change: 1 addition & 0 deletions ui-cra/src/types/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type ListProfilesResponse = {

export type UpdatedProfile = {
name: Profile['name'];
editable?: boolean;
values: { version: string; yaml: string; selected?: boolean }[];
required: boolean;
layer?: string;
Expand Down