Skip to content
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

feature: add new survey notification to design page #8155

Merged
merged 32 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a23eebb
add custom style
beyackle Jun 14, 2021
95d2677
Update Publish.tsx
beyackle Jun 14, 2021
de094b9
display card on Home page
beyackle Jun 14, 2021
611ff7f
Update constants.tsx
beyackle Jun 14, 2021
1bef946
Update shell.ts
beyackle Jun 14, 2021
21aaba2
Merge branch 'feature/hats-survey' into beyackle/hatsUsage
beyackle Jun 15, 2021
5f51dab
Update Home.tsx
beyackle Jun 15, 2021
397a746
move survey into separate component
beyackle Jun 15, 2021
0fe5ebd
get more info automatically
beyackle Jun 15, 2021
518ed0e
move URL into constant
beyackle Jun 15, 2021
150ec25
move more props around
beyackle Jun 15, 2021
6a160b2
Update constants.tsx
beyackle Jun 15, 2021
43beda7
turn non-rendering component into hook
beyackle Jun 15, 2021
ecf2e2d
move card to design page
beyackle Jun 16, 2021
dadb925
start adding ipcRenderer stuff
beyackle Jun 17, 2021
a9babdd
update card design
beyackle Jun 17, 2021
7ea55db
get machineID and stash in Recoil
beyackle Jun 18, 2021
7b4d460
read OS and place in URL
beyackle Jun 18, 2021
27037dc
add spacer to notification card
beyackle Jun 18, 2021
854cffc
better notification styling
beyackle Jun 18, 2021
7d8f8ae
fix constants and typercheck error
beyackle Jun 18, 2021
f7c1459
Merge branch 'feature/hats-survey' into beyackle/hatsUsage
beyackle Jun 21, 2021
24d9f06
fixes from PR
beyackle Jun 21, 2021
80f7464
fix card alignment and make aka.ms URL
beyackle Jun 21, 2021
e727353
remove redundant prop
beyackle Jun 21, 2021
fbeff10
use query-string package to generate link
beyackle Jun 22, 2021
c6416d5
move MAC truncation to electron server
beyackle Jun 22, 2021
ac6853a
add fixes from CR and machineID truncation
beyackle Jun 23, 2021
d0cd394
fix typechecking
beyackle Jun 23, 2021
7121967
Update ToolbarButtonMenu.test.tsx
beyackle Jun 23, 2021
0dd4982
Update App.tsx
beyackle Jun 24, 2021
f062b3f
Merge branch 'feature/hats-survey' into beyackle/hatsUsage
beyackle Jun 24, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ const defaultCardContentRenderer = (props: CardProps) => {
{description && <div css={cardDescription}>{description}</div>}
<Stack horizontal horizontalAlign="space-between">
<Stack {...stackProps}>
{leftLinkList.map(
(link) => link != null && <Stack.Item key={link.label}>{makeLinkLabel(link)}</Stack.Item>
)}
{leftLinkList.map((link) => (
<Stack.Item key={link.label}>{makeLinkLabel(link)}</Stack.Item>
))}
</Stack>
<Stack {...stackProps}>
{rightLinkList.map(
(link) => link != null && <Stack.Item key={link.label}>{makeLinkLabel(link)}</Stack.Item>
)}
{rightLinkList.map((link) => (
<Stack.Item key={link.label}>{makeLinkLabel(link)}</Stack.Item>
))}
</Stack>
</Stack>
{type === 'pending' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const buildUrl = (info: MachineInfo) => {
return `${SURVEY_URL_BASE}?${querystring.stringify(parameters)}`;
};

export function useSurveyNotification() {
export const useSurveyNotification = () => {
const { addNotification, deleteNotification } = useRecoilValue(dispatcherState);
const surveyEligible = useRecoilValue(surveyEligibilityState);
const machineInfo = useRecoilValue(machineInfoState);
Expand Down Expand Up @@ -82,4 +82,4 @@ export function useSurveyNotification() {
});
}
}, []);
}
};
1 change: 0 additions & 1 deletion Composer/packages/electron-server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ async function run() {
mainWindow?.webContents.openDevTools();
}

log(`Machine ID is ${machineId}`);
mainWindow?.webContents.send('machine-info', { id: machineId, os: os.platform() });
});

Expand Down
11 changes: 7 additions & 4 deletions Composer/packages/electron-server/src/utility/machineId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ import { readTextFileSync, writeJsonFileSync } from './fs';

export const persistedFilePath = path.join(app.getPath('userData'), 'persisted.json');

function truncate(str: string): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Arrow function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see what that would get us here. This isn't inside a component that gets re-rendered, this isn't exported anywhere, it's just a simple utility function that belongs to this one file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The other functions in this file use arrow functions. Best to be consistent. More of a nit.

return str.slice(0, str.length * 0.8);
}

export async function getMachineId(): Promise<string> {
if (!existsSync(persistedFilePath)) {
const hashedMac = await getMacMachineId();
const machineId = hashedMac?.slice(0, hashedMac.length * 0.8) || uuid();
const machineId = (await getMacMachineId()) || uuid();
const telemetrySettings = { machineId };

writeJsonFileSync(persistedFilePath, telemetrySettings);
return machineId;
return truncate(machineId);
} else {
const raw = readTextFileSync(persistedFilePath);
return JSON.parse(raw).machineId;
return truncate(JSON.parse(raw).machineId);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Composer/packages/types/src/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export type Notification = {
description?: string;
retentionTime?: number;
link?: NotificationLink;
links?: (NotificationLink | null | undefined)[];
leftLinks?: (NotificationLink | null | undefined)[];
rightLinks?: (NotificationLink | null | undefined)[];
links?: NotificationLink[];
leftLinks?: NotificationLink[];
rightLinks?: NotificationLink[];
icon?: string;
color?: string;
read?: boolean;
Expand Down