Skip to content

feat: mass assign attributes#16995

Merged
PeerRich merged 4 commits intomainfrom
feat/mass-assign-attributes
Oct 9, 2024
Merged

feat: mass assign attributes#16995
PeerRich merged 4 commits intomainfrom
feat/mass-assign-attributes

Conversation

@sean-brydon
Copy link
Copy Markdown
Member

@sean-brydon sean-brydon commented Oct 8, 2024

What does this PR do?

Implements mass assignment of attributes
Fixes: #16985
Loom: https://www.loom.com/share/e821740381b644cabf6508f84800a198

TODO: https://linear.app/calcom/issue/CAL-4481/refactor-assignment-of-attributes (Out of scope for this PR)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have added a Docs issue here if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • create an organization
  • Create attributes of every type
  • Bulk assign to users in your org

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

@graphite-app graphite-app Bot requested a review from a team October 8, 2024 13:09
@github-actions github-actions Bot added the ❗️ migrations contains migration files label Oct 8, 2024
@keithwillcode keithwillcode added consumer core area: core, team members only labels Oct 8, 2024
Comment thread apps/web/package.json
"next-seo": "^6.0.0",
"next-themes": "^0.2.0",
"nodemailer": "^6.7.8",
"nuqs": "^1.20.0",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

https://nuqs.47ng.com/

We've talked about using this a lot before so thought now would be a good time

@dosubot dosubot Bot added organizations area: organizations, orgs ✨ feature New feature or request labels Oct 8, 2024
const [selectedAttribute, setSelectedAttribute] = useQueryState("a", parseAsString);
const utils = trpc.useUtils();
const attributeData = utils.viewer.attributes.list.getData();
const foundAttribute = attributeData?.find((attr) => attr.id === selectedAttribute);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Get the data from cache instead of propdrilling / requerying on ID

We know it exists as we fetch all attributes from org

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Oct 8, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (10/08/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (10/09/24)

1 label was added to this PR based on Keith Williams's automation.

}
const translateableType = getTranslateableStringFromType(foundAttribute.type);

const isSelectable = foundAttribute.type === "SINGLE_SELECT" || foundAttribute.type === "MULTI_SELECT";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Used to determine if we use checkboxes or text input

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Oct 8, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@formkit/auto-animate@1.0.0-beta.5 None 0 35.4 kB justin-schroeder
npm/bcryptjs@2.4.3 None 0 221 kB dcode

View full report↗︎

);
}

if (showMultiSelectWarning) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Warning to show the behaviour of multi select merging with existing options for that attribute.

Comment on lines +243 to +259
if (
foundAttributeInCache?.type === "MULTI_SELECT" ||
foundAttributeInCache?.type === "SINGLE_SELECT"
) {
attributesToAssign = [
{
id: foundAttributeInCache.id,
options: selectedAttributeOptions.map((v) => ({
value: v,
})),
},
];
} else {
attributesToAssign = [
{ id: foundAttributeInCache.id, value: selectedAttributeOptions[0] },
];
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This isnt that nice i created https://linear.app/calcom/issue/CAL-4481/refactor-assignment-of-attributes to refactor how we pass data into the assignAttributes

@@ -0,0 +1,2 @@
-- DropIndex
DROP INDEX "AttributeOption_attributeId_value_key";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We couldnt unique here - i found out that you couldnt assign the two different member the same value. It has no effect on anything else

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Oct 8, 2024 1:14pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Oct 8, 2024 1:14pm

Copy link
Copy Markdown
Member

@alishaz-polymath alishaz-polymath left a comment

Choose a reason for hiding this comment

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

Let's go. Looking great 🚀 🚀

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 9, 2024

E2E results are ready!

@PeerRich PeerRich merged commit c7b1fbd into main Oct 9, 2024
@PeerRich PeerRich deleted the feat/mass-assign-attributes branch October 9, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only ✨ feature New feature or request ❗️ migrations contains migration files organizations area: organizations, orgs ready-for-e2e Urgent Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-4477] members view: mass select and add attributes

4 participants