-
Notifications
You must be signed in to change notification settings - Fork 368
Adds spp autofillcolumn apply command. Closes #6203 #6460
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
base: main
Are you sure you want to change the base?
Conversation
2ff3284 to
50c5529
Compare
|
Thank you, we'll try to review it ASAP! |
|
Sorry for the late reply @mkm17, I totally missed your remark last time.
Is this something we are using at a lot of other spots? Seems like in your code you are only retrieving the list
SPO util will be the right place I guess, yes.
To me, it kind of depends on how many places we'll have to replace code by this util function. If it's just one other command, you can easily add it to this PR. If there are like 5 other commands sharing the same logic, I'd opt for a separate issue/PR. |
064b2f6 to
db18aae
Compare
|
Hi, according to the latest comments from @martinlingstuyl on the specification, I have changed the current apply command to set. The I have used the column property I noticed an issue with the test stage in the PR checks, but all tests pass when I run them locally. Can we rerun these checks without changing the code? |
I just did rerun them, but it seems like it doesn't help. I think something is wrong with the macOs pipeline, in the last couple of days I saw this pipeline failing on other PRs as well. We'll have to take a look at it. |
db18aae to
d476d53
Compare
|
Hi @mkm17, I rebased your PR to the latest main to see if our pipeline has been fixed. I hope you don't mind if we take you as a test. Since I performed a force push, I recommend you delete your local branch and pull again from your forked repo. |
779edbc to
81f60aa
Compare
|
Hi @milanholemans sorry for the delay. I've finally made some changes to this command. it's now ready for review. |
martinlingstuyl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mkm17, I've reviewed your PR, looks like solid work. I do have some comments. Could you look into those and fix them?
| : Server or web-relative URL of the library on which to apply the model. Specify either `listTitle`, `listId`, or `listUrl` but not multiple. | ||
|
|
||
| `-i, --columnId [columnId]` | ||
| : ID of the column to which the autofill option will be assigned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an optionset, we should add something like "Specify either..."
| message: `${listId} in parameter listId is not a valid GUID` | ||
| })).optional(), | ||
| listUrl: z.string().optional(), | ||
| columnId: zod.alias('i', z.string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you've added columnId and columnTitle, as opposed to the original specs where you just had column. It's not clear from columnTitle that you can add an internalName as well (which is possible as I see in the code). I'd suggest we add an additional columnInternalName option to the optionset... just for clarities sake. What about you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinlingstuyl, good idea, I have added it!
| } | ||
| } | ||
|
|
||
| interface CommandArgs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate interface
| message: `'${url}' is not a valid SharePoint Online site URL.` | ||
| }))), | ||
| listTitle: z.string().optional(), | ||
| listId: z.string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also use .string().uuid(), then you don't need to fix the error message and add the custom validation. the validation error message is less clear there, but we will try to fix that centrally.
| message: `${listId} in parameter listId is not a valid GUID` | ||
| })).optional(), | ||
| listUrl: z.string().optional(), | ||
| columnId: zod.alias('i', z.string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here (.string().uuid())
|
|
||
| private getColumn(options: Options, listId: string): Promise<Field> { | ||
| let fieldRestUrl: string = ''; | ||
| if (options.columnId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add an additional line-break here for readability
| }, | ||
| responseType: 'json' | ||
| }; | ||
| return request.get<Field>(requestOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add an additional line-break here for readability
| } | ||
|
|
||
| if (!args.options.prompt) { | ||
| throw Error(`The prompt parameter is required when setting the autofill column for the first time.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also add this information to the documentation
| throw Error(`The prompt parameter is required when setting the autofill column for the first time.`); | ||
| } | ||
|
|
||
| const requestOptions: CliRequestOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity lets add this request to a private function as well, just as the updateAutoFillColumnSettings function
| throw `${opts.url} is invalid request`; | ||
| }); | ||
|
|
||
| await command.action(logger, { options: { siteUrl: 'https://contoso.sharepoint.com/sites/sales', columnId: '9b1b1e42-794b-4c71-93ac-5ed92488b67f', listId: '421b1e42-794b-4c71-93ac-5ed92488b67d', prompt: 'test', verbose: true } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use commandOptionsSchema.parse() to parse/validate the options when we pass them into the command action function.
| await command.action(logger, { options: { siteUrl: 'https://contoso.sharepoint.com/sites/sales', columnId: '9b1b1e42-794b-4c71-93ac-5ed92488b67f', listId: '421b1e42-794b-4c71-93ac-5ed92488b67d', prompt: 'test', verbose: true } }); | |
| await command.action(logger, { options: commandOptionsSchema.parse({ siteUrl: 'https://contoso.sharepoint.com/sites/sales', columnId: '9b1b1e42-794b-4c71-93ac-5ed92488b67f', listId: '421b1e42-794b-4c71-93ac-5ed92488b67d', prompt: 'test', verbose: true }) }); |
|
Oh and also could you fix/rebase the branch to fix the merge conflicts? Thanks in advance! |
81f60aa to
c5ddbc6
Compare
c5ddbc6 to
346b519
Compare
|
@martinlingstuyl thank you for the review. I hope that I have covered all the suggestions. |
Adds spp autofillcolumn apply command. Closes #6203
Hi, just a few remarks on this command:
I’ve added the
columnIdandcolumnTitleparameters to allow selection of the column by either option.I noticed that retrieving the list instance, like in the
getDocumentLibraryInfofunction, appears in several places in the solution. Could you advise on where we should store this common code? Is spo.ts the correct file for it?Similarly, for retrieving a field, should the
getColumnfunction also be placed in spo.ts?Do you think I should make these updates in this PR, or would it be better to create a separate one?