Skip to content

Commit

Permalink
Removes deprecated options from 'spo retentionlabel ensure'. Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
MathijsVerbeeck authored and milanholemans committed Aug 6, 2023
1 parent 5affaac commit 0224182
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 58 deletions.
13 changes: 2 additions & 11 deletions docs/docs/cmd/spo/list/list-retentionlabel-ensure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ m365 spo list retentionlabel ensure [options]
`--name <name>`
: The label name to set on the list.

`--label <label>`
: (deprecated. Use `name` instead) The label name to set on the list.

`-t, --listTitle [listTitle]`
: The title of the list on which to set the label. Specify either `listTitle`, `listId`, or `listUrl` but not multiple.

Expand All @@ -33,12 +30,6 @@ m365 spo list retentionlabel ensure [options]

`--syncToItems`
: Specify, to set the label on all existing items in the list.

`--blockDelete`
: (deprecated) Specify, to disallow deleting items in the list.

`--blockEdit`
: (deprecated) Specify, to disallow editing items in the list.
```

<Global />
Expand All @@ -55,10 +46,10 @@ Sets a retention label by name on a given list.
m365 spo list retentionlabel ensure --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl 'Shared Documents' --name 'Some label'
```

Sets a retention label by name and disables editing and deleting items on the list and all existing items for a given list.
Sets a retention label by name and syncs this to all existing items for a given list.

```sh
m365 spo list retentionlabel ensure --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle 'Documents' --name 'Some label' --blockEdit --blockDelete --syncToItems
m365 spo list retentionlabel ensure --webUrl https://contoso.sharepoint.com/sites/project-x --listTitle 'Documents' --name 'Some label' --syncToItems
```

## Response
Expand Down
8 changes: 8 additions & 0 deletions docs/docs/v7-upgrade-guidance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ spo list label set | [spo list retentionlabel ensure](./cmd/spo/list/list-retent

Update your scripts to use the new commands instead of the deprecated aliases. Verify that your scripts work as intended.

## Removed deprecated options `label`, `blockDelete` and `blockEdit` from `spo list retentionlabel ensure` command

In version 7 of the CLI for Microsoft 365, we have removed the options `label`, `blockDelete` and `blockEdit` from the `spo list retentionlabel ensure` command. Both options `blockDelete` and `blockEdit` were currently being ignored even though they were set when calling the command. The option `label` has been removed due to naming conventions.

### What action do I need to take?

Remove the references to the option `blockDelete` and `blockEdit` from commands and replace the option `label` to `name` if it is currently being used in scripts.

## Aligned options with naming convention

In version 7 of the CLI for Microsoft 365, we have made updates to the options for certain commands, aligning with our naming convention. This includes renaming options to ensure consistency and improve the CLI experience. For example, the option `--environment` for the command `m365 pa app consent set` has been changed to `--environmentName`. These changes aim to make it easier for you to use the CLI.
Expand Down
14 changes: 2 additions & 12 deletions src/m365/spo/commands/list/list-retentionlabel-ensure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,12 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
debug: true,
webUrl: 'https://contoso.sharepoint.com/sites/team1',
listTitle: 'MyLibrary',
label: 'abc'
name: 'abc'
}
});
const lastCall = postStub.lastCall.args[0];
assert.strictEqual(lastCall.data.listUrl, 'https://contoso.sharepoint.com/sites/team1/MyLibrary');
assert.strictEqual(lastCall.data.complianceTagValue, 'abc');
assert.strictEqual(lastCall.data.blockDelete, false);
assert.strictEqual(lastCall.data.blockEdit, false);
assert.strictEqual(lastCall.data.syncToItems, false);
});

Expand Down Expand Up @@ -181,8 +179,6 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
const lastCall = postStub.lastCall.args[0];
assert.strictEqual(lastCall.data.listUrl, 'https://contoso.sharepoint.com/sites/team1/MyLibrary');
assert.strictEqual(lastCall.data.complianceTagValue, 'abc');
assert.strictEqual(lastCall.data.blockDelete, false);
assert.strictEqual(lastCall.data.blockEdit, false);
assert.strictEqual(lastCall.data.syncToItems, false);
});

Expand Down Expand Up @@ -213,8 +209,6 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
const lastCall = postStub.lastCall.args[0];
assert.strictEqual(lastCall.data.listUrl, 'https://contoso.sharepoint.com/sites/team1/MyLibrary');
assert.strictEqual(lastCall.data.complianceTagValue, 'abc');
assert.strictEqual(lastCall.data.blockDelete, false);
assert.strictEqual(lastCall.data.blockEdit, false);
assert.strictEqual(lastCall.data.syncToItems, false);
});

Expand All @@ -232,21 +226,17 @@ describe(commands.LIST_RETENTIONLABEL_ENSURE, () => {
webUrl: 'https://contoso.sharepoint.com/sites/team1',
listUrl: 'MyLibrary',
name: 'abc',
blockDelete: true,
blockEdit: true,
syncToItems: true
}
});
const lastCall = postStub.lastCall.args[0];
assert.strictEqual(lastCall.data.listUrl, 'https://contoso.sharepoint.com/sites/team1/MyLibrary');
assert.strictEqual(lastCall.data.complianceTagValue, 'abc');
assert.strictEqual(lastCall.data.blockDelete, true);
assert.strictEqual(lastCall.data.blockEdit, true);
assert.strictEqual(lastCall.data.syncToItems, true);
});

it('fails validation if the url option is not a valid SharePoint site URL', async () => {
const actual = await command.validate({ options: { webUrl: 'foo', listId: 'cc27a922-8224-4296-90a5-ebbc54da2e85' } }, commandInfo);
const actual = await command.validate({ options: { webUrl: 'foo', listId: 'cc27a922-8224-4296-90a5-ebbc54da2e85', name: 'abc' } }, commandInfo);
assert.notStrictEqual(actual, true);
});

Expand Down
38 changes: 3 additions & 35 deletions src/m365/spo/commands/list/list-retentionlabel-ensure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ interface CommandArgs {

export interface Options extends GlobalOptions {
webUrl: string;
name?: string;
label?: string;
name: string;
listId?: string;
listTitle?: string;
listUrl?: string;
syncToItems?: boolean;
blockDelete?: boolean;
blockEdit?: boolean;
}

class SpoListRetentionLabelEnsureCommand extends SpoCommand {
Expand All @@ -45,14 +42,10 @@ class SpoListRetentionLabelEnsureCommand extends SpoCommand {
#initTelemetry(): void {
this.telemetry.push((args: CommandArgs) => {
Object.assign(this.telemetryProperties, {
name: (!(!args.options.name)).toString(),
label: (!(!args.options.label)).toString(),
listId: (!(!args.options.listId)).toString(),
listTitle: (!(!args.options.listTitle)).toString(),
listUrl: (!(!args.options.listUrl)).toString(),
syncToItems: args.options.syncToItems || false,
blockDelete: args.options.blockDelete || false,
blockEdit: args.options.blockEdit || false
syncToItems: args.options.syncToItems || false
});
});
}
Expand All @@ -63,10 +56,7 @@ class SpoListRetentionLabelEnsureCommand extends SpoCommand {
option: '-u, --webUrl <webUrl>'
},
{
option: '--name [name]'
},
{
option: '--label [label]'
option: '--name <name>'
},
{
option: '-t, --listTitle [listTitle]'
Expand All @@ -79,12 +69,6 @@ class SpoListRetentionLabelEnsureCommand extends SpoCommand {
},
{
option: '--syncToItems'
},
{
option: '--blockDelete'
},
{
option: '--blockEdit'
}
);
}
Expand All @@ -106,20 +90,6 @@ class SpoListRetentionLabelEnsureCommand extends SpoCommand {
}

public async commandAction(logger: Logger, args: CommandArgs): Promise<void> {
if (args.options.label) {
args.options.name = args.options.label;

this.warn(logger, `Option 'label' is deprecated. Please use 'name' instead`);
}

if (args.options.blockDelete) {
this.warn(logger, `Option 'blockDelete' is deprecated.`);
}

if (args.options.blockEdit) {
this.warn(logger, `Option 'blockEdit' is deprecated.`);
}

try {
let listRestUrl: string = '';
let listServerRelativeUrl: string = '';
Expand Down Expand Up @@ -159,8 +129,6 @@ class SpoListRetentionLabelEnsureCommand extends SpoCommand {
data: {
listUrl: listAbsoluteUrl,
complianceTagValue: args.options.name,
blockDelete: args.options.blockDelete || false,
blockEdit: args.options.blockEdit || false,
syncToItems: args.options.syncToItems || false
},
responseType: 'json'
Expand Down

0 comments on commit 0224182

Please sign in to comment.