@@ -61,13 +61,40 @@ export const StarterTemplateWithOrgPicker: Story = {
61
61
} ,
62
62
} ;
63
63
64
+ const canCreateTemplate = ( organizationId : string ) => {
65
+ return {
66
+ [ organizationId ] : {
67
+ object : {
68
+ resource_type : "template" ,
69
+ organization_id : organizationId ,
70
+ } ,
71
+ action : "create" ,
72
+ } ,
73
+ } ;
74
+ } ;
75
+
64
76
export const StarterTemplateWithProvisionerWarning : Story = {
65
77
parameters : {
66
78
queries : [
67
79
{
68
80
key : organizationsKey ,
69
81
data : [ MockDefaultOrganization , MockOrganization2 ] ,
70
82
} ,
83
+ {
84
+ key : [
85
+ "authorization" ,
86
+ {
87
+ checks : {
88
+ ...canCreateTemplate ( MockDefaultOrganization . id ) ,
89
+ ...canCreateTemplate ( MockOrganization2 . id ) ,
90
+ } ,
91
+ } ,
92
+ ] ,
93
+ data : {
94
+ [ MockDefaultOrganization . id ] : true ,
95
+ [ MockOrganization2 . id ] : true ,
96
+ } ,
97
+ } ,
71
98
{
72
99
key : getProvisionerDaemonsKey ( MockOrganization2 . id ) ,
73
100
data : [ ] ,
@@ -86,6 +113,44 @@ export const StarterTemplateWithProvisionerWarning: Story = {
86
113
} ,
87
114
} ;
88
115
116
+ export const StarterTemplatePermissionsCheck : Story = {
117
+ parameters : {
118
+ queries : [
119
+ {
120
+ key : organizationsKey ,
121
+ data : [ MockDefaultOrganization , MockOrganization2 ] ,
122
+ } ,
123
+ {
124
+ key : [
125
+ "authorization" ,
126
+ {
127
+ checks : {
128
+ ...canCreateTemplate ( MockDefaultOrganization . id ) ,
129
+ ...canCreateTemplate ( MockOrganization2 . id ) ,
130
+ } ,
131
+ } ,
132
+ ] ,
133
+ data : {
134
+ [ MockDefaultOrganization . id ] : true ,
135
+ [ MockOrganization2 . id ] : false ,
136
+ } ,
137
+ } ,
138
+ {
139
+ key : getProvisionerDaemonsKey ( MockOrganization2 . id ) ,
140
+ data : [ ] ,
141
+ } ,
142
+ ] ,
143
+ } ,
144
+ args : {
145
+ ...StarterTemplate . args ,
146
+ showOrganizationPicker : true ,
147
+ } ,
148
+ play : async ( ) => {
149
+ const organizationPicker = screen . getByPlaceholderText ( "Organization name" ) ;
150
+ await userEvent . click ( organizationPicker ) ;
151
+ } ,
152
+ } ;
153
+
89
154
export const DuplicateTemplateWithVariables : Story = {
90
155
args : {
91
156
copiedTemplate : MockTemplate ,
0 commit comments